Example usage for javax.swing JFrame toFront

List of usage examples for javax.swing JFrame toFront

Introduction

In this page you can find the example usage for javax.swing JFrame toFront.

Prototype

public void toFront() 

Source Link

Document

If this Window is visible, brings this Window to the front and may make it the focused Window.

Usage

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskSwingHttpCLI.CFAsteriskSwingHttpCLI.java

public static void main(String args[]) {
    final String S_ProcName = "CFAsteriskSwingHttpCLI.main() ";
    initConsoleLog();//from  w w w  . j  a v  a  2  s  . c  o m
    boolean fastExit = false;

    String homeDirName = System.getProperty("HOME");
    if (homeDirName == null) {
        homeDirName = System.getProperty("user.home");
        if (homeDirName == null) {
            log.message(S_ProcName + "ERROR: Home directory not set");
            return;
        }
    }
    File homeDir = new File(homeDirName);
    if (!homeDir.exists()) {
        log.message(S_ProcName + "ERROR: Home directory \"" + homeDirName + "\" does not exist");
        return;
    }
    if (!homeDir.isDirectory()) {
        log.message(S_ProcName + "ERROR: Home directory \"" + homeDirName + "\" is not a directory");
        return;
    }

    CFAsteriskClientConfigurationFile cFAsteriskClientConfig = new CFAsteriskClientConfigurationFile();
    String cFAsteriskClientConfigFileName = homeDir.getPath() + File.separator + ".cfasteriskclientrc";
    cFAsteriskClientConfig.setFileName(cFAsteriskClientConfigFileName);
    File cFAsteriskClientConfigFile = new File(cFAsteriskClientConfigFileName);
    if (!cFAsteriskClientConfigFile.exists()) {
        String cFAsteriskKeyStoreFileName = homeDir.getPath() + File.separator + ".msscfjceks";
        cFAsteriskClientConfig.setKeyStore(cFAsteriskKeyStoreFileName);
        InetAddress localHost;
        try {
            localHost = InetAddress.getLocalHost();
        } catch (UnknownHostException e) {
            localHost = null;
        }
        if (localHost == null) {
            log.message(S_ProcName + "ERROR: LocalHost is null");
            return;
        }
        String hostName = localHost.getHostName();
        if ((hostName == null) || (hostName.length() <= 0)) {
            log.message("ERROR: LocalHost.HostName is null or empty");
            return;
        }
        String userName = System.getProperty("user.name");
        if ((userName == null) || (userName.length() <= 0)) {
            log.message("ERROR: user.name is null or empty");
            return;
        }
        String deviceName = hostName.replaceAll("[^\\w]", "_").toLowerCase() + "-"
                + userName.replaceAll("[^\\w]", "_").toLowerCase();
        cFAsteriskClientConfig.setDeviceName(deviceName);
        cFAsteriskClientConfig.save();
        log.message(S_ProcName + "INFO: Created CFAsterisk client configuration file "
                + cFAsteriskClientConfigFileName);
        fastExit = true;
    }
    if (!cFAsteriskClientConfigFile.isFile()) {
        log.message(S_ProcName + "ERROR: Proposed client configuration file " + cFAsteriskClientConfigFileName
                + " is not a file.");
        fastExit = true;
    }
    if (!cFAsteriskClientConfigFile.canRead()) {
        log.message(S_ProcName + "ERROR: Permission denied attempting to read client configuration file "
                + cFAsteriskClientConfigFileName);
        fastExit = true;
    }
    cFAsteriskClientConfig.load();

    if (fastExit) {
        return;
    }

    // Configure logging
    Properties sysProps = System.getProperties();
    sysProps.setProperty("log4j.rootCategory", "WARN");
    sysProps.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Log4JLogger");

    Logger httpLogger = Logger.getLogger("org.apache.http");
    httpLogger.setLevel(Level.WARN);

    // The Invoker and it's implementation
    CFAsteriskXMsgClientHttpSchema invoker = new CFAsteriskXMsgClientHttpSchema();

    // And now for the client side cache implementation that invokes it
    ICFAsteriskSchemaObj clientSchemaObj = new CFAsteriskSchemaObj() {
        public void logout() {
            CFAsteriskXMsgClientHttpSchema invoker = (CFAsteriskXMsgClientHttpSchema) getBackingStore();
            try {
                invoker.logout(getAuthorization());
            } catch (RuntimeException e) {
            }
            setAuthorization(null);
        }
    };
    clientSchemaObj.setBackingStore(invoker);
    // And stitch the response handler to reference our client instance
    invoker.setResponseHandlerSchemaObj(clientSchemaObj);
    // And now we can stitch together the CLI to the SAX loader code
    CFAsteriskSwingHttpCLI cli = new CFAsteriskSwingHttpCLI();
    cli.setXMsgClientHttpSchema(invoker);
    cli.setSchema(clientSchemaObj);
    ICFAsteriskSwingSchema swing = cli.getSwingSchema();
    swing.setClientConfigurationFile(cFAsteriskClientConfig);
    swing.setSchema(clientSchemaObj);
    swing.setClusterName("system");
    swing.setTenantName("system");
    swing.setSecUserName("system");
    JFrame jframe = cli.getDesktop();
    jframe.setVisible(true);
    jframe.toFront();
}

