public RadioButtonDemo() { super(new BorderLayout());
//Create the radio buttons. JRadioButton birdButton = new JRadioButton(birdString); birdButton.setMnemonic(KeyEvent.VK_B); birdButton.setActionCommand(birdString); birdButton.setSelected(true);
JRadioButton catButton = new JRadioButton(catString); catButton.setMnemonic(KeyEvent.VK_C); catButton.setActionCommand(catString);
JRadioButton dogButton = new JRadioButton(dogString); dogButton.setMnemonic(KeyEvent.VK_D); dogButton.setActionCommand(dogString);
JRadioButton rabbitButton = new JRadioButton(tigerString); rabbitButton.setMnemonic(KeyEvent.VK_R); rabbitButton.setActionCommand(tigerString);
JRadioButton pigButton = new JRadioButton(undoString); pigButton.setMnemonic(KeyEvent.VK_P); pigButton.setActionCommand(undoString);
//Group the radio buttons. ButtonGroup group = new ButtonGroup(); group.add(birdButton); group.add(catButton); group.add(dogButton); group.add(rabbitButton); group.add(pigButton);
//Register a listener for the radio buttons. birdButton.addActionListener(this); catButton.addActionListener(this); dogButton.addActionListener(this); rabbitButton.addActionListener(this); pigButton.addActionListener(this);
//Set up the picture label. picture = new JLabel(createImageIcon("images/" + birdString + ".gif"));
//Put the radio buttons in a column in a panel. JPanel radioPanel = new JPanel(new GridLayout(0, 1)); radioPanel.add(birdButton); radioPanel.add(catButton); radioPanel.add(dogButton); radioPanel.add(rabbitButton); radioPanel.add(pigButton);
// Listens to the radio buttons public void actionPerformed(ActionEvent e) { picture.setIcon(createImageIcon("images/" + e.getActionCommand() + ".gif")); }
// Returns an ImageIcon, or null if the path was invalid protected static ImageIcon createImageIcon(String path) { java.net.URL imgURL = RadioButtonDemo.class.getResource(path); if (imgURL != null) { return new ImageIcon(imgURL); } else { System.err.println("Couldn't find file: " + path); return null; } }
private static void createAndShowGUI() { //Make sure we have nice window decorations. JFrame.setDefaultLookAndFeelDecorated(true);
//Create and set up the window. JFrame frame = new JFrame("RadioButtonDemo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Create and set up the content pane. JComponent newContentPane = new RadioButtonDemo(); newContentPane.setOpaque(true); frame.setContentPane(newContentPane);
frame.setSize(300,250); frame.setVisible(true); }
public static void main(String[] args) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { createAndShowGUI(); } }); } } --------------------------- Thanks.
Related Pages:
Hi .Again me.. - Java Beginners Hi .Againme.. Hi Friend......
can u pls send me some code on JPanel..
JPanel shoul have
1pic 1RadioButton
..
Like a Voter List...
REsponse me.. Hi friend,
import java.io.*;
import java.awt.
hi again - Java Beginners hi again i did the changes on the code
but still the time is not decreasing
i wanna reach increasing running time target
sorry for asking too...;
// testing every character
for (int n=0 ;n Hi friend,
Do changes
again with xml - XML again with xml hi all
i am a beginner in xml so pls give me the details regarding the methods used in it.
wat will return the methods.../content.aspx?b=STY_XML_21days&seqNum=207
Thanks
Rajanikant Hi
again java - Java Beginners
.i need it
pls help me. Hi Friend,
Have you got any error...again java i will ask
iam using servlets ,in one program my requirement is if there is a image(if u like) in anywhere and we browse that image
again java - Java Beginners again java Hi,
i will ask
iam using servlets ,in one program my requirement is if there is a image(if u like) in anywhere and we browse... please tell me step by step procedure.
pls help me.
Hi Friend
JFREE error again
JFREE error again hi.........
As i had asked u the jfree error i want to tel u that i have taken the both the jar files jfree and jcommon. but then also its giving me error
i am able to compile the code but now when i am
Hi..Again Doubt .. - Java Beginners Hi..Again Doubt .. Thank u for ur Very Good Response...Really great..
i have completed that..
If i click the RadioButton,,ActionListenr should get... WORRY WE'ILL ROCK ");
}
}
}
Hi
Can u send your MainMenu.java
Read data again - Java Beginners
Read data again sir,
i still hav a problem,first your code will be change like this :
in netbeans out message error 5. Can you help meagain. My...
System.err.println("Error: " + e.getMessage());
} Hi friend
doesnt run again - Java Beginners
the soltion
Hi
I am sending u again the code, this code run in my...doesnt run again the code u sent doesnt run
and the error msg says
illegal start with do
even if i change it
it keeps telling me the same
hi see and give me reply as soon as possible hi see and give me reply as soon as possible Hi Friend,
I got path,but it will again ask path error
first i was gave index.jsp.It is displayed and it is not going to next level.
HTTP Status 404 - /struts/hello
type
HI. HI. hi,plz send me the code for me using search button bind the data from data base in dropdownlist
Hi
Hi Hi
How to implement I18N concept in struts 1.3?
Please reply to me
hi.... hi.... plzz sent me d code for counting vowels in a string... gui programme
Hi
Hi I want import txt fayl java.please say me...
Hi,
Please clarify your problem!
Thanks
hi
hi My program is not find java.io.File; why? help me please
Hi
Hi Hi All,
I am new to roseindia. I want to learn struts. I do not know anything in struts. What exactly is struts and where do we use it. Please help me. Thanks in advance.
Regards,
Deepak
hi
, again the label with ââ?¬Å?+Click to add another accountââ?¬Â? should be enable
Hi Hi I have got this code but am not totally understanding what the errors. Could someone Please help. Thanks in advance!
import java.util.Random...!"); // this says to guess higher
System.out.print("Wrong! Again Guess
hi
, display the menu again. the user should respond to this prompt with another
hi
online multiple choice examination hi i am developing online multiple choice examination for that i want to store questions,four options,correct answer in a xml file using jsp or java?can any one help me?
Please
hi.......
for such a programme... plz help me...
Hi Friend,
Try this:
import java.awt....hi....... i've a project on railway reservation... i need to connect netbeans and mysql with the help of jdbc driver... then i need to design
hi
for such a programme... plz help me... i hope for a speedy reply from ur side
hi
for such a programme... plz help me... i hope for a speedy reply from ur side
Hi
Hi The thing is I tried this by seeing this code itself.But I;m facing a problem with the code.Please help me in solving me the issue.
HTTP Status 500 -
type Exception report
message
description The server encountered
hi.. hi.. I want upload the image using jsp. When i browse the file...
BRwowse File!!twad9315.jpg
show me
BROWSE FILE...);
System.out.println("show me");
// Pattern
String browsefile
hi.. hi.. I want upload the image using jsp. When i browse the file...
BRwowse File!!twad9315.jpg
show me
BROWSE FILE...);
System.out.println("show me");
// Pattern
String browsefile
hi.. hi.. I want upload the image using jsp. When i browse the file...
BRwowse File!!twad9315.jpg
show me
BROWSE FILE...);
System.out.println("show me");
// Pattern
String browsefile
hi.. hi.. I want upload the image using jsp. When i browse the file...
BRwowse File!!twad9315.jpg
show me
BROWSE FILE...);
System.out.println("show me");
// Pattern
String browsefile
hi.. hi.. I want upload the image using jsp. When i browse the file...
BRwowse File!!twad9315.jpg
show me
BROWSE FILE...);
System.out.println("show me");
// Pattern
String browsefile
hi.. hi.. I want upload the image using jsp. When i browse the file...
BRwowse File!!twad9315.jpg
show me
BROWSE FILE...);
System.out.println("show me");
// Pattern
String browsefile
hi.. hi.. I want upload the image using jsp. When i browse the file...
BRwowse File!!twad9315.jpg
show me
BROWSE FILE...);
System.out.println("show me");
// Pattern
String browsefile
hi hi i want to develop a online bit by bit examination process as part of my project in this i am stuck at how to store multiple choice questions... can any one help me??????
We are providing you a simple application
hi
storing data in xml file using jsp hi i am storing data in xml file using jsp.in this when i enter data into xml file i am getting xml declaration for each specified data?can any one help me to prevent this?
<
hi.. hi.. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ page contentType="text/html...);
System.out.println("show me");
// Pattern
String browsefile= browsefile1.replace
hi.. hi.. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ page contentType="text/html...);
System.out.println("show me");
// Pattern
String browsefile= browsefile1.replace
hi.. hi.. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ page contentType="text/html...);
System.out.println("show me");
// Pattern
String browsefile= browsefile1.replace
hi.. hi.. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ page contentType="text/html...);
System.out.println("show me");
// Pattern
String browsefile= browsefile1.replace
hi.. hi.. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ page contentType="text/html...);
System.out.println("show me");
// Pattern
String browsefile= browsefile1.replace
hi.. hi.. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ page contentType="text/html...);
System.out.println("show me");
// Pattern
String browsefile= browsefile1.replace
help again plz sorry - Java Beginners
help again plz sorry Thanks for giving me thread code
but i have a question
this code is comletelly right
and i want to make it runs much faster...;
onescounter=0;
// testing every character
for (int n=0 ;n Hi
Plz chk it and reply again - Java Beginners
Plz chk it and reply again Hi Deepak,
Thanks for fast... will be slow also.
so plz help me for this if u understood my question then plz fast reply. Hi Ragini,
Please specify your requirements
After Logout Back Button Should not work again
Kindly Help me...
your regards,
Prudvi raj.
Hi,
you would might...After Logout Back Button Should not work again Hi deepak,,
I am doing Login Page,..
IN That If Logout Then When I Click Logout Button It Should
hi frnds.. help me.. hi frnds.. help me.. i ve a doubt in incompatible type error (block letter). plz help me clear this error!
thanks in advance.
This is my code.
double velo[][] = new double [task] [resource];
for(int i=0;iList<Double>
java again - Date Calendar
java again I can't combine your source code yesterday, can you help meagain. My problem is how we get result jtextfield2 from if jtexfield1 we enter(jTextfield keypressed) then the result out to jTextfield2,
This my jFrame
when refreshing the page the data is stored in data base again
when refreshing the page the data is stored in data base again Hi,
In my application, I am adding form data in database on click of submit... body give me good link for this problem...
Thanks a lot
matching database again - Java Beginners
this ask a question page again. Thank God.
I want to say "A BIG THANK YOU" for helping me about the matching codes.
It is working now after fine tuning the SQL query :-) but I can't do it without you showing me the steps.
My question
Read data again - Java Beginners
Read data again Hey,
i want to ask again about how to read data from txt,
My DB:
kd_div varchar(15),
nm_div varchar(30),
dep varchar(25... data from txt file and send to DB.i'm using one button to call. Hi
Reply Me - Java Beginners
"code too large for try statement" please help me its very urgent......
Hi Ragini,
I can understand your problem. Today once again try...Reply Me Hi Amardeep
I am sending database table name,code
Reply Me - Java Beginners
Reply Me Hi deepak,
your sending web application is good... will be not displayed.
please help me how it is open selection of the user its very urgent
Thanks
Ragini
Hi Ragini
Actually, you can not direct access