joptionpane

Java multiple selection dialog box

China☆狼群 提交于 2020-01-24 12:29:08
问题 I have a dialog box with a drop down menu like this: Object[] possibilities = {"1", "2", "3", "4"}; ImageIcon icon = new ImageIcon("images/middle.gif"); int i = Integer.parseInt((String)JOptionPane.showInputDialog(pane,"How Many Channels:","Reset Visible Channels", JOptionPane.PLAIN_MESSAGE,icon,possibilities,"1")); The problem is that it only lets you select one option. Instead, I would like for users to be able to select multiple options from a list that is given in the dialog box.

Is there a way to change JOptionPane.showMessageDialog font?

瘦欲@ 提交于 2020-01-15 06:34:05
问题 Is there a way to change the JOptionPane.showMessageDialog font? I'm trying to write code for a message dialog and I need to change the font if it's possible. 回答1: JOptionPane jopt = new JOptionPane(); String result; result = "your message"; JLabel resLabel = new JLabel(result); resLabel.setFont(new Font("Monospaced", Font.BOLD, 50)); jopt.showMessageDialog( null, resLabel, "Results", JOptionPane.PLAIN_MESSAGE ); Create a new label with your custom font and set the jlabel as a component in

How to allow JOptionPanes to show in a Windows Service

半腔热情 提交于 2020-01-14 05:48:05
问题 The program I created deletes all files in a folder then displays a JOptionPane. It runs fine as a jar file but not when I create a service out of it. When I run the service it deletes the files but does not display the JOptionPane. I've already tried the: "Allow service to interact with desktop" package testPackage; import java.io.File; import javax.swing.JDialog; import javax.swing.JOptionPane; public class TestPack{ private static void deleteAll(File del) { if (!(del.isDirectory())) { del

How do display multiple lines in JOptionPane?

孤街浪徒 提交于 2020-01-13 19:00:13
问题 How do I display all of this information here in just one dialog? Every time I run the file different dialog boxes appears, I really need them to appear in just one dialog box with all the information. JOptionPane.showMessageDialog(null,"Your Name:"+a1,"Output",JOptionPane.INFORMATION_MESSAGE ); JOptionPane.showMessageDialog(null,"Your age:"+age,"Output",JOptionPane.INFORMATION_MESSAGE ); JOptionPane.showMessageDialog(null,"Your Birth year:"+a3,"Output",JOptionPane.INFORMATION_MESSAGE );

confirmation before press YES to exit program in Java

社会主义新天地 提交于 2020-01-12 06:23:52
问题 private void windowClosing(java.awt.event.WindowEvent evt) { int confirmed = JOptionPane.showConfirmDialog(null, "Exit Program?","EXIT",JOptionPane.YES_NO_OPTION); if(confirmed == JOptionPane.YES_OPTION) { dispose(); } } I want to close program by pressing Close Window Button with confirmation...But when I choose "No" to back to my Jframe, it still helps me to exit the program??? 回答1: From what i understand you want something like this addWindowListener(new WindowAdapter() { public void

Java system.out.print to print JOptionPane.ShowMessageDialog

不羁岁月 提交于 2020-01-11 12:27:06
问题 How can I print system.out.print message into a JOptionPane.ShowMessageDialog I need it to run through the for loop and then outside the for loop I need it to display inside of a JOptionPane.ShowMessageDialog box. I am really crunched for time. I would greatly appreciate any help. Thank You! public static void main(String[] args) { //A. Enter the Number Of Loans to compare String numberOfLoansString = JOptionPane.showInputDialog("Enter the Number Of Loans to Compare"); //Convert

JButton stays pressed when focus stolen by JOptionPane

我的未来我决定 提交于 2020-01-11 02:50:07
问题 I am new to Swing and I have a situation. I am designing an application that renders the GUI components dynamically based on an xml file input(meta-data) . Now most of my JTextFields have InputVerifier set to them, for validation purpose. The input verifier pops up JOptionPane whenever there is an invalid input. Now, if a user enter an invalid data and moves ahead and clicks a button on the Panel, then a dialog pops up and the user have to respond to it. but after that also the button does

JOptionPane displaying HTML problems in Java

拟墨画扇 提交于 2020-01-09 08:06:09
问题 Okay, so I have this code, it prompts a month and a year from the user and prints the calendar for that month. I'm having some problems though. the HTML font editing only affects the month. the days of the week are not aligned in columns correctly. Thanks! package calendar_program; import javax.swing.JOptionPane; public class Calendar { public static void main(String[] args) { StringBuilder result=new StringBuilder(); // read input from user int year=getYear(); int month=getMonth(); String[]

JOptionPane displaying HTML problems in Java

一世执手 提交于 2020-01-09 08:05:26
问题 Okay, so I have this code, it prompts a month and a year from the user and prints the calendar for that month. I'm having some problems though. the HTML font editing only affects the month. the days of the week are not aligned in columns correctly. Thanks! package calendar_program; import javax.swing.JOptionPane; public class Calendar { public static void main(String[] args) { StringBuilder result=new StringBuilder(); // read input from user int year=getYear(); int month=getMonth(); String[]

Add actionlistener to a button in joptionPane (java)

拈花ヽ惹草 提交于 2020-01-07 03:04:52
问题 How can I add ActionListener to a JButton in JOptionPane . So that when I press on the button, it excutes a certain code. I tried to use this code, but it is not working: JButton button1= new JButton("Button 1"); int value = JOptionPane.showOptionDialog(null, "Here's a test message", "Test", JOptionPane.YES_OPTION , JOptionPane.QUESTION_MESSAGE, null,new Object[]{button1}, button1); button1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { //code to excute