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

the game must wait until the user clicks on a button

Look at the JDialog class.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.