From source file:com.googlecode.bpmn_simulator.gui.BPMNSimulatorFrame.java

private static void showFrame(final JFrame frame) {
    frame.setVisible(true);
    frame.toFront();
}

From source file:net.fenyo.gnetwatch.GUI.AwtGUI.java

/**
 * Adds a component to a frame and displays the frame.
 * This method must be run from the AWT thread.
 * @param frame frame./* w w w.  j  a  va2  s . c  om*/
 * @param component component to add.
 */
// AWT thread
private void _createFrame(final JFrame frame, final BasicComponent component) {
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.getContentPane().add(component);

    //Display the window.
    frame.pack();
    frame.setVisible(true);
    frame.toFront();
}

From source file:net.fenyo.gnetwatch.GUI.AwtGUI.java

public void createDialog() {
    try {/*w  w  w.  ja va 2  s  .c  o  m*/
        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                final JTextField button = new JTextField();
                button.setText("close this window to stop the foreground action");
                final JFrame frame = new JFrame("working...");
                frame.addWindowListener(new java.awt.event.WindowAdapter() {
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        // XXX
                    }
                });

                frame.getContentPane().add(button, BorderLayout.CENTER);
                frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                frame.pack();
                frame.setVisible(true);
                frame.toFront();
            }
        });
    } catch (final InvocationTargetException ex) {
        log.error("exception", ex);
    } catch (final InterruptedException ex) {
        log.error("exception", ex);
    }
}

From source file:LineChart.java

public LineChart(JTable table) {
    final JFrame frame = new JFrame("jshow Chart");

    final JFreeChart chart = createDataset(table);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    chartPanel.setMouseZoomable(true, false);
    frame.setContentPane(chartPanel);/*from  ww  w  .  j  a  va2  s.com*/

    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    frame.setIconImage(Toolkit.getDefaultToolkit()
            .createImage(LineChart.class.getResource("de/skelton/images/chart.png")));

    frame.pack();
    frame.setVisible(true);
    frame.requestFocus();
    frame.toFront();
}

From source file:Gui.loading_frames.LoadExcelDataGui.java

private void add_new_electrical_itemsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_add_new_electrical_itemsActionPerformed

    JFrame parent = this;
    Thread addingwindow = new Thread() {

        @Override//from  www .  ja v  a  2 s . c  om
        public void run() {

            AddNewElectricalItems a = new AddNewElectricalItems();
            a.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
            a.setVisible(true);
            a.addWindowListener(new java.awt.event.WindowAdapter() {
                @Override
                public void windowClosing(java.awt.event.WindowEvent windowEvent) {
                    parent.setEnabled(true);
                    parent.toFront();
                    parent.repaint();
                }
            });
        }

    };
    setEnabled(false);
    addingwindow.start();
    try {
        LoadDataFromDB.loadall();

    } catch (InterruptedException ex) {
        Logger.getLogger(LoadExcelDataGui.class.getName()).log(Level.SEVERE, null, ex);
    }
    cp.refresh();

}

From source file:com.diversityarrays.kdxplore.trials.TrialViewPanel.java

private void updateDeleteSamplesAction(boolean shifted, boolean isRightClick) {
    TableModel model = trialDataTable.getModel();

    SampleGroup sampleGroup = null;/* w  w  w. ja  va2s  . c o m*/
    boolean enableDel = false;
    //      boolean enableExp = false;
    if (model instanceof TrialData) {
        TrialData trialData = (TrialData) model;
        if (trialDataTableHeaderRenderer.columnSelected >= 0) {
            Pair<DeviceIdentifier, SampleGroup> pair = getSelectedDeviceAndSampleGroup(trialData);
            if (pair == null) {
                // Must be the Trait Instance names
                //               enableExp = true;
            } else {
                sampleGroup = pair.second;
                // is a SampleGroup
                switch (pair.first.getDeviceType()) {
                case DATABASE:
                case EDITED:
                    break;

                case FOR_SCORING:
                case KDSMART:
                    enableDel = true;
                    break;
                default:
                    break;

                }
                //               enableExp = true;
            }
        }
    }

    deleteSamplesAction.setEnabled(enableDel);
    //      exportSamplesAction.setEnabled(enableExp);

    if (shifted && (sampleGroup != null)) {
        String title = createTitleForSampleGroupViewer(sampleGroup);
        JFrame frame = windowOpener.getWindowByIdentifier(title);
        if (frame != null) {
            frame.toFront();
        } else {
            SampleGroupViewer sgv = SampleGroupViewer.create(title, offlineData.getKdxploreDatabase(), trial,
                    sampleGroup);
            frame = windowOpener.addDesktopObject(sgv);
            frame.setVisible(true);
        }
    }
}

