List of usage examples for javax.swing JOptionPane ERROR_MESSAGE
int ERROR_MESSAGE
To view the source code for javax.swing JOptionPane ERROR_MESSAGE.
Click Source Link
From source file:MainClass.java
public static void main(String args[]) { final JFrame frame = new JFrame("Change Look"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { Object source = actionEvent.getSource(); String lafClassName = null; if (source instanceof JComboBox) { JComboBox comboBox = (JComboBox) source; lafClassName = (String) comboBox.getSelectedItem(); } else if (source instanceof JButton) { lafClassName = actionEvent.getActionCommand(); }//from www . ja v a 2 s . c o m if (lafClassName != null) { final String finalLafClassName = lafClassName; try { UIManager.setLookAndFeel(finalLafClassName); SwingUtilities.updateComponentTreeUI(frame); } catch (Exception exception) { JOptionPane.showMessageDialog(frame, "Can't change look and feel", "Invalid PLAF", JOptionPane.ERROR_MESSAGE); } } } }; UIManager.LookAndFeelInfo looks[] = UIManager.getInstalledLookAndFeels(); DefaultComboBoxModel model = new DefaultComboBoxModel(); JComboBox comboBox = new JComboBox(model); JPanel panel = new JPanel(); for (int i = 0, n = looks.length; i < n; i++) { JButton button = new JButton(looks[i].getName()); model.addElement(looks[i].getClassName()); button.setActionCommand(looks[i].getClassName()); button.addActionListener(actionListener); panel.add(button); } comboBox.addActionListener(actionListener); frame.add(comboBox, BorderLayout.NORTH); frame.add(panel, BorderLayout.SOUTH); frame.setSize(350, 150); frame.setVisible(true); }
From source file:licenceexecuter.LicenceExecuter.java
/** * @param args the command line arguments * @throws java.text.ParseException// ww w.ja v a 2s. c o m */ public static void main(String[] args) throws Throwable { LicenceExecuter licenceExecuter = new LicenceExecuter(); licenceExecuter.initProperties(); if (args != null && args.length >= 5) { System.out.println(Base64.encodeBase64String(args[4].getBytes())); System.out.println(licenceExecuter.properties.getProperty("generateKey")); if (Base64.encodeBase64String(args[4].getBytes()) .equals(licenceExecuter.properties.getProperty("generateKey"))) { System.out.println(ControllerKey.encrypt( new ObKeyExecuter().toObject(args[0] + "|" + args[1] + "|" + args[2] + "|" + args[3]))); } else { throw new IllegalArgumentException("InvalidPassword"); } return; } try { licenceExecuter.run(); } catch (Throwable ex) { ex.printStackTrace(); JOptionPane.showMessageDialog(null, "PROBLEMAS NA EXECUO", "ATENO", JOptionPane.ERROR_MESSAGE); } }
From source file:gov.loc.repository.bagger.app.BaggerApplication.java
public static void main(String[] args) { String rootContextDirectoryClassPath = "/gov/loc/repository/bagger/ctx"; String startupContextPath = rootContextDirectoryClassPath + "/common/richclient-startup-context.xml"; String richclientApplicationContextPath = rootContextDirectoryClassPath + "/common/richclient-application-context.xml"; try {/* w w w . j a v a2 s. c o m*/ new ApplicationLauncher(startupContextPath, new String[] { richclientApplicationContextPath }); } catch (IllegalStateException e) { log.error("IllegalStateException during startup", e); JOptionPane.showMessageDialog(null, "An illegal state error occured.\n", "Bagger startup error!", JOptionPane.ERROR_MESSAGE); System.exit(1); } catch (PropertyAccessException e) { log.error("PropertyAccessException during startup", e); JOptionPane.showMessageDialog(null, "An error occured loading properties.\n", "Bagger startup error!", JOptionPane.ERROR_MESSAGE); System.exit(1); } catch (RuntimeException e) { log.error("RuntimeException during startup", e); if (e.getMessage().contains("SAXParseException")) { JOptionPane.showMessageDialog(null, "An error occured parsing application context. You may have no internet access.\n", "Bagger startup error!", JOptionPane.ERROR_MESSAGE); } else { JOptionPane.showMessageDialog(null, "An error occured during startup.\n", "Bagger startup error!", JOptionPane.ERROR_MESSAGE); } System.exit(1); } }
From source file:gov.loc.repository.bagger.BaggerApplication.java
public static void main(String[] args) { String rootContextDirectoryClassPath = "/gov/loc/repository/bagger/ctx"; String startupContextPath = rootContextDirectoryClassPath + "/common/richclient-startup-context.xml"; String richclientApplicationContextPath = rootContextDirectoryClassPath + "/common/richclient-application-context.xml"; String businessLayerContextPath = rootContextDirectoryClassPath + "/common/business-layer-context.xml"; try {// w ww .java2 s.com new ApplicationLauncher(startupContextPath, new String[] { richclientApplicationContextPath, businessLayerContextPath }); } catch (IllegalStateException ex1) { LogFactory.getLog(BaggerApplication.class).error("IllegalStateException during startup", ex1); JOptionPane.showMessageDialog(new JFrame(), "An illegal state error occured.\n", "Bagger startup error!", JOptionPane.ERROR_MESSAGE); System.exit(1); } catch (PropertyAccessException ex) { LogFactory.getLog(BaggerApplication.class).error("PropertyAccessException during startup", ex); JOptionPane.showMessageDialog(new JFrame(), "An error occured loading properties.\n", "Bagger startup error!", JOptionPane.ERROR_MESSAGE); System.exit(1); } catch (RuntimeException e) { LogFactory.getLog(BaggerApplication.class).error("RuntimeException during startup", e); String msg = e.getMessage(); if (msg.contains("SAXParseException")) { JOptionPane.showMessageDialog(new JFrame(), "An error occured parsing application context. You may have no internet access.\n", "Bagger startup error!", JOptionPane.ERROR_MESSAGE); } else { JOptionPane.showMessageDialog(new JFrame(), "An error occured during startup.\n", "Bagger startup error!", JOptionPane.ERROR_MESSAGE); } System.exit(1); } }
From source file:cool.pandora.modeller.ModellerApplication.java
public static void main(final String[] args) { final String rootContextDirectoryClassPath = "cool/pandora/modeller/ctx"; final String startupContextPath = rootContextDirectoryClassPath + "/common/richclient-startup-context.xml"; final String richclientApplicationContextPath = rootContextDirectoryClassPath + "/common/richclient-application-context.xml"; final String businessLayerContextPath = rootContextDirectoryClassPath + "/common/business-layer-context.xml"; try {// w ww .jav a 2s. com new ApplicationLauncher(startupContextPath, new String[] { richclientApplicationContextPath, businessLayerContextPath }); } catch (final IllegalStateException ex1) { log.error("IllegalStateException during startup", ex1); JOptionPane.showMessageDialog(new JFrame(), "An illegal state error occured.\n", "Bagger startup error!", JOptionPane.ERROR_MESSAGE); System.exit(1); } catch (final PropertyAccessException ex) { log.error("PropertyAccessException during startup", ex); JOptionPane.showMessageDialog(new JFrame(), "An error occured loading properties.\n", "Bagger startup " + "error!", JOptionPane.ERROR_MESSAGE); System.exit(1); } catch (final RuntimeException e) { log.error("RuntimeException during startup", e); final String msg = e.getMessage(); if (msg.contains("SAXParseException")) { JOptionPane.showMessageDialog(new JFrame(), "An error occured parsing application context. You may " + "have no " + "internet access.\n", "Bagger startup error!", JOptionPane.ERROR_MESSAGE); } else { JOptionPane.showMessageDialog(new JFrame(), "An error occured during startup.\n", "Bagger startup " + "error!", JOptionPane.ERROR_MESSAGE); } System.exit(1); } }
From source file:com.sec.ose.osi.UIMain.java
public static void main(String[] args) { log.debug("Start GUI Application : " + Version.getApplicationVersionInfo()); // check java version final double MINIMUM_VERSION = 1.6; // SwingWorker is since 1.6 log.debug("Checking Java version."); double cur_version = getJavaVersion(); Properties prop = System.getProperties(); String msg = "You need the latest JVM version to execute " + Version.getApplicationVersionInfo() + "\nYou can download JVM(JRE or JDK) at http://java.sun.com" + "\n -Minimun JVM to execute: Java " + MINIMUM_VERSION + "\n -Current version: Java " + prop.getProperty("java.version") + "\n -Local java home directory: " + prop.getProperty("java.home"); if (cur_version < MINIMUM_VERSION) { JOptionPane.showMessageDialog(null, msg, "Incompatible JVM", JOptionPane.ERROR_MESSAGE); log.debug(msg);// w w w . j a va 2 s.c o m System.exit(0); } // App Initialize BackgroundJobManager.getInstance().startBeforeLoginTaskThread(); log.debug("Loading \"Login Frame\""); // login JFrame frmLogin = new JFrmLogin(); UISharedData.getInstance().setCurrentFrame(frmLogin); frmLogin.setVisible(true); // check for only one OSI if (isRunning()) { JOptionPane.showMessageDialog(null, "OSI already has started. The program will be closed.", "Error", JOptionPane.ERROR_MESSAGE); System.exit(-1); } // tray icon create new JTrayIconApp("OSIT", frmLogin); }
From source file:edu.cmu.cs.diamond.pathfind.main.PathFindDjango.java
public static void main(String[] args) { if (args.length != 4 && args.length != 5) { System.out.println("usage: " + PathFindDjango.class.getName() + " predicate_dir interface_map slide_map annotation_uri"); return;/*w w w . java2 s. c o m*/ } final String predicateDir = args[0]; final String interfaceMap = args[1]; final String slideMap = args[2]; final String annotationUri = args[3]; final File slide; if (args.length == 5) { slide = new File(args[4]); } else { slide = null; } final AnnotationStore annotationStore = new DjangoAnnotationStore(new HttpClient(), annotationUri); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { try { new PathFindFrame(predicateDir, annotationStore, interfaceMap, slideMap, slide, false); } catch (IOException e) { e.printStackTrace(); JOptionPane.showMessageDialog(null, e, "Error", JOptionPane.ERROR_MESSAGE); } } }); }
From source file:JTextFieldSample.java
public static void main(String args[]) { String title = (args.length == 0 ? "TextField Listener Example" : args[0]); JFrame frame = new JFrame(title); Container content = frame.getContentPane(); JPanel namePanel = new JPanel(new BorderLayout()); JLabel nameLabel = new JLabel("Name: "); nameLabel.setDisplayedMnemonic(KeyEvent.VK_N); JTextField nameTextField = new JTextField(); nameLabel.setLabelFor(nameTextField); namePanel.add(nameLabel, BorderLayout.WEST); namePanel.add(nameTextField, BorderLayout.CENTER); content.add(namePanel, BorderLayout.NORTH); JPanel cityPanel = new JPanel(new BorderLayout()); JLabel cityLabel = new JLabel("City: "); cityLabel.setDisplayedMnemonic(KeyEvent.VK_C); JTextField cityTextField = new JTextField(); cityLabel.setLabelFor(cityTextField); cityPanel.add(cityLabel, BorderLayout.WEST); cityPanel.add(cityTextField, BorderLayout.CENTER); content.add(cityPanel, BorderLayout.SOUTH); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { System.out.println("Command: " + actionEvent.getActionCommand()); }/* ww w . ja v a 2 s. c o m*/ }; nameTextField.setActionCommand("Yo"); nameTextField.addActionListener(actionListener); cityTextField.addActionListener(actionListener); KeyListener keyListener = new KeyListener() { public void keyPressed(KeyEvent keyEvent) { printIt("Pressed", keyEvent); } public void keyReleased(KeyEvent keyEvent) { printIt("Released", keyEvent); } public void keyTyped(KeyEvent keyEvent) { printIt("Typed", keyEvent); } private void printIt(String title, KeyEvent keyEvent) { int keyCode = keyEvent.getKeyCode(); String keyText = KeyEvent.getKeyText(keyCode); System.out.println(title + " : " + keyText + " / " + keyEvent.getKeyChar()); } }; nameTextField.addKeyListener(keyListener); cityTextField.addKeyListener(keyListener); InputVerifier verifier = new InputVerifier() { public boolean verify(JComponent input) { final JTextComponent source = (JTextComponent) input; String text = source.getText(); if ((text.length() != 0) && !(text.equals("Exit"))) { Runnable runnable = new Runnable() { public void run() { JOptionPane.showMessageDialog(source, "Can't leave.", "Error Dialog", JOptionPane.ERROR_MESSAGE); } }; SwingUtilities.invokeLater(runnable); return false; } else { return true; } } }; nameTextField.setInputVerifier(verifier); cityTextField.setInputVerifier(verifier); DocumentListener documentListener = new DocumentListener() { public void changedUpdate(DocumentEvent documentEvent) { printIt(documentEvent); } public void insertUpdate(DocumentEvent documentEvent) { printIt(documentEvent); } public void removeUpdate(DocumentEvent documentEvent) { printIt(documentEvent); } private void printIt(DocumentEvent documentEvent) { DocumentEvent.EventType type = documentEvent.getType(); String typeString = null; if (type.equals(DocumentEvent.EventType.CHANGE)) { typeString = "Change"; } else if (type.equals(DocumentEvent.EventType.INSERT)) { typeString = "Insert"; } else if (type.equals(DocumentEvent.EventType.REMOVE)) { typeString = "Remove"; } System.out.print("Type : " + typeString + " / "); Document source = documentEvent.getDocument(); int length = source.getLength(); try { System.out.println("Contents: " + source.getText(0, length)); } catch (BadLocationException badLocationException) { System.out.println("Contents: Unknown"); } } }; nameTextField.getDocument().addDocumentListener(documentListener); cityTextField.getDocument().addDocumentListener(documentListener); frame.setSize(250, 150); frame.setVisible(true); }
From source file:ch.tatool.app.App.java
/** * Main method. Loads the application through an application context. * Requires two arguments: module ID (integer) and code (String). These are used to * set which module will be loaded. /* w w w . j a v a 2s.co m*/ * * The main class App itself then performs the final initialization by loading the * module and displaying the GUI. */ public static void main(String[] args) { // TODO localize error messages if (args.length < 2) { JOptionPane.showMessageDialog(null, "Please provide module ID number and code.", "Error: missing module data", JOptionPane.ERROR_MESSAGE); return; } // load the application ApplicationContext ctx = new ClassPathXmlApplicationContext("/tatool/application-context.xml"); // Set the module that should be loaded GuiController controller = (GuiController) ctx.getBean("GuiController"); try { controller.setModuleID(Integer.parseInt(args[0])); controller.setCode(args[1]); } catch (NumberFormatException e) { JOptionPane.showMessageDialog(null, args[0] + " is not a valid module ID number.", "Error: invalid module ID", JOptionPane.ERROR_MESSAGE); return; } }
From source file:ListProperties.java
public static void main(String args[]) { final JFrame frame = new JFrame("List Properties"); final CustomTableModel model = new CustomTableModel(); model.uiDefaultsUpdate(UIManager.getDefaults()); TableSorter sorter = new TableSorter(model); JTable table = new JTable(sorter); TableHeaderSorter.install(sorter, table); table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); UIManager.LookAndFeelInfo looks[] = UIManager.getInstalledLookAndFeels(); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { final String lafClassName = actionEvent.getActionCommand(); Runnable runnable = new Runnable() { public void run() { try { UIManager.setLookAndFeel(lafClassName); SwingUtilities.updateComponentTreeUI(frame); // Added model.uiDefaultsUpdate(UIManager.getDefaults()); } catch (Exception exception) { JOptionPane.showMessageDialog(frame, "Can't change look and feel", "Invalid PLAF", JOptionPane.ERROR_MESSAGE); }/*from ww w . j av a2 s .c om*/ } }; SwingUtilities.invokeLater(runnable); } }; JToolBar toolbar = new JToolBar(); for (int i = 0, n = looks.length; i < n; i++) { JButton button = new JButton(looks[i].getName()); button.setActionCommand(looks[i].getClassName()); button.addActionListener(actionListener); toolbar.add(button); } Container content = frame.getContentPane(); content.add(toolbar, BorderLayout.NORTH); JScrollPane scrollPane = new JScrollPane(table); content.add(scrollPane, BorderLayout.CENTER); frame.setSize(400, 400); frame.setVisible(true); }