Jbutton selection criteria - java

I am designing a Java project which contains a Radio button group having 15 jRadio buttons. Each Radio button have names like "Master", "Front_desk", "Accounts" etc. and this text name is defined in MySQL table. In MySQL table I have defined whether to enable or disable particular radio button. I use following code to get Radio button name from MySQL table
String Btn_name = Rs.getString("Module_name");
after get Btn_name I tried to enable or disable the radio button state by using follwing command
Btn_name.setEnabled(true);
or
Btn_name.setEnabled(false);
but I am getting following error
can not find symbol
symbol : method setEnabled(boolean)
location : variable Btn_name of type String

You need to create a jradiobutton in a standard way,
JRadioButton btn = new JRadioButton().
btn.setText(Btn_name);
btn.setEnabled(true/false);
And create as many jradiobutton you need in a loop over the resultSet.

Related

Setting selected value of AutoCompleteTextView Material drop down list from Firebase

I am using AutoCompleteTextView material drop down list to add information to my Firebase database. This is working correctly and the information is being captured correctly.
I now want to allow my users to edit the information they have previously added to the database. I know how to update normal EditText views but when I use this same method with the AutoCompleteTextViews, the drop down only shows the value that is stored in Firebase and doesn't show the full drop down of options so the user can select a new value if they wish.
The code I am using to show the currently selected values which are stored in the database for these drop downs is
String activityType = data.getStringExtra("Activity_Type");
I am then using this code to populate the drop down lists
editActivityTypeLayout = findViewById(R.id.editActivityTypeLayout);
editActivityType = findViewById(R.id.editActivityType);
final String[] type = new String[]{
"Formal Education Completed", "Other Completed", "Professional Activities", "Self-Directed Learning", "Work-Based Learning"
};
final ArrayAdapter<String> editAdapterType = new ArrayAdapter<>(
EditActivity.this,
R.layout.dropdown_item,
type
);
editActivityType.setAdapter(editAdapterType);
However, this code doesn't populate the drop down list if I include the first line of code.
Is there a different way to display the current value of the drop down and also display the other options?
To display the selected value you should use:
AutoCompleteTextView editText = (AutoCompleteTextView) textInputLayout.getEditText();
editText.setAdapter(adapter);
editText.setText(value,false);
It is important to set the filter false to display the entire list in dropdown and not only the single value.

How to add colum JTable to Jcombobox in Java Eclipse

I add the column value of JTable to JComBoBox full of null notifications
I tried passing the sub-variable and then adding jcombobox but it was not
I have test two ways but failed
1.TableColumn testColumn = tbclass.getColumnModel().getColumn(1);
testColumn.setCellEditor(new DefaultCellEditor(jcombobox));
2.tbclass.getColumnModel().getColumn(1).setCellEditor(new DefaultCellEditor(jcombobox));
The error is
java.lang.NullPointerExceptionat

Javafx mysql, how to get rows one by one

So i'm working on flashcards app and got stuck. I need textfield that get word from my DB, shows it on the screen and change to the next one after user press button. Problem is that when i'm using resultset to set textfield it shows only the last row from DB. I've got no idea how to get first value from DB and then change it to the next after user pres button.
That's part of my button controller:
ResultSet res = st.executeQuery("SELECT fiszka_eng FROM "+LoginHandler.GetLogin()+"");
while(res.next())
{
String textENG = res.getString("table");
TextField.setText(textENG);
//Here i want to wait till the button is pressed and after - change textENG to next row
}
Because you iterate over whole ResultSet object thus setting textENG to last value from db. Maybe add textENG to List and then on button click show next element of that list.

Java SWT TreeViewer with one column that needs to be StyledText

I have a TreeViewer used in an eclipse plugin that uses a content provider and a label provider that implements all of (ITableLabelProvider, IFontProvider, IColorProvider).
But I need one of the columns of the table it creates to hold "links" - underlined blue text that when clicked causes some popup to open. I guess what I want to do is cause that single column to hold styled text and not just text, and attach a listener to the items in that column of the tree, but I couldn't figure out how to do it.
Use a separate label provider for each column using TreeViewerColumn:
TreeViewer viewer = new TreeViewer(.....);
TreeViewerColumn col1 = new TreeViewerColumn(viewer, SWT.LEAD);
col1.setLabelProvider(col1 label provider);
... repeat for other columns
For columns that require styling use DelegatingStyledCellLabelProvider as the column label provider as described here
Note: Do not call viewer.setLabelProvider when using column label providers.

Drop down box selenium

I have a drop down box with the id = PoolsSelect. I am trying to select the value within that drop down box but I'm getting an error, here is my code:
RenderedWebElement element = (RenderedWebElement) driver.findElement(By.id("PoolsSelect"));
RenderedWebElement target = (RenderedWebElement) driver.findElement(By.name("Austria"));
element.dragAndDropOn(target);
and the error I get is
Error: Unable to find element by name using "PoolsSelect" (7)
I am using selenium 2.07a with JUnit 4.8.2.
You say the id of the select is PoolsSelect but yet you're using a By.name selector. Have you tried selecting by id?

Categories