joptionpane

Is there a multiple input JOptionPane in Java?

Hey all, I was wondering if there is a JOptionPane where you can get multiple inputs from a user instead of just one? If not, how could i accomplish this using some type of prompt. I am creating Battleship, and wanted to prompt the user to specify locations to place each ship. Thanks, Tomek ...

How can I make JOptionPane dialogs show up as a task on the taskbar?

Edit: The question follows the horizontal rule; my own answer precedes it. Based on help from Oscar Reyes, I crafted this solution: import javax.swing.JOptionPane; import javax.swing.JFrame; public class MyApp extends JFrame { public static void main(String [] args) { new MyApp(); } public MyApp() { sup...

JOptionPane equivalent in C#?

In Java there's a useful class in the standard Swing libraries called 'JOptionPane' that provides a bunch of pre-made but customizable windows for displaying messages and getting (simple) user input. I know there's 'MessageBox.Show(..)' to display Yes/No/Cancel type messages to the user in C#, but is there an equivalent class (or simple...

Best way to detect whether code is running in an application server java

For a J2EE bean I am reusing code that was developed for a java swing application. JOptionPane.showMessageDialog() is unfortunately commonly used. Most occurences luckily in code sections that are not reused by the J2EE application, but in some cases lower levels of the code has instances of JOptionPane.showMessageDialog(). Obviously thi...

Get the return value of JOptionPane

My JOptionPane code is as follows: selectedSiteName = JOptionPane.showInputDialog("Enter the name of the new site:"); This renders out an input with a textbox and an OK and Cancel button. I need to detect if Cancel was clicked. Cheers. ...

Making a JOptionPane with 4 options

I need to make a custom dialog with 4 options but as far as I can tell you can only have one with three options. Here is how I would make an option pane with 3 options: Frame refFrame = DialogUtils.getReferenceFrame(); ///TODO: /// - Use DialogUtils int option = JOptionPane.showOptionDialog(refFrame, ...

Bug in JOptionPane.showConfirmDialog?

I want to prompt the user for a confirmation when they want to close the frame window, like so: addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { if (JOptionPane.showConfirmDialog(null, "Are you sure you want to abort the game?", "Really quit?", JOptionPane.YES_NO_OPTION) == JOption...

How to make JOptionPane.showConfirmDialog have No selected by default?

I implemented a Save As dialog in Java that prompts the user if the file already exists, and I want the No option to be selected by default. How do I do this? Here is my current code: JFileChooser chooser = new JFileChooser() { public void approveSelection() { File selectedFile = getSelectedFile(); if (selectedF...

Setting Mnemonics and Hot Keys for a JOptionPane Dialog

Is it possible to assign hotkeys and mnemonics to the buttons in a JOptionPane Dialog? I'd like to be able, in a JOptionPane generated message dialog with the options Yes, No and Cancel, press Y to hit the Yes button, N to hit the No button and escape to activate the escape button. Similarly in a dialog with Okay and Cancel buttons I'd...

Changing Font Size and leaving space between button in a JOptionPane

The text in my JOptionPanes are way to small I was wondering how I could change the font of the text inside the pane. Also, I would like to be set a space between two buttons. Something like |Canecl| |DoneSave| |Save| ...

Disabling the close x in a JOptionPane

I would like to disable the close x in the upper left corner of my JOptionPane how would I do this? ...

Using JOptionPane

if i was using a JOptionPane message dialog box how would I be able to show an the whole array in the message section such as this little snipit? or would that evenbe possible? public void showTheMessage() { JOptionPane.showMessageDialog(null,"These are are all the colors to choosfrom,\n"+ arrayOfcolors[the whole array], "...

Message Dialog Box Reappears After OK button is clicked

Hi, After getting good help previously, I have completed my Minesweeper game. However, there is one problem that I can't figure out. The game itself works fine, however, I have an option for the user to change difficulty setting (beginner, intermediate, advanced) which is giving me grief. The user selects "Game" from the JMenuBar and the...

JOptionPane customize input

All I want to do is have a JOptionPane inputDialog with a JTextArea instead of a JTextField. I tried putting the JTextArea inside of the Message parameter like so Object[] inputText = new Object[]{new JLabel("Enter Graph Information"), newJTextArea("",20,10)}; graphInfo=(String)JOptionPane.showInputDial...

Question about the cancel button on a standard JOptionPane

So I am working on a program for school, and part of the assignment is to have a bunch of prompts for input pop up. I am using the JOptionPane, which inherently has an OK button and a Cancel button. Now, to make the program exit when they press cancel when the prompt is asking for a string, I have something like this: firstName = JOpti...

print matrix in dialog box

Hello, I'm having a little difficulty to print a matrix array on dialog box. The matrix is integer and as far as i understood i need to change it into string? anyway, here's the code: public void print_Matrix(int row, int column) { for (int i = 0; i <= row; i++) { for (int j = 0; j <= column; j++) { JOptionPane.s...

Unable to change background colour for JOptionPane

Hi I have created sample progeam which will give same look and feel of a confirm dialog and set the background colour as red. But I donot know what is the problem that my background colour of option is displayed as the default colour but not red. also i need same look and feel of confirm dialog across all platforms. Here is the code tha...

JOptionPane background Image.

How to set background Image of JOptionPane? I want to show a different image on background of an JOptionPane. ...

Localization of javax.swing.JOptionPane's default button labels in OS X

How can this be achieved? I have the ff. test code: javax.swing.JOptionPane.showMessageDialog(null, "Hello, world!"); Running it with, say, -Duser.language=zh and -Duser.country=TW doesn't work. I.e., the OK button is still labeled "OK". In Windows, for example, it is replaced with the Traditional Chinese equivalent. ...

How to get JOptionPane with three text fields

I want to know how i can do a messageBox from three input dialog .. Like this: JOptionPane.showInputMessageDialog("Enter your FirstName"); JOptionPane.showInputMessageDialog("Enter your MiddleName"); JOptionPane.showInputMessageDialog("Enter your LastName"); But I want one message has a three input boxes. ...