joptionpane

How can I dismiss one JOptionPane upon emergence of another JOptionPane in the GUI

强颜欢笑 提交于 2020-01-01 10:42:11
问题 As you have seen from my subject above, I would like to know how can I dismiss a JOptionPane which became irrelevant because of another JOptionPane and because the user ,for some reason, didn't dismiss the first one by himself clicking ok button (for example). I've seen some ware in other site similar question, and people suggested to do simply: JOptionPane.getRootFrame().dispose(); But how can I store a reference for each JOptionPane I have and to be able to dismiss only that wanted one.

Stop code until a condition is met

亡梦爱人 提交于 2020-01-01 06:17:16
问题 How can you create a function or component etc that will stop all running code until a condition is met? For example the same way as a JOptionPane will do, if I have this for example: JOptionPane.showInputDialog(null, "Hello", "Title", 1); Within a function etc and then print to the console afterwards it it will not print until I close the JOptionPane. I am guessing this component has some sort of thread setup built in to do this but how could I duplicate that with my own functions? So say

Stop code until a condition is met

落花浮王杯 提交于 2020-01-01 06:17:02
问题 How can you create a function or component etc that will stop all running code until a condition is met? For example the same way as a JOptionPane will do, if I have this for example: JOptionPane.showInputDialog(null, "Hello", "Title", 1); Within a function etc and then print to the console afterwards it it will not print until I close the JOptionPane. I am guessing this component has some sort of thread setup built in to do this but how could I duplicate that with my own functions? So say

unable to close JOptionPane properly in chain order

落花浮王杯 提交于 2019-12-31 07:47:08
问题 I am displaying a JOptionPane suppose A on a button click from JFrame, and again displaying another JOptionPane suppose B on a button click from JOptionPane A, and I have a button on JOptionPane B suppoce button1, on the click event of button1, I am using code JOptionPane.getRootFrame().dispose() for closing the JOptionPane B , but it closes both A and B, please help me how can close only B but not A. here is my sample code i want second JOptionPane must be open import java.awt.Dimension;

JoptionPane multi select and srollable option

时光毁灭记忆、已成空白 提交于 2019-12-31 04:07:18
问题 I'm new to JoptionPane is there any method that i can have multi select and scrollable feature. Please find my code below. String bigList[] = new String[100]; for (int i = 0; i < bigList.length; i++) { bigList[i] = Integer.toString(i); } for scrolling i'm using JOptionPane.showInputDialog(new JFrame(), "Pick a printer", "Input", JOptionPane.QUESTION_MESSAGE,null, bigList, "Titan"); for multi select im using JList list = new JList(bigList); JOptionPane.showMessageDialog(null, list, "Select

Is there a way to Change the JOptionPane layout, like the color at the top and the image at the top left?

爷,独闯天下 提交于 2019-12-31 00:00:08
问题 I am curious, I am wondering if there exist a way to make the top of the JOptionPane into a different color, say red or orange. Also i was wondering how to change the image on the left of the JOptionPane. I am guessing it is not possible because it is already a method being used from java. But i am no expert. 回答1: There are three options here: Use one of the predefined icons using the respective message type: JOptionPane.showMessageDialog(frame, "Eggs are not supposed to be green.", "Inane

Is there a way to Change the JOptionPane layout, like the color at the top and the image at the top left?

强颜欢笑 提交于 2019-12-31 00:00:03
问题 I am curious, I am wondering if there exist a way to make the top of the JOptionPane into a different color, say red or orange. Also i was wondering how to change the image on the left of the JOptionPane. I am guessing it is not possible because it is already a method being used from java. But i am no expert. 回答1: There are three options here: Use one of the predefined icons using the respective message type: JOptionPane.showMessageDialog(frame, "Eggs are not supposed to be green.", "Inane

Add Image to JOptionPane

本小妞迷上赌 提交于 2019-12-29 08:51:26
问题 I'm wondering How To Add Image To MessageDialog Box. I tried the code below and the image was nowhere to be found else if(button == B){ String text = "blahblahblahblahblah"; JTextArea textArea = new JTextArea(text); textArea.setColumns(30); textArea.setLineWrap( true ); textArea.setWrapStyleWord( true ); textArea.setSize(textArea.getPreferredSize().width, 1); Font font = new Font("Verdana", Font.BOLD, 12); textArea.setFont(font); textArea.setForeground(Color.BLUE); JOptionPane

Making a JOptionPane with 4 options

 ̄綄美尐妖づ 提交于 2019-12-29 07:37:32
问题 I need to make a custom dialog with 4 options but as far as I can tell you can only have one with three options. Here is how I would make an option pane with 3 options: Frame refFrame = DialogUtils.getReferenceFrame(); ///TODO: /// - Use DialogUtils int option = JOptionPane.showOptionDialog(refFrame, msg, rsc.str("918"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, DialogUtils.INFO_ICON, options, options[0]); But I could not find some sort of open ended substitution for

JOptionPane Yes or No window

拈花ヽ惹草 提交于 2019-12-29 03:22:12
问题 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){ //default icon, custom title int n = JOptionPane.showConfirmDialog( null, "Would you like green eggs and ham?", "An Inane Question", JOptionPane.YES_NO_OPTION); if(true){ JOptionPane.showMessageDialog(null, "HELLO"); } else { JOptionPane.showMessageDialog(null,