Questions tagged [joptionpane]

JOptionPane is a Java class that makes it easy to pop up a standard dialog box that prompts users for a value or informs them of something.

JOptionPane makes it easy to pop up a standard dialog box that prompts users for a value or informs them of something. For information about using JOptionPane, see How to Make Dialogs, a section in The Java Tutorial. Related examples may be found here.

1895 questions
152
votes
6 answers

How to present a simple alert message in java?

Coming from .NET i am so used calling Alert() in desktop apps. However in this java desktop app, I just want to alert a message saying "thank you for using java" I have to go through this much suffering: (using a JOptionPane) Is there an easier way?
Haoest
  • 13,610
  • 29
  • 89
  • 105
68
votes
2 answers

Multiple input in JOptionPane.showInputDialog

Is there a way to create multiple input in JOptionPane.showInputDialog instead of just one input?
siaooo
  • 1,827
  • 3
  • 23
  • 25
54
votes
7 answers

JOptionPane to get password

JOptionPane can be used to get string inputs from user, but in my case, I want to display a password field in showInputDialog. The way I need is the input given by the user should be masked and the return value must be in char[]. I need a dialog box…
Ahamed
  • 39,245
  • 13
  • 40
  • 68
45
votes
6 answers

Java - How to create a custom dialog box?

I have a button on a JFrame that when clicked I want a dialog box to popup with multiple text areas for user input. I have been looking all around to try to figure out how to do this but I keep on getting more confused. Can anyone help?
Corrie
33
votes
3 answers

Text wrap in JOptionPane?

I'm using following code to display error message in my swing application try { ... } catch (Exception exp) { JOptionPane.showMessageDialog(this, exp.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } The width of the error dialog goes…
laksys
  • 3,228
  • 4
  • 27
  • 38
29
votes
5 answers

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…
splintor
  • 9,924
  • 6
  • 74
  • 89
20
votes
2 answers

Convert timestamp to string

In java I need to display 'time of the program start' It must be in String. How do I get the current time, and then convert it to a String?
user3703289
  • 347
  • 1
  • 3
  • 9
20
votes
2 answers

Java: Custom Buttons in showInputDialog

How do you add custom text to the buttons of a JOptionPane.showInputDialog? I know about this question JOptionPane showInputDialog with custom buttons, but it doesn't answer the question asked, it just references them to JavaDocs, which doesn't…
ZuluDeltaNiner
  • 725
  • 2
  • 11
  • 27
18
votes
2 answers

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…
eleven81
  • 6,301
  • 11
  • 37
  • 48
18
votes
6 answers

how to show JOptionPane on the top of all windows

I have created a DialogUtil which shows numbers of JOptionPan in different situation. sometimes in my action class call to this method with null parameters as below. DialogUtil.showNotExist(null,xml.getName().concat(" is null or")); In this case…
itro
  • 7,006
  • 27
  • 78
  • 121
17
votes
4 answers

JOptionPane without button

I need to present a information message that needs to be in the screen for 5 seconds, during this time, user can't close the dialog. The specification says clearly that the dialog shouldn't have any button. Is there a way I can use…
brevleq
  • 2,081
  • 10
  • 53
  • 97
16
votes
3 answers

JOptionPane showConfirmDialog with only one button

I need to have only one button in showConfirmDialog. I tried this: int response = JOptionPane.showConfirmDialog(null, "Time Entered Successfully", "", JOptionPane.OK_OPTION, JOptionPane.PLAIN_MESSAGE); if (response ==…
Shashank Degloorkar
  • 3,151
  • 4
  • 32
  • 50
15
votes
8 answers

JOptionPane Yes or No window

I am trying to create a message with a Yes or No button. Then a window will appear with a certain message that depends on if the user clicked Yes or No. Here is my code: public class test{ public static void main(String[] args){ …
Josh King
  • 177
  • 2
  • 2
  • 7
15
votes
5 answers

Can I use a Java JOptionPane in a non-modal way?

I am working on an application which pops up a JOptionPane when a certain action happens. I was just wondering if it was possible that when the JOptionPane does pop up how can you still use the background applications. Currently when the JOptionPane…
yemyem
  • 155
  • 1
  • 1
  • 6
15
votes
2 answers

Java: Multiple lines of text using JOptionPane.showInputDialog(null, "Text");

I need a text pop up like the one you get with JOptionPane.showInputDialog(null, "Text"); Just with multiple lines, like... I'm new to java. I have no background in programming. I could use some help How would I do this?
jjd712
  • 151
  • 1
  • 1
  • 4
1
2 3
99 100