|
-
May 22nd, 2003, 02:10 AM
#1
Thread Starter
Lively Member
JAVA GUI stuff
1. on radiobuttons:
JRadioButton a= new JRadioButton("A");
JRadioButton b= new JRadioButton("B");
ButtonGroup bg = new ButtonGroup();
bg.add(a); bg.add(b);
JPanel mode = new JPanel(new GridLayout(1, 1));
mode.add(bg);
ERROR:
Incompatible type for method. Can't convert javax.swing.ButtonGroup to java.awt.Component.
eh?
2. also, how do i use the isSelected method so that radiobutton "A" is selected on load?
3. finally, x.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); in void main, but it doesn't work, something like EXIT_ON_CLOSE not declared...
-
May 23rd, 2003, 01:36 AM
#2
mode.add(a); mode.add(b);
The ButtonGroup is a manager, it isn't added to anything.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
May 23rd, 2003, 06:08 AM
#3
Re: JAVA GUI stuff
Originally posted by quipy
3. finally, x.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); in void main, but it doesn't work, something like EXIT_ON_CLOSE not declared...
I remember hitting this bug when I was in school. Try this instead :
Code:
x.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent we) { System.exit(0); }
});
Where x is the JFrame as you have indicated.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
May 25th, 2003, 04:32 PM
#4
Hyperactive Member
Re: JAVA GUI stuff
Originally posted by quipy
2. also, how do i use the isSelected method so that radiobutton "A" is selected on load?
Use a.setSelected(true) in the form constructor
3. finally, x.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); in void main, but it doesn't work, something like EXIT_ON_CLOSE not declared...
You need JDK 1.4 for that. You can also use 3 but that didn't always work in the lower versions. Your best bet is the windowadapter
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|