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
Filter by
Sorted by
Tagged with
0 votes
1 answer
99 views

How to login in Java

My program checks and makes sure that the password that you types in is correct. If the password is correct, then you go on to the next window. If it does not match the password, then it is supposed ...
c.torres's user avatar
0 votes
0 answers
67 views

How to focus the cursor on a JTextField upon starting the program?

I'm wondering if anyone could steer me in the right direction? I am looking to focus the cursor on the JTextField opt upon starting the program? Any help is greatly appreciated, I have been stuck on ...
user2988501's user avatar
0 votes
6 answers
123 views

Comparing Strings in Java .equals()

I'm trying to filter the user's input to make sure its a max of 4 digits and it's not an empty string. Whether I leave it blank or I enter a number, !strInput.equals(null) still comes up true. Am I ...
Oscar F's user avatar
  • 323
1 vote
1 answer
113 views

Simple message box homework gives me color wheel

We did this JavaFX practice problem in class and it keeps giving me a color wheel when I click the "hit me" button. I've looked through the code and even had my professor do so, and I can't see any ...
aufty's user avatar
  • 417
0 votes
2 answers
835 views

Java Code Returns 0 for Triangle Area

I'm in an intro to Java course and my assignment is to write a program that takes in 3 sides of a triangle and returns the type as well as the area. The sides have to be integers according to the ...
hunsbct's user avatar
  • 31
0 votes
2 answers
1k views

Change input dialog locale to hebrew in java

My application is in Hebrew. The computers that are running my app all have English set as the default language and Hebrew as the secondary language Every time they need to input stuff to the app, ...
David Gidony's user avatar
  • 1,253
4 votes
2 answers
10k views

Drawing a circle based from user input in Java

I have tried over and over to find a solution to this problem, but I seem to can't understand how to solve it. I'm trying to write a simple program to draw a circle with these specifications in the ...
user3768057's user avatar
0 votes
1 answer
117 views

If statements not running [closed]

The strings were parsed to integers, so the condition of the if statements are properly right set. Why are the if statements not running? Why there doesn't appear a MessageDialog with a response? ...
Insanovation's user avatar
1 vote
1 answer
3k views

Alternative to JOptionPane?

It works, but I need an alternative to the JOptionPane. This is a homework assignment and we are not allowed to use JOptionPane. Here is what I have, which works, it just isn't what the instructor ...
Justin's user avatar
  • 11
0 votes
1 answer
196 views

JoptionPane Gettting Yes Option even I Press Enter On No [closed]

