We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,624 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

How to create a JFrame like an JOptionPane

Hi,

Im developing a game. When the human gets his turn i want to display a JFrame with some buttons.
So the game must wait until the user clicks on a button. Also i want to identify which button is clicked.

I read that JOptionPna gets any component as a parameter.I did the following.
but the coding of the my object is shown inside an input field.

 MyFrame my=new MyFrame();
 JOptionPane.showInputDialog(null,"test",my);

PLZ....... help me

3
Contributors
2
Replies
1 Day
Discussion Span
9 Months Ago
Last Updated
3
Views
coroll
Junior Poster in Training
98 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

the game must wait until the user clicks on a button

Look at the JDialog class.

NormR1
Posting Sage
Team Colleague
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16

Do you want it as a JFrame or just a simple quick option selection pane?

Just a quick snippet I took because I cba looking up Java doc stuff:

 static String[] connectionOptions = {"Real server", "Fake server", "Simulation server"};
 String input = (String) JOptionPane.showInputDialog(null, "Choose option","Connection selection", JOptionPane.QUESTION_MESSAGE, null, connectionOptions, connectionOptions[0]);

That would return an option selected from a drop down box. So if 'Real server' was selected the string would be 'Real server' etc.

Taios
Newbie Poster
5 posts since Aug 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0603 seconds using 2.69MB