Example usage for javax.swing SwingUtilities invokeLater

List of usage examples for javax.swing SwingUtilities invokeLater

Introduction

In this page you can find the example usage for javax.swing SwingUtilities invokeLater.

Prototype

public static void invokeLater(Runnable doRun) 

Source Link

Document

Causes doRun.run() to be executed asynchronously on the AWT event dispatching thread.

Usage

From source file:components.LabelDemo.java

public static void main(String[] args) {
    //Schedule a job for the event dispatch thread:
    //creating and showing this application's GUI.
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            //Turn off metal's use of bold fonts
            UIManager.put("swing.boldMetal", Boolean.FALSE);

            createAndShowGUI();//w  w w . j  a v  a 2s  . com
        }
    });
}

From source file:gtu._work.ui.PropertyEditUI.java

/**
 * Auto-generated main method to display this JFrame
 *//*from w  w  w.  j  a  v  a2  s  . c o m*/
public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            PropertyEditUI inst = new PropertyEditUI();
            inst.setLocationRelativeTo(null);
            gtu.swing.util.JFrameUtil.setVisible(true, inst);
        }
    });
}

From source file:gtu._work.ui.SvnLastestCommitInfoUI.java

/**
 * Auto-generated main method to display this JFrame
 *///  w w  w  .ja v a  2  s  .c  om
public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            SvnLastestCommitInfoUI inst = new SvnLastestCommitInfoUI();
            inst.setLocationRelativeTo(null);
            gtu.swing.util.JFrameUtil.setVisible(true, inst);
        }
    });
}

From source file:SwingThreadingWait.java

public static void main(String... args) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            SwingThreadingWait edt = new SwingThreadingWait();
            edt.setVisible(true);//from   w w w.j  av a2 s .  co m
        }
    });
}

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);
                    }/*  w w  w .j  a va 2  s .  co  m*/
                }
            };
            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);
}

From source file:com.raddle.tools.ClipboardTransferMain.java

/**
 * Auto-generated main method to display this JFrame
 *///from w  ww  .jav a2 s. co  m
public static void main(final String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            ClipboardTransferMain inst = new ClipboardTransferMain();
            inst.setLocationRelativeTo(null);
            inst.setDefaultCloseOperation(EXIT_ON_CLOSE);
            if (args != null) {
                for (String string : args) {
                    if ("-s".equals(string)) {
                        inst.startServer();
                    }
                }
                for (String string : args) {
                    if ("-m".equals(string)) {
                        inst.setState(Frame.ICONIFIED);
                    }
                }
            }
            if (inst.getState() != Frame.ICONIFIED) {
                inst.setVisible(true);
            }
        }
    });
}

From source file:com.qawaa.gui.EventWebScanGUI.java