From source file:org.nebulaframework.ui.swing.cluster.ClusterMainUI.java

/**
 * System Tray Icon setup/* www  .  ja  v  a  2  s  .com*/
 * @param frame owner JFrame
 */
private void setupTrayIcon(final JFrame frame) {

    // Idle Icon
    idleIcon = Toolkit.getDefaultToolkit()
            .getImage(ClassLoader.getSystemResource("META-INF/resources/cluster_inactive.png"));

    // Active Icon
    activeIcon = Toolkit.getDefaultToolkit()
            .getImage(ClassLoader.getSystemResource("META-INF/resources/cluster_active.png"));

    frame.setIconImage(idleIcon);

    // If system tray is supported by OS
    if (SystemTray.isSupported()) {

        // Set Icon
        trayIcon = new TrayIcon(idleIcon, "Nebula Grid Cluster", createTrayPopup());
        trayIcon.setImageAutoSize(true);
        trayIcon.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                if (e.getButton() == MouseEvent.BUTTON1) {
                    if (!frame.isVisible()) {
                        frame.setVisible(true);
                    }

                    frame.setExtendedState(JFrame.NORMAL);
                    frame.requestFocus();
                    frame.toFront();
                }
            }

        });

        try {
            SystemTray.getSystemTray().add(trayIcon);
        } catch (AWTException ae) {
            log.debug("[UI] Unable to Initialize Tray Icon");
            return;
        }

        frame.addWindowListener(new WindowAdapter() {

            @Override
            public void windowIconified(WindowEvent e) {
                // Hide (can be shown using tray icon)
                frame.setVisible(false);
            }

        });
    }

}

From source file:ffx.ui.MainPanel.java

/**
 * <p>//www  .ja v  a2s.c  o  m
 * help</p>
 */
public void help() {
    String helpHS = "ffx/help/jhelpset.hs";
    ClassLoader cl = getClass().getClassLoader();
    HelpSet hs = null;
    try {
        URL hsURL = HelpSet.findHelpSet(cl, helpHS);
        hs = new HelpSet(null, hsURL);
    } catch (Exception e) {
        logger.warning("HelpSet not found: " + e);
        return;
    }
    JHelp jhelp = new JHelp(hs);
    JFrame helpFrame = new JFrame();
    JFrame.setDefaultLookAndFeelDecorated(true);
    helpFrame.add(jhelp);
    helpFrame.setTitle("Force Field X Help");
    helpFrame.setSize(jhelp.getPreferredSize());
    helpFrame.setVisible(true);
    jhelp.setCurrentID("ForceFieldXBook");
    helpFrame.toFront();
}

From source file:org.nebulaframework.ui.swing.node.NodeMainUI.java

/**
 * Setup System Tray Icon.//w w w  .  j ava 2  s .c o  m
 * 
 * @param frame owner frame
 */
private void setupTrayIcon(final JFrame frame) {

    idleIcon = Toolkit.getDefaultToolkit()
            .getImage(ClassLoader.getSystemResource("META-INF/resources/node_inactive.png"));

    activeIcon = Toolkit.getDefaultToolkit()
            .getImage(ClassLoader.getSystemResource("META-INF/resources/node_active.png"));

    frame.setIconImage(idleIcon);

    // If system tray is supported by OS
    if (SystemTray.isSupported()) {
        trayIcon = new TrayIcon(idleIcon, "Nebula Grid Node", createTrayPopup());
        trayIcon.setImageAutoSize(true);
        trayIcon.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                if (e.getButton() == MouseEvent.BUTTON1) {
                    if (!frame.isVisible()) {
                        frame.setVisible(true);
                    }

                    frame.setExtendedState(JFrame.NORMAL);
                    frame.requestFocus();
                    frame.toFront();
                }
            }

        });

        try {
            SystemTray.getSystemTray().add(trayIcon);
        } catch (AWTException ae) {
            log.debug("[UI] Unable to Initialize Tray Icon");
            return;
        }

        frame.addWindowListener(new WindowAdapter() {

            @Override
            public void windowIconified(WindowEvent e) {
                // Hide (can be shown using tray icon)
                frame.setVisible(false);
            }

        });
    }

}