joptionpane

Multiple JOptionPane input dialogs?

非 Y 不嫁゛ 提交于 2019-12-24 01:53:25
问题 I've been looking for the past hour, but I haven't been able to find the solution I am looking for. I'm wanting to take multiple inputs from the user using JOptionPane , but I don't want them to all be in one dialog window. I'm wanting it to transition to the next or just make the next one pop up. Is there a way to do that using JOptionPane ? Here's what I have so far: import java.util.Scanner; import javax.swing.*; public class HomeWork2 { public static void main(String[] args) { Scanner

Updating message in JOptionPane

泄露秘密 提交于 2019-12-23 19:39:51
问题 I am trying to make a digital clock which displays the time in a JOptionPane. I've managed to display the time on the message dialog box. However, I can't figure out how to make it update the time at every second in the dialog box. This is what I currently have: Date now = Calendar.getInstance().getTime(); DateFormat time = new SimpleDateFormat("hh:mm:ss a."); String s = time.format(now); JLabel label = new JLabel(s, JLabel.CENTER); label.setFont(new Font("DigifaceWide Regular", Font.PLAIN,

Setting Size of JPanel or JOptionPane

偶尔善良 提交于 2019-12-23 18:16:49
问题 So i want to somehow set the size of my JOptionPane - without setting it, it is just too large for my purposes and won't look nice. here is my code: JScrollPane scrollpane = new JScrollPane(); String categories[] = { "1. Problem One Problem One Problem One Problem One Problem One Problem One Problem One Problem One Problem One", "2. Problem Two", "3. Extended Family", "4. Extended Family", "5. Extended Family"}; JList list = new JList(categories); errorListCellRenderer cellRenderer = new

JOptionPane.showMessageDialog() shows but without any message?

邮差的信 提交于 2019-12-23 16:12:13
问题 In the following code, I call JOptionPane.showMessageDialog, inside a try/catch block. But when the error is caught, my JOptionPane is visible but without any message !!! Does someone knows why and how I can correct the problem ? Regards MyBoardJPannel.java package experimentations.gui; import java.awt.Graphics; import java.awt.Image; import java.io.InputStream; import javax.imageio.ImageIO; import javax.swing.JOptionPane; import javax.swing.JPanel; public class MyBoardPannel extends JPanel {

JOptionPane with a JTextArea instead of a text field?

岁酱吖の 提交于 2019-12-23 15:54:17
问题 I need to grab multiple lines of input from a popup JOptionPane (or some other popup, but most of my searches direct me there, which is where I get stuck..). I am stuck at using JOptionPane.showInputDialog(null, new JTextArea(20,20)); but I want just the 20x20 area to be read to a String and no text field shown. I figure there must be some way to do this, but the other types of dialog only seem to return an int... It doesn't have to be a JOptionPane, as long as it is a separate popup from my

JOptionPane Grey Out One Button

◇◆丶佛笑我妖孽 提交于 2019-12-23 11:59:42
问题 I need to use a JOptionPane to give the user two options. Depending on previous actions though one of the buttons may need to be disabled. Is it possible with JOptionPane to have the ability to set either of the buttons to be disabled or enabled? How can I do this? 回答1: It's easy if you use JButtons: public class Test { public static void main(String[] args) { final JButton option1 = new JButton("option1"); final JButton option2 = new JButton("option2"); option1.setEnabled(false); // option2

How can I give this password field focus?

旧巷老猫 提交于 2019-12-23 11:43:12
问题 This may seem trivial, but I can't figure out how to give the password box in this dialog focus. import javax.swing.JOptionPane; import javax.swing.JPasswordField; public class PasswordBox { @SuppressWarnings("unused") public String prompt() { JPasswordField pass = new JPasswordField(10); int action = JOptionPane.showConfirmDialog(null, pass,"Enter Password",JOptionPane.OK_CANCEL_OPTION); return new String(pass.getPassword()); } } I invoke it from other classes like this: String tmpPASS = new

Is there a way to set a layout for JOptionsPane.showOptionDialog?

喜你入骨 提交于 2019-12-23 02:42:16
问题 If the array you are using is, let's say a length of 15, and you want to display them all at once, it shows them side by side in a really long display box: String[] options = {"Option 1","Option 2","Option 3","Option 4", "Option 5","Option 6","Option 7","Option 8","Option 9", "Option 10","Option 11","Option 12","Option 13","Option 14", "Option 15"}; int displayoptions = JOptionPane.showOptionDialog (null, "select one", "Title", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null,

how to restrict Joptionpane message dialog box prompting once for the Condition?

梦想的初衷 提交于 2019-12-23 02:26:24
问题 This is my code below that have to be generated in GUI form(Using Swing awt) My code work is to read text files from a folder and get repeated words count and saving those selected files to a user specified folder. if(tmp.isSelected()) { String filepathNName = tf.getText() +"\\"+ tmp.getText(); //filepathNName = System.getProperty("path.separator"); String filename = tmp.getText(); System.out.println("filename = " + filename); System.out.println("filepaname = " + filepathNName); System.out

Java return from a ShowOptionDialog from an inner JPanel

白昼怎懂夜的黑 提交于 2019-12-22 10:48:54
问题 I used JOptionPane.showOptionDialog(null, new MyPanel(), "Import", JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, new Object[]{}, null); because I don't want the default buttons provided by the OptionDialog and I created my buttons inside the MyPanel extends JPanel So my problem is now how can I close that OptionDialog from inside the MyPanel fired by an ActionEvent ? I don't care the return value, as long as that dialog disappears. And I realize this might not be the best