joptionpane

JOptionPane opening another JFrame

So I'm continuing my fight with this : http://stackoverflow.com/questions/2923545/creating-java-dialogs/2926126 task. Now my JOptionPane opens new window with envelope overfiew, but I can't change size of this window. Also I wanted to have sender's data in upper left corner, and receiver's data in bottom right. How can I achieve that ? T...

How the JOptionPane works

How can I control what happens with window after clicking JOPtionPane buttons ? I'm trying to implement simple file chooser. In my frame I have 3 buttons (OK, Cancel, Browse). Browse button opens file search window, and after picking files should return to main frame. Clicking OK will open a frame with the content of the file. Now porble...

How to merge JOptionPane and Frame into one

Hello. Currently I have a very basic file viewer working as follows : - in JOptionPane I browse for files, and set some variables to display (colors, line connecting etc) - previous windows loads a frame with drawn points Code : http://paste.pocoo.org/show/220066/ Now I'd like to throw it into one window, with JMenu for selecting files...

How to close a JFrame in the middle of a program

public class JFrameWithPanel extends JFrame implements ActionListener, ItemListener { int packageIndex; double price; double[] prices = {49.99, 39.99, 34.99, 99.99}; DecimalFormat money = new DecimalFormat("$0.00"); JLabel priceLabel = new JLabel("Total Price: "+price); JButton button = new JButton("Check Price")...

How to select an index value from a String Array in a JOptionPane

I've created a JOptionPane as a selection method. I want the int value for selection 1,2 or 3 of the String Array so I can use it as a counter. How do I get the index of the array and set it equal to my int variable loanChoice? public class SelectLoanChoices { int loanChoice = 0; String[] choices = {"7 years at 5.35%", "15 years...

JOptionPane Input to int

Hello all, I am trying to make a JOptionPane get an input and assign it to an int but I am getting some problems with the variable types. I am trying something like this: Int ans = (Integer) JOptionPane.showInputDialog(frame, "Text", JOptionPane.INFORMATION_MESSAGE, null, null, ...

JOptionPane with two labels

I would like to create in Java a JOptionPane which should contain two different labels, Is it possible? If so, how to do it? ...

Java program exits when I click OK button in JOptionPane.showMessageDialog

Hi, when I click the OK button in second.java program, the program exit the program. I want it not to exit (since there is a thread running). I tried removing setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE). CODE import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swin...

How to make an input form in java code (NOT Netbeans using JForm) ?

Hi I want to make an input form so that the user can enter details in java code. Something like this : MY CODE import java.awt.GridLayout; import javax.swing.*; class JOptionPaneTest { public static void main(String[] args) { String[] items = {"One", "Two", "Three", "Four", "Five"}; JComboBox combo = new JComboBox(items)...

How to make a scrollable JList to add details got from a JOptionPane

Hi there, I want to repeatedly take input from the user(probably using a button) via a JOptionPane(already done) and store the details in something(how about a dynamic object array) and display this information as a list in a scrollable JList. MY CODE import java.awt.GridLayout; import javax.swing.*; class Flight { public stati...

How to validate if Text entered is a numeric number?

Hi there I have a calculation application which I need to validate the fields to check if the values entered are numeric numbers and not alphanumeric. I have some ideas about the codes: Please guide me if I have done anything wrong or seem noob as this is my first time trying out Swing. private void jTextField1ActionPerformed(java.aw...

User input validation for JOptionPane.showInputDialog

I'm just learning JAVA and having a bit of trouble with this particular part of my code. I searched several sites and have tried many different methods but can't seem to figure out how to implement one that works for the different possibilities. int playerChoice = Integer.parseInt(JOptionPane.showInputDialog(null, "Enter num...

JOptionPane dialog with editable text field and list

Is it possible to create a dialog where the user can select values from a list, but also can edit the text? (Something like a dialog with an editable JComboBox.) ...

Java - JOptionPane.InputDialog - What if user enters no input and clicks OK?

Well, I'm trying to create a way of detecting if the user inputs nothing and clicks 'OK.' For example, if the user clicks cancel, I break out of a while loop with the following code: if (words[i] == null) break; //breaks out of while loop I tried something along these lines for a user clicking OK: else if (Character.isDigit(words[i]...

Using custom icons in title with JOptionPane.showInputDialog

Hi, I'm trying to use a custome icon in the title of the JOption pane rather then with the label. Is there a way that I can do that? I'm using the Icon class (as shown below) in JOptionPane but it keeps displaying the icon in the main display area rather than in the title. Here is the code: Icon icon = new ImageIcon(ApplicationManager...

How to enlarge buttons on JOptionPane dialog boxes?

The line of code below displays a dialog box with two buttons: Yes and No. I want those two buttons to be at least 3 times the actual default size. I understand I can create a customized JFrame and add button and set the Size but I have scores of dialog boxes; does not seems practical. JOptionPane.showConfirmDialog(null, "Did you eat",...

How to create a dialogbox that will pop up after 5 minutes of idleness by the user? (java)

I have a dialog box that is: JOptionPane.showMessageDialog(null,"Once medicine is given, measure temperature within 5 minutes." ,"Medication" ,JOptionPane.PLAIN_MESSAGE); When the user presses 'ok', it goes straight to a Jframe that ask the user to input the temperature using a slider and then pressing a button that takes it to the n...

How to replace the image on JOptionPane dialog boxes on the title menu?

Instead of the default java logo, I want a different image on all my dialog boxes. The image is jpeg and already stored on my desktop. Is there a way to modify the title menu ? ...

How to tame the X on the JOptionPane Dialog boxes?

Also, right now whenever I click the 'X" button on top right, the dialog boxes behaves as if I clicked OK (on messages) or YES (on questions). When the user clicks the X, I want DO_Nothing. In the code below, when i click on the X on the dialog box, it pops out the 'eat!'. Apparently, the X is acting as 'YES' Option, which it should no...