Results 1 to 6 of 6
Thread: GUI problem...
- 12-07-2007, 09:06 AM #1
Member
- Join Date
- Nov 2007
- Posts
- 15
- Rep Power
- 0
- 12-07-2007, 09:30 AM #2
Member
- Join Date
- Nov 2007
- Posts
- 15
- Rep Power
- 0
hmm...
can somebody help me please????
- 12-07-2007, 09:35 AM #3
Member
- Join Date
- Nov 2007
- Posts
- 15
- Rep Power
- 0
hayyyy...
i need this as soon as possible... please... somebody...:)...T_T
- 12-07-2007, 11:00 AM #4
Member
- Join Date
- Aug 2007
- Posts
- 26
- Rep Power
- 0
you can start from something like this:
Hope this helpsJava Code:import java.awt.BorderLayout; import javax.swing.JCheckBox; import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.JPanel; public class UserInput extends JPanel{ JPanel checkBoxPanel = new JPanel(); public UserInput(){ int noOfCBReq = Integer.parseInt( JOptionPane.showInputDialog("Enter the number of check boxes needed")); JCheckBox[] cb = new JCheckBox[noOfCBReq]; for(int i=0; i<cb.length; i++){ JCheckBox checkBox = new JCheckBox(); checkBox.setText("Check box"+i); checkBoxPanel.add(checkBox); } add(checkBoxPanel, BorderLayout.CENTER); } public static void main(String[] args){ JFrame f = new JFrame("User Input test"); f.getContentPane().add(new UserInput()); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.pack(); f.setVisible(true); } }
-R
- 12-07-2007, 11:04 AM #5
Member
- Join Date
- Aug 2007
- Posts
- 26
- Rep Power
- 0
The other way would be to add a Textfield and a JButton. Make the user enter the number of check boxes in the text field and add a ActionListener to the JButton. Create checkboxes in the actionPerformed method of the listener.
Depends on what you want in the GUI...
-R
- 12-11-2007, 03:22 AM #6
Member
- Join Date
- Nov 2007
- Posts
- 15
- Rep Power
- 0


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks