LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-17-2003, 06:58 PM   #1
titanium_geek
Senior Member
 
Registered: May 2002
Location: Horsham Australia
Distribution: elementary os 5.1
Posts: 2,479

Rep: Reputation: 50
Question Java menus (radio buttons) and panels


Allright, I'm just gonna jump into this head first, so here goes...

HOW DO I DO RADIO BUTTONS? I know how to do them so that they just turn up, (like I did with the other menu items, normal ones) like this:
Code:
	JMenu semnu = new JMenu("Settings");
		JRadioButtonMenuItem sob;
		ButtonGroup crowd = new ButtonGroup();
		semnu.add(sob = new JRadioButtonMenuItem("easy", true));
		crowd.add(sob);
		semnu.add(sob = new JRadioButtonMenuItem("medium"));
		crowd.add(sob);
		semnu.add(sob = new JRadioButtonMenuItem("hard"));
		crowd.add(sob);
		semnu.addSeparator();
the problem is that I moved my normal menu items out of the method so I could do action listening easier (read: so I could do it). The problem? I get an error when I move ^ that stuff up out of the method.
I mean, I declare the menu items before the method, then add them in the method. Help, Please?

allright: another problem (a quickie)
I have a help menu, that when clicked, pops up a new JFrame and tells the user what to do. I have a button "OK" to click when done, but I don't want
Code:
System.exit(0)
, do I? that would make the program quit. How do I close a JFrame, without closing the program?

thanks people.

titanium_geek
 
Old 12-19-2003, 03:06 AM   #2
nephilim
Member
 
Registered: Aug 2003
Location: Belgium
Distribution: Debian (server), Kubuntu (desktop)
Posts: 248

Rep: Reputation: 30
check out http://java.sun.com/docs/books/tutor...ml#radiobutton for questions on radio buttons.

You talk about action listeners, but I don't see you declaring one in the code that you posted. You should have crowd.addActionListener(your_action_listener) or something like that. Maybe you should post some more of your code to clarify the situation.

To close a JFrame, use the dispose() method.

name_of_JFrame.dispose()
 
Old 12-19-2003, 05:15 AM   #3
titanium_geek
Senior Member
 
Registered: May 2002
Location: Horsham Australia
Distribution: elementary os 5.1
Posts: 2,479

Original Poster
Rep: Reputation: 50
thankyou.

umm.. I declare my action listeners separately, and do the action event stuff separately. Thanks though, that really cleared things up for me.

thanks for the link also.

titanium_geek
 
Old 12-19-2003, 09:32 AM   #4
nephilim
Member
 
Registered: Aug 2003
Location: Belgium
Distribution: Debian (server), Kubuntu (desktop)
Posts: 248

Rep: Reputation: 30
No problem. If you have specific problems, don't hesitate to ask for advise.
 
Old 12-22-2003, 06:00 AM   #5
titanium_geek
Senior Member
 
Registered: May 2002
Location: Horsham Australia
Distribution: elementary os 5.1
Posts: 2,479

Original Poster
Rep: Reputation: 50
These posts were very helpful guys...
thanks.

my problem now is to actually get the progaming doing something useful(!)

titanium_geek
 
Old 01-07-2004, 10:43 AM   #6
german
Member
 
Registered: Jul 2003
Location: Toronto, Canada
Distribution: Debian etch, Gentoo
Posts: 312

Rep: Reputation: 30
To close a JFrame or JDialog, JWindow etc. without exiting the program call it's dispose() method. If you want it to persist so you can hide it temporarily, call setVisible(false) then when you want to redisplay it call setVisible(true).

HTH

B.

edit:

oops, nephilim beat me to it, missed that post... sorry for the redundant post

Last edited by german; 01-07-2004 at 10:44 AM.
 
Old 01-07-2004, 11:13 AM   #7
titanium_geek
Senior Member
 
Registered: May 2002
Location: Horsham Australia
Distribution: elementary os 5.1
Posts: 2,479

Original Poster
Rep: Reputation: 50
thanks german. the set visible false thing could be useful.

titanium_geek
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Menus, Panels, and Launchers? Bojamin Linux - Newbie 11 09-06-2005 03:43 PM
GTK apps have HUGE menus & buttons, it's messed up Elijah Linux - Software 3 07-21-2005 09:56 AM
Help with Panels in Java please. Diederick Programming 1 07-07-2005 03:44 PM
Question about drop down menus and Java Hockeyfan Programming 1 06-07-2005 11:16 PM
Java + Swing = Huge Buttons/Menus damicatz Linux - Software 0 01-02-2005 12:59 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration