G
gtmeloney
I am trying to create a java application with several JButtons, a
JTextField and 6 JRadioButtons. I am trying to use only 1 panel but am
unable to get anything to show up besides the JButtons. I am trying to
use no layout manager so I can position things myself absolutely. I'm
pretty sure that my problem is something to do with
"myPanel.setLayout(null)". But any help would be appreciated. Thanks
JFrame myFrame = new JFrame ("Conversion Gui (TEST)");
myFrame.setDefaultLookAndFeelDecorated (false);
myFrame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
JRadioButton radBtn1 = new JRadioButton ("Button 1");
JRadioButton radBtn2 = new JRadioButton ("Button 2");
radBtn1.setLocation (100,200);
ButtonGroup bg = new ButtonGroup();
bg.add(radBtn1);
bg.add(radBtn2);
myPanel = new JPanel();
myPanel.setLayout(null);
myPanel.add(radBtn1);
myPanel.add(radBtn2);
radBtn2.setLocation (200,300);
myFrame.add(myPanel);
myFrame.pack();
myFrame.setSize (500,500);
myFrame.setVisible(true);
JTextField and 6 JRadioButtons. I am trying to use only 1 panel but am
unable to get anything to show up besides the JButtons. I am trying to
use no layout manager so I can position things myself absolutely. I'm
pretty sure that my problem is something to do with
"myPanel.setLayout(null)". But any help would be appreciated. Thanks
JFrame myFrame = new JFrame ("Conversion Gui (TEST)");
myFrame.setDefaultLookAndFeelDecorated (false);
myFrame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
JRadioButton radBtn1 = new JRadioButton ("Button 1");
JRadioButton radBtn2 = new JRadioButton ("Button 2");
radBtn1.setLocation (100,200);
ButtonGroup bg = new ButtonGroup();
bg.add(radBtn1);
bg.add(radBtn2);
myPanel = new JPanel();
myPanel.setLayout(null);
myPanel.add(radBtn1);
myPanel.add(radBtn2);
radBtn2.setLocation (200,300);
myFrame.add(myPanel);
myFrame.pack();
myFrame.setSize (500,500);
myFrame.setVisible(true);