I am Working with Swing Application. and in one of my application when i put some code on the windowclosing event. try { int dialog = JOptionPane.showConfirmDialog( null, "are you ...
Kishan Bhimajiyani's user avatar
1 vote
1 answer
627 views

Printing StringBuffer JOptionPane

I'd like to start by saying thank you to the stackoverflow community and all the great people who answer these questions. Much more often than not, I find my answer by reading and not typing, however ...
Zero_NotCool's user avatar
0 votes
1 answer
131 views

Find out Ok in JOptionPane InputDialog

This is my input dialog: But my code can't recognize selected buttons correctly: (No message appear on console at all) public static void main(String[] args) { int userId = Integer.parseInt(...
user avatar
0 votes
3 answers
1k views

JOptionPane Array Elements

I have been trying to work this out for the passed couple of days while trying to learn java. I have been teaching myself how to use option panes to display messages and I have recently tried to make ...
Callum Robertson's user avatar
0 votes
1 answer
924 views

JOptionPane.showMessageDialog keeps reappearing

My code is supposed to ensure that users only enter a binary string. Everything goes right and in order if I enter a correct binary number (1, 0). But when I enter a wrong number (alphabet or number ...
Hassan Zia's user avatar
1 vote
2 answers
8k views

How to show multiple messages within a single joptionpane message box?

I am new to these forums so I apologize in advance for any confusion/mistakes I might make. I am trying to make a single message box with JOptionPane, and I want it to display many things such as: ...
cooldudsk's user avatar
-3 votes
1 answer
77 views

JAVA: Running method without running the next line until the method end

int x = Integer.parseInt(JOptionPane.showInputDialog("INPUT 1 FOR GAME, ANY FOR EXIT")); while(x == 1){ new PokelanzBattle(); x = Integer.parseInt(JOptionPane.showInputDialog("INPUT 1 FOR GAME,...
lazygeniusLANZ's user avatar
-2 votes
1 answer
60 views

Message display on top of other apps

Please help me in showing popup in front of browser. I have used following code, but it's coming behind browser once I clicked a save button. JFrame frame; frame = new JFrame(""); JOptionPane....
user2563648's user avatar
0 votes
1 answer
80 views

JOptionPane input validation not working

Having some issues getting this input validation to work. What am I doing wrong? When you select OK in the JOptionPane it still assigns the values and does not show the error dialog box. public ...
user3126322's user avatar
0 votes
0 answers
3k views

Importing javax.swing.JOptionPane

At the moment I'm following a book, and the current chapter gives you a brief look at GUIs. import javax.swing.*; import java.awt.event.*; import java.awt.*; /** The MetricConverterWindow class ...
DanceRandyDance's user avatar
2 votes
3 answers
315 views

How do I make the generated numbers show at once?

import java.util.*; import javax.swing.JOptionPane; public class p1 { public static void main(String[] args) { int size = 50; ArrayList<Integer> list = new ArrayList<Integer>(...
user3425947's user avatar
1 vote
1 answer
145 views

Java (eclipse): Any way to System.out.println this String from a JOptionPane .showInputDialog?

Code's here: import javax.swing.JOptionPane; public class Comienzo { public static void main() { String nombrepersonaje = JOptionPane .showInputDialog("Introduce el ...
Cristobal Ruiz's user avatar
0 votes
1 answer
2k views

How to get the default Frame to use as parent component?

As in a JOptionPane I want to set a parent Component when sending a null value as the component parent. parentComponent: Defines the Component that is to be the parent of this dialog box. It is ...
Jonathan Solorzano's user avatar
0 votes
1 answer
58 views

can you change all this thing (JCheckBox) go to array and loop?

I am doing some GUI and I use JCheckBox. I am wondering if this all can be do in an array and loop? It's so tiring to change every single thing. If you can help me I'd love to hear. if (box1....
Lukman Al Hakim's user avatar
-2 votes
2 answers
1k views

JOptionPane action on cancel button

The code I'm trying to compile: import javax.swing.JOptionPane; public class Comienzo { public static void main() { String nombrepersonaje = JOptionPane.showInputDialog("Introduce ...
Cristobal Ruiz's user avatar
2 votes
2 answers
3k views

Data validation with JOptionPane

I want to perform data validation while JOptionPane.I found the following approach but i am not really satisfied with it import javax.swing.*; import java.util.regex.*; public class ...
user2650277's user avatar
  • 6,541
0 votes
2 answers
2k views

How do I make dialog windows in java?

I found a webpage on the java site on how to make dialog windows, but it isn't working when I try it. The site said to type: JOptionPane.showMessageDialog(frame, "Window text."); I'm just trying to ...
public static void's user avatar
0 votes
1 answer
96 views

How to launch a pop up when a user clicks close on a Java Swing application [duplicate]

I have a JFrame that currently has setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Is it possible for me to change this so that when the user clicks close I launch an "Are you sure?" JOptionPane ...
Eduardo's user avatar
  • 7,029
-1 votes
2 answers
5k views

java.util.Scanner; vs JOptionPane; [closed]

Please I would like know How would I implement JOptionPane instead of import java.util.Scanner; I also have 4 separate classes If i implement JOptionPane will it clean up the code I would also like to ...
idk's user avatar
  • 13
0 votes
1 answer
1k views

How to clear an image from memory when repeating an operation in Java?

I'm struggling with a new program. The program is designed to obtain a spectrum from a webcam and compare it with a reference spectrum. This is done when the use clicks a button called 'captureButton'...
Guy Stimpson's user avatar
0 votes
2 answers
85 views

How do I make a program that takes a string but disallows numbers?

I'm developing a game and it asks for a username at the start which will then be added to a txt file and saved. But the problem is that the user can write absolutely anything. Their usernames are ...
William's user avatar
  • 51
1 vote
2 answers
15k views

How to position JOptionPane.showMessageDialog at the center of screen? [duplicate]

Currently,the dialog box pops up just below the clicked Jbutton component.
user3529351's user avatar
0 votes
1 answer
5k views

How to get the value of option selected from JOptionPane.showMessageDialog?

I am making a java game. This is a piece of my code in which I have a question. How to get the value (no matter index value or string value) of option selected? I have to use it later in my code, for ...
user3529351's user avatar
3 votes
1 answer
10k views

java joptionpane which automatically closes after few seconds [duplicate]

Help needed for making a popup which automatically closes after a few seconds. JOptionpane messages usually needs an input to close, so is there any other way to handle auto-closing popup in java. ...
sneha nambiar's user avatar
0 votes
2 answers
660 views

Manual Mouse drag Resizing of JOptionPanel containing a JScrollPane

I have a JScrollPane that has a filedrop feature to allow the dragging of files. I have the JScrollPane being called with a JOptionPanel.showConfirmDialog so there are ok and cancel buttons. I want ...
Evilsithgirl's user avatar
1 vote
4 answers
594 views

JOptionPane Can Not DIsplay Everything

Hello SO Community I have recently changed my program from a Scanner input and display to a JOptionPane input and display, It is set up to display the investment over a course of user specified years ...
Minotaur's user avatar
4 votes
3 answers
24k views

JOptionPane handling ok, cancel and x button

There is one problem I am facing with my JOptionPane if I don't key in anything,no matter what I press(the ok,cancel or the x button(the top right button in the JOptionPane)), it will prompt me until ...
user3879568's user avatar
0 votes
1 answer
2k views

Java: Can't connect to X11 window server using 'localhost:1.0' as the value of the DISPLAY variable

I have created a web application which makes use of JOptionPane to display some dialogs to the users such as 'Record not found etc'. I did this development in Windows and everything was working fine. ...
vaibhav misra's user avatar
0 votes
0 answers
154 views

Java swing JoptionPane

i want to create a little game with java swing and i'm trying find how to create something like a joptionpane (to put it inside action listener) but a bit more complex. So till now when the user ...
captain monk's user avatar
-1 votes
1 answer
355 views

Switch from one "Input dialog box" to another "input dialog box"?

well hope you all are well.. I'm making a simple Phone book diary, so the problem is When i click new, it must open a dialog box JOptionPane, and yes it opens successfully, but after click ok i ...
Rajendra Arora's user avatar
2 votes
2 answers
254 views

Java: JFrame on exit actions closes anyway even if "No" is clicked

Do you know why my JFrame closes anbyway even if I click the "No" Button? This is my code: jframe.addWindowListener(new java.awt.event.WindowAdapter() { @Override public void ...
SagittariusA's user avatar
  • 5,389
1 vote
1 answer
894 views

How to add multiple if loop results to a single JOptionPane message dialog?

I'm super new to all of this but I'm trying to figure out how to get all the following results (which are now shown in separate message dialogs following each other) into a single message dialog ...
frequent_sleeper's user avatar
4 votes
1 answer
2k views

JOptionPane not displaying correctly?

Today I updated my jdk and docs from 7 to 8. I made a few changes to my program, and now when I try to have the program use JOptionPane, JLabel, ..., everything messes up. I made a separate tester ...
user2154420's user avatar
0 votes
1 answer
34 views

How to insert one line in Applet?

I would like to insert one line between "total charges"and "Thank you..." Here is the code I have made so far: JOptionPane.showMessageDialog(null, "Total Charges : RM" + dollar.format(totalCharges) +...
Ralph's user avatar
  • 67
0 votes
0 answers
154 views

Button clicked to activate JOptionPane.showOptionDialog stays clicked after close

I feel like I have done the heavy lifting, and now I am stuck on what should be the easy part, closing my pane. Cans somebody please tell me what I'm doing wrong? I think these are the applicable bits,...
Jedi Grunge's user avatar
-4 votes
2 answers
156 views

doClick inside JOptionPane

I am a beginner to java, and I need some help. This is my code. import java.util.*; import javax.swing.*; import java.awt.*; public class SWG1 { public static void main(String[] args) { ...
user3829961's user avatar
0 votes
1 answer
265 views

Put a doClick inside a JOptionPane

I am a beginner to java and I have some trouble on making the doClick buttons. I don't understand how it works and I need it in my code. JButton easyb = new JButton("Easy"); JButton ...
user avatar
0 votes
1 answer
1k views

Open a JOptionPane by another JOptionPane

I am using a JOptionPane to get a string. By klicking "OK" the string is saved. Now i want the second JOptionPane to pop-up to enter the second necassary string. Is there any opportunity to add an ...
Yannic Hansen's user avatar
1 vote
0 answers
2k views

JPanel for user input should show on top of all other windows

I am new to java swing and have a question, but first let me explain what my app does: on first start my java web start application asks the user for username and password and stores them with java ...
Pali's user avatar
  • 1,337
1 vote
1 answer
689 views

How do I use JOptionPane.showInputDialog with a class I created?

I'm new to Java, so sorry for the dumb question. I created a class called Age to be a part of a Retirement Planning program. In the main method of the program, how do I use JOptionPane to ask and set ...
user3708356's user avatar
0 votes
3 answers
2k views

Confirmation in JOptionPane, can I loop back to scanner?

I'm a newbie, so forgive me if I a bit slow. If I have a confirmation dialog in JOptionPane, can loop back to scanner if user states YES? EX: in JOptionPane, if user answers YES, then I want it to ...
user3743409's user avatar

1
19 20
21
22 23
38