/**
* Auto-generated main method to display this JFrame
*//*  w  ww.  jav  a  2  s.com*/
public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            EventWebScanGUI inst = new EventWebScanGUI();
            inst.setLocationRelativeTo(null);
            inst.setVisible(true);
            inst.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JFrame.setDefaultLookAndFeelDecorated(true);
            FlowLayout flowLayout = new FlowLayout();
            flowLayout.setAlignment(FlowLayout.LEFT);
            flowLayout.setAlignOnBaseline(true);
            inst.setTitle(PROGRAM_NAME + " [" + PROGRAM_VERSION + "] " + " - " + DefaultMessage.SOFT_NAME
                    + " - " + DefaultMessage.COMPANY_NAME);
            {
                consoleScrollPane = new JScrollPane();
                inst.getContentPane().add(consoleScrollPane, BorderLayout.CENTER);
                {
                    consolePane = new JEditorPane();
                    consoleScrollPane.setViewportView(consolePane);
                    consolePane.setText("");
                    setConsoleRight();
                    jConsole = new JConsole(System.out, consolePane);
                    System.setOut(jConsole);
                    System.setErr(jConsole);
                    consolePane.setEditable(false);
                    consolePane.addMouseListener(new MouseAdapter() {
                        /* (non-Javadoc)
                         * @see java.awt.event.MouseAdapter#mouseReleased(java.awt.event.MouseEvent)
                         */
                        public void mouseReleased(MouseEvent e) {
                            if (e.getButton() == MouseEvent.BUTTON3) {
                                consolePane.add(consoleRight);
                                consoleRight.show(e.getComponent(), e.getX(), e.getY());
                            }
                        }
                    });
                }
            }
            {
                infoPanel = new JPanel();
                inst.getContentPane().add(infoPanel, BorderLayout.SOUTH);
                infoPanel.setBorder(new LineBorder(new Color(0, 0, 0), 1, false));
                infoPanel.setPreferredSize(new Dimension(784, 30));
                infoPanel.setLayout(flowLayout);
                {
                    {
                        statusbar_count = new JTextPane();
                        infoPanel.add(statusbar_count);
                        statusbar_count.setText(
                                CONTEXT.getMessage("event.web.scan.statusbar.count", null, Locale.CHINA));
                        statusbar_count.setBackground(null);
                        statusbar_count.setEditable(false);
                    }
                    {
                        statusbar_count_value = new JTextPane();
                        infoPanel.add(statusbar_count_value);
                        statusbar_count_value.setText(String.valueOf(SCAN_COUNT));
                        statusbar_count_value.setBackground(null);
                        statusbar_count_value.setEditable(false);
                        statusbar_count_value.setEnabled(false);
                    }
                    {
                        programPID = new JTextPane();
                        infoPanel.add(programPID);
                        programPID.setText("PID:");
                        programPID.setBackground(null);
                        programPID.setEditable(false);
                    }
                    {
                        programPID_value = new JTextPane();
                        infoPanel.add(programPID_value);
                        programPID_value.setText(JvmPid.getPID());
                        programPID_value.setBackground(null);
                        programPID_value.setEditable(false);
                        programPID_value.setEnabled(false);
                    }
                    {
                        memory = new JTextPane();
                        infoPanel.add(memory);
                        memory.setText(CONTEXT.getMessage("gobal.gui.memory", null, Locale.CHINA));
                        memory.setBackground(null);
                        memory.setEditable(false);
                    }
                    {
                        memory_value = new JTextPane();
                        infoPanel.add(memory_value);
                        memory_value.setText("0KB");
                        memory_value.setBackground(null);
                        memory_value.setEditable(false);
                        memory_value.setEnabled(false);
                        MemoryListener memory = new MemoryListener(memory_value);
                        memory.start();
                    }
                    {
                        runtime = new JTextPane();
                        infoPanel.add(runtime);
                        runtime.setText(CONTEXT.getMessage("gobal.gui.runtime", null, Locale.CHINA));
                        runtime.setBackground(null);
                        runtime.setEditable(false);
                    }
                    {
                        runtime_value = new JTextPane();
                        infoPanel.add(runtime_value);
                        runtime_value.setText("NULL");
                        runtime_value.setBackground(null);
                        runtime_value.setEditable(false);
                        runtime_value.setEnabled(false);
                    }
                }
            }
            {
                shortcut = new JPanel();
                inst.getContentPane().add(shortcut, BorderLayout.NORTH);
                shortcut.setSize(784, 35);
                shortcut.setPreferredSize(new Dimension(784, 35));
                shortcut.setBorder(new LineBorder(new Color(0, 0, 0), 1, false));
                shortcut.setLayout(new BorderLayout());
                {
                    eventText = new JTextPane();
                    shortcut.add(eventText, BorderLayout.WEST);
                    eventText.setText(CONTEXT.getMessage("event.web.scan.name", null, Locale.CHINA) + ": ");
                    eventText.setEditable(false);
                    eventText.setEnabled(true);
                    eventText.setBackground(null);
                    eventText.setCaretColor(new Color(0, 0, 0));
                }
                {
                    eventTextField = new JTextField();
                    shortcut.add(eventTextField, BorderLayout.CENTER);
                    eventTextField.setSize(500, 25);
                    eventTextField.setText("");
                    eventTextField.setPreferredSize(new Dimension(500, 25));
                    eventTextField.setEditable(false);
                }
                {
                    submit = new JButton();
                    shortcut.add(submit, BorderLayout.EAST);
                    submit.setText(CONTEXT.getMessage("gobal.gui.button.run", null, Locale.CHINA));
                    submit.setSize(new Dimension(75, 25));
                    submit.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            try {
                                submitActionPerformed(evt);
                            } catch (InterruptedException e) {
                                e.printStackTrace();
                            }
                        }
                    });
                }
            }
        }
    });

}

From source file:ImageOpByRomain.java

public static void main(String... args) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            new ImageOpByRomain().setVisible(true);
        }// w  ww  .j  a  v a 2  s.co m
    });
}

From source file:gtu._work.ui.ExportSVNModificationFilesUI.java

/**
 * Auto-generated main method to display this JFrame
 *///from w ww.j  a v  a 2s  . c  om
public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            ExportSVNModificationFilesUI inst = new ExportSVNModificationFilesUI();
            inst.setLocationRelativeTo(null);
            gtu.swing.util.JFrameUtil.setVisible(true, inst);
        }
    });
}

From source file:burlov.ultracipher.swing.SwingGuiApplication.java

public static void main(String[] args) throws IOException, FontFormatException {
    if (args.length > 0) {
        fileToLoad = new File(args[0]);
    }/* w w  w.j  a v  a  2 s.  co  m*/
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            initLAF();
            new SwingGuiApplication().startup();
        }
    });
}