mandril
mandril

Reputation: 401

Java make JDialog Listen until the user hits a JButton

I have a while loop that performs a game table.

For example lets say i have a table with 4 people and the while should open every persons window and ask him "Pay" "Pass" "Discard Card" options (buttons) .. until they dont press the buttons and the actionperformed is executed then the while wont continue to open the next person window.

I discovered that calling a JOPtionPane message stop the while loop until i press the OK button, i want that "effect" on my windows but without the optionpane(obvious), using my custom buttons "Pay" "Pass" "Discard Card", etc.

When a player pays the bid, then the while will continue and the next player window will appear asking him with 3 buttons: "Pay" "Pass" "Discard Card".

Anyone? Thanks!!!

Upvotes: 0

Views: 271

Answers (2)

youzhi.zhang
youzhi.zhang

Reputation: 141

yep,you can try like this:

String[] choices = {"Java", "C++", "VB", "PHP"};
    int response = JOptionPane.showOptionDialog(null, "Which is your favourite programming language?", "Language Poll", JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, null, choices, "None of your business");

Upvotes: 1

camickr
camickr

Reputation: 324207

You can use a JOptionPane with custom buttons. Read the API and follow the link to the section in the Swing tutorial on How to Make Dialogs for an example.

Or you can use an undecorated JDialog and add your own buttons.

Upvotes: 4

Related Questions