jradiobutton

What am i doing wrong in retrieving value of button group?

我的梦境 提交于 2019-12-11 08:23:55
问题 import javax.swing.*; import javax.swing.event.*; import java.awt.*; import java.awt.event.*; import net.java.dev.designgridlayout.DesignGridLayout; import java.sql.*; class databaseprob { JFrame JF; Container C,C1; JDesktopPane JDP; JInternalFrame JIF5; JLabel i1l1,i1l2; JTextField i1t1; JRadioButton i1r1,i1r2,i1r3,i1r4; JButton i1b1,i1b2,i1b3; JInternalFrame JIF1; ButtonGroup i1bg; String i1type; public databaseprob() { JF = new JFrame(); JDP = new JDesktopPane(); JF.setVisible(true); JF

can't set JPanel color and JRadioButton invisibility

≡放荡痞女 提交于 2019-12-11 05:36:18
问题 I have problem with setting JPanel and JFrame color to white, though I used panel.setBackground(Color.white) . The second problem is that setting ImageIcon in JRadioButton constructor causes that JRadioButton is invisible. Here is my code: public class proby { static JPanel panel = new JPanel(); static JPanel panel2 = new JPanel(); private void createAndShowGUI() { final ImageIcon zielonaikona = new ImageIcon("green2.png"); final ImageIcon czerwonaikona = new ImageIcon("red2.png"); final

How to deselect already selected JRadioButton by clicking on it

被刻印的时光 ゝ 提交于 2019-12-11 05:29:25
问题 Let's say we are having some JRadioButton s which belongs to same ButtonGroup , when user clicks on a JRadioButton it got selected. I want to add a feature that when user click on already selected JRadioButton , it gets deselected, that is whole ButtonGroup will have no JRadioButton selected. I already searched which leads me hint to use, ButtonGroup method, clearSelection. but problem is that when user clicks on already selected JRadioButton, it is not generating any ItemStateChangeEvent ,

Cannot properly add values to ArrayList from radio Buttons - Java GUI

淺唱寂寞╮ 提交于 2019-12-11 04:17:18
问题 I have created a program that allows a user to choose restaurant menu items and adds the total of each item creating a double mealTotal for each person. I need to also add each mealTotal every time a new person is entered(using the Next Person button) to come up with the tableTotal which I have created as an ArrayList. I cannot seem to get the arraylist to add more than just the last person's mealTotal. I need it to include every person's mealTotal, i.e., if there were 4 people, my tableTotal

Vertical alignment of icons with various size in JRadioButtonMenuItem

浪子不回头ぞ 提交于 2019-12-11 01:58:21
问题 I met problem to align icons of different sizes with JRadioButtonMenuItem . Here's a picture of my problem. The icons have several sizes and are left aligned. I would like to center the icons as in the picture below. Apparently, none of the methods of JRadioButtonMenuItem class allow to do that... 回答1: As an alternative, implement the Icon interface using a constant enclosing size and scale the rendered content to reflect the desired image size, as shown in this example. For convenience, you

Insert Radiobuttons in JTable Netbeans

非 Y 不嫁゛ 提交于 2019-12-09 02:20:22
I am populating Employee Data in JTable using Netbeans. I want to add Radiobutton in each row, so that user can select any row and can perform actions like Update/Delete,etc. Here is my code for TableModel: DefaultTableModel model = new DefaultTableModel(); model.setColumnIdentifiers(new String[] {"Select","Employee ID","Name","Surname","Birth Place","Genre","Home","Marital Status","Phone","Age","Department"}); try{ con = DriverManager.getConnection ("jdbc:mysql://localhost:3306/"+database,"root","123456"); Statement s = con.createStatement (); s.executeQuery ("SELECT * FROM Employee");

Java trouble with ArrayLists when there are multiple classes and help fixing up the code [closed]

岁酱吖の 提交于 2019-12-06 06:37:40
Closed . This question needs details or clarity . It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post . Closed 5 years ago . I've come to the conclusion that I have 3 questions. How do I use the variables and arrayList of the company class in the Employee class. How should I make the actionListeners so the operate correctly. Would the methods in the Company class work correctly? If not, how should I make them? Check the link given in the paragraph above for the prompt to my question. Here is a link to the prompt my

how to use JRadioButton groups with a model

…衆ロ難τιáo~ 提交于 2019-12-06 03:00:23
Is there any way to associate a group of JRadioButtons with a data model so it is easier to tell which button (if any) is selected? In an ideal world, I would like to associate a group of N radiobuttons with an enum class that has a NONE value and one value associated with each radiobutton. I solved my own problem, this wasn't too hard, so share and enjoy: import java.util.EnumMap; import java.util.Map; import javax.swing.JRadioButton; public class RadioButtonGroupEnumAdapter<E extends Enum<E>> { final private Map<E, JRadioButton> buttonMap; public RadioButtonGroupEnumAdapter(Class<E>

Clearing a group of radio buttons in Java

吃可爱长大的小学妹 提交于 2019-12-01 22:16:06
问题 I have a program which prompts users to select a choice out of four options (from a group of RadioButtons). Once the user has made a choice, he/she clicks a button and then receives a message. After closing the window, the user will go back to the first window and make a new selection if desired. What I want is for the radiobuttons to be totally clear. So far I have implemented a method to actually unselect the radiobuttons and works well (clears the values of the variables), what it doesn't

setSelected a specific jradiobutton in a buttongroup based on action command

↘锁芯ラ 提交于 2019-12-01 21:14:14
i want to setSelected a speicfic jradiobutton in a buttongroup based on the actionCommand(/name of the specific jradiobutton). it could be done usind .setSelected(true) for example, JRadioButton rabbitButton = new JRadioButton("rabbit"); rabbitButton .setActionCommand("rabbit"); JRadioButton pigButton = new JRadioButton("pig"); pigButton .setActionCommand("pig"); ButtonGroup group = new ButtonGroup(); group.add(rabbitButton); group.add(pigButton); now.. without , { rabbitButton.setSelected(true);} NOR {group.setSelected(rabbitButton.getModel,true)} is there a way to setSelected(true)