joptionpane

JOptionPane bigger

微笑、不失礼 提交于 2021-02-08 10:10:59
问题 I am working on a Tic Tac Toe game on Java (eclipse). On my computer my dialog box is really small. I been trying to make it bigger. I didn't have any luck. I was hoping someone here can lead me in the right direction. The code below is my dialog box code: JOptionPane.showMessageDialog(frame, "Tic Tac Toe Server is Running"); Thank you in Advance 回答1: As mentioned here, you can do this: UIManager.put("OptionPane.minimumSize",new Dimension(500,500)); JOptionPane.showMessageDialog(frame, "Tic

JOptionPane bigger

流过昼夜 提交于 2021-02-08 10:09:44
问题 I am working on a Tic Tac Toe game on Java (eclipse). On my computer my dialog box is really small. I been trying to make it bigger. I didn't have any luck. I was hoping someone here can lead me in the right direction. The code below is my dialog box code: JOptionPane.showMessageDialog(frame, "Tic Tac Toe Server is Running"); Thank you in Advance 回答1: As mentioned here, you can do this: UIManager.put("OptionPane.minimumSize",new Dimension(500,500)); JOptionPane.showMessageDialog(frame, "Tic

Initializing a variable in an if-statement in java?

巧了我就是萌 提交于 2020-05-16 20:59:26
问题 I keep getting an error variable F3 may have not been intialized on the last line of code you see. What am I doing wrong? { Float F1,F2, F3; F1 = Float.parseFloat( JOptionPane.showInputDialog("Enter a number and press ok.")); F2 = Float.parseFloat( JOptionPane.showInputDialog("Enter a second number and press ok.")); if(F1 >= F2) { F3=(F1 * F2) + (F1 * 2); } if(F2 >= F1) { F3 =(F1 + F2) + (F2 * 5); } DecimalFormat dec = new DecimalFormat("##.##"); JOptionPane.showMessageDialog(null,"Your

Initializing a variable in an if-statement in java?

空扰寡人 提交于 2020-05-16 20:59:24
问题 I keep getting an error variable F3 may have not been intialized on the last line of code you see. What am I doing wrong? { Float F1,F2, F3; F1 = Float.parseFloat( JOptionPane.showInputDialog("Enter a number and press ok.")); F2 = Float.parseFloat( JOptionPane.showInputDialog("Enter a second number and press ok.")); if(F1 >= F2) { F3=(F1 * F2) + (F1 * 2); } if(F2 >= F1) { F3 =(F1 + F2) + (F2 * 5); } DecimalFormat dec = new DecimalFormat("##.##"); JOptionPane.showMessageDialog(null,"Your

Initializing a variable in an if-statement in java?

帅比萌擦擦* 提交于 2020-05-16 20:59:07
问题 I keep getting an error variable F3 may have not been intialized on the last line of code you see. What am I doing wrong? { Float F1,F2, F3; F1 = Float.parseFloat( JOptionPane.showInputDialog("Enter a number and press ok.")); F2 = Float.parseFloat( JOptionPane.showInputDialog("Enter a second number and press ok.")); if(F1 >= F2) { F3=(F1 * F2) + (F1 * 2); } if(F2 >= F1) { F3 =(F1 + F2) + (F2 * 5); } DecimalFormat dec = new DecimalFormat("##.##"); JOptionPane.showMessageDialog(null,"Your

JOptionPane with arranged multiple inputs

萝らか妹 提交于 2020-02-16 06:29:42
问题 I am currently working on a GUI and I want to display a pop up window identical to the one shown below using JOptionPane. I am currently able to display the JTextField and JLabel but not in the same specific location as the one shown in the picture. In addition, I am not able to store the user input into variables. Can someone please provided me with hints or some examples of code so I can continue on the right path? This is what I am doing: GridBagConstraints layoutConst = null; // GUI

How to assign a sepecifc action to the (“Cancel”) button within (JOptionPane.showInputDialog) in Java?

≡放荡痞女 提交于 2020-02-05 06:02:07
问题 Here is my question with a short sample code: double num = 0.00; try { num = Double.parseDouble(JOptionPane.showInputDialog("Enter your num:")); } catch (Exception e) { System.err.println("Error: Invalid Input!"); JOptionPane.showMessageDialog(null, "Error: Invalid Input!", "Error", JOptionPane.ERROR_MESSAGE); } //Validate the num if (num > 0.0 && num <= 1000.00) { functionA(); } else if (deposit <= 0.0 || deposit > 1000.00) { System.err.println("Error: out of range"); } *The Problem with the

JOptionPane Input to int

戏子无情 提交于 2020-01-29 04:55:07
问题 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, "[sample text to help input]"); But I am getting: Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer Which sounds logical yet, I cannot think of another way to make this

Set DocumentFilter on JOptionPane

為{幸葍}努か 提交于 2020-01-24 13:05:07
问题 I'm using: String s = JOptionPane.showInputDialog(...); to get a response back from the user to a question; the dialog is set up to display a text field for the response. I'd like to limit the characters allowed in the response to alphanumeric and '_' only. Is it possible to install a DocumentFilter on the text field without implementing my own custom dialog from scratch? 回答1: Access the autocreated text field of JOptionPane is theoretically possible, but it's IMHO wrong way. Here is the