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
0
votes
1 answer

Trouble with cancelling operation JOptionPane

I have a problem with my really long and messy code (If there is a better way then please tell me) but the real problem I have is I want my JOptionPane.showConfirmDialog() to cancel the rest of the operation after cancel is clicked, my class here is…
ItsRainingHP
  • 139
  • 1
  • 4
  • 18
0
votes
1 answer

java get radio button selection & joptionpane.ok_option

I'm building a tool to update a txt file. In the JOptionPane, I want the file to update IF the Radio button "Add Charm" is selected and the JOptionPane.Ok_Option button is clicked. The code compiles fine, but when the program is ran, no changes…
user3155369
  • 15
  • 2
  • 4
0
votes
1 answer

JFrame is not removed from the taskbar

This question is related to my previous question Showing JDialog on taskbar does not look good. I have modified my code so that the dialog is displayed correctly but now the problem is that the button does not disappear from the taskbar when the…
Peter
  • 213
  • 2
  • 5
  • 14
0
votes
1 answer

JOptionPane set default button to Enter key

This is my code for creating login dialog but I want to login automatically on Enter key press which is not getting done with this code. I have tried getRootPane().setDefaultButton(..); but I don't have JButton object. String _options = {"ok",…
eatSleepCode
  • 4,427
  • 7
  • 44
  • 93
0
votes
1 answer

Java JOptionPane Whole Program Loop

I am trying to get my whole program to loop again if the user presses yes but I am stuck on what I should be putting. I need it to loop infinitely until the user says no. Any help will be appreciated. public static void main(String[] args) { //…
Javier
  • 25
  • 1
  • 2
  • 8
0
votes
4 answers

Celsius is always 0.0?

I'm making a simple temperature conversion program in Java that converts Fahrenheit to Celsius. My program compiles just fine, but no matter what number I input, it always says that Celsius is 0.0! What could I be doing wrong? Here is my full…
SoloMael
  • 53
  • 2
  • 9
0
votes
2 answers

how to refer to strings from input dialog?

I need to prompt the user to enter their full name and once they do I need two separate messages to show them your first name is and your last name is. I have everything but what I need to code for the firstName and lastName string. I feel like it…
user3247712
  • 37
  • 2
  • 3
  • 8
0
votes
1 answer

I am making a game and I need my JOptionPane to close

int confirmDialog = JOptionPane.showConfirmDialog(null, "You selected quit! \nAre you sure you want to quit?", "Selected Quit", JOptionPane.YES_NO_OPTION); if(confirmDialog == 0) System.exit(0); //focus under this…
0
votes
2 answers

Show a message in a message window in Java

I want to show a message window displaying a string value, but I don't know how to write it. I have this code: for (BufferedImage bImage : lineImage1) { int trafficSection[] = analysis.colorShare(screenCapturing.getMapTrafficOnly(), bImage); …
user3186565
  • 9
  • 1
  • 3
0
votes
1 answer

check if a string inserted by user input corresponds to a particular format

i have this method that ask the user for an input(a Date) in a specific format -- DD/MM/YYYY and i managed to partially limit the user input by this way using this code date.matches("[0-9]+[0-9]/[0-9]+[0-9]/[0-9]+[0-9]+[0-9]+[0-9]")); but i still…
The BigBoss
  • 111
  • 2
  • 11
0
votes
1 answer

how to change default choice for JOptionPane.showOptionDialog to default_close_operation

i got this problem i used a JOptionPane in OptionDialog mode but i can't manage to set to default option that if i select the x in the upper right corner it closes itself; this is because in the declaration of the showOptionDialog it makes me…
The BigBoss
  • 111
  • 2
  • 11
0
votes
1 answer

How to convert this code to class and reuse it?

I have written this Enum to configure my program parameters... Well i want to translate as a class. Better if a SingletonClass. My big problem is that i don´t know how to set on the run time the parameters values... package GUI; public enum…
Tilens
  • 109
  • 7
0
votes
2 answers

JOptionpane + JDialog (non-modal) get the return value

I have a non-modal dialog with two input text fields shown with the JOptionPane with OK and CANCEL buttons. I show the dialog as below. JTextField field_1 = new JTextField("Field 1"); JTextField field_2 = new JTextField("Field 2"); …
AJJ
  • 3,570
  • 7
  • 43
  • 76
0
votes
1 answer

get JSlider's input and changes

I need to use JSlider with getting input live, meaning that it will return an input without pressing any button. I have this piece of code for the slider: JPanel panel = new JPanel(); JSlider js = new JSlider(JSlider.VERTICAL, 0, 20,…
TJR
  • 454
  • 8
  • 24
0
votes
1 answer

Adding a cancel button to my JOptionPane

My question is the inverse of this one: Is there a way to only have the OK button in a JOptionPane showInputDialog (and no CANCEL button)? One solution to that was (if I read correctly) to add an arbitrary JPanel, in that instance a label. My…
Lenoxus
  • 545
  • 1
  • 4
  • 19
1 2 3
99
100