Example usage for javax.swing JFrame setAlwaysOnTop

List of usage examples for javax.swing JFrame setAlwaysOnTop

Introduction

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

Prototype

public final void setAlwaysOnTop(boolean alwaysOnTop) throws SecurityException 

Source Link

Document

Sets whether this window should always be above other windows.

Usage

From source file:org.obiba.onyx.jade.instrument.gehealthcare.CardiosoftInstrumentRunner.java

/**
 * Create an information dialog that tells the user to wait while the data is being processed.
 *//*from  w ww.  ja  v a  2s.c om*/
private void showProcessingDialog() {

    JPanel messagePanel = new JPanel();
    messagePanel.setAlignmentX(Component.CENTER_ALIGNMENT);
    messagePanel.setLayout(new BoxLayout(messagePanel, BoxLayout.Y_AXIS));

    JLabel message = new JLabel(ecgResourceBundle.getString("Message.ProcessingEcgMeasurement"));
    message.setFont(new Font(Font.DIALOG, Font.PLAIN, 20));
    messagePanel.add(message);

    JLabel subMessage = new JLabel(ecgResourceBundle.getString("Message.ProcessingEcgMeasurementInstructions"));
    subMessage.setFont(new Font(Font.DIALOG, Font.PLAIN, 14));
    subMessage.setForeground(Color.RED);
    messagePanel.add(subMessage);

    JFrame window = new JFrame();
    window.add(messagePanel);
    window.pack();

    // Make sure dialog stays on top of all other application windows.
    window.setAlwaysOnTop(true);
    window.setLocationByPlatform(true);

    // Center dialog horizontally at the bottom of the screen.
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    window.setLocation((screenSize.width - window.getWidth()) / 2, screenSize.height - window.getHeight() - 70);

    window.setEnabled(false);
    window.setVisible(true);

}

From source file:edu.uara.tableeditor.TableFigure.java

/**
 * view chart in a new frame//from  ww w. j  av  a2  s.c  o m
 */
public void chartPreview() {

    java.awt.EventQueue.invokeLater(new Runnable() {
        @Override
        public void run() {
            JFrame chartFrame = new JFrame(title);
            JFreeChart ch = chart.getChart();
            ChartPanel chartPanel = new ChartPanel(ch);
            chartPanel.setPreferredSize(new Dimension(500, 300));
            chartFrame.setContentPane(chartPanel);
            chartFrame.pack();
            RefineryUtilities.centerFrameOnScreen(chartFrame);
            chartFrame.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
            chartFrame.setVisible(true);
            chartFrame.setAlwaysOnTop(true);
        }
    });

}

From source file:ConfigFiles.java

public ConfigFiles(Dimension screensize) {
    //         initializeFileBrowser();
    paths = new JPanel();
    paths.setBackground(Color.WHITE);
    //paths.setBorder(BorderFactory.createTitledBorder("Paths"));
    paths.setLayout(null);//  w w w  .ja  v a  2s  .c o  m
    paths.setPreferredSize(new Dimension(930, 1144));
    paths.setSize(new Dimension(930, 1144));
    paths.setMinimumSize(new Dimension(930, 1144));
    paths.setMaximumSize(new Dimension(930, 1144));
    //paths.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
    setLayout(null);
    ttcpath = new JTextField();
    addPanel("TestCase Source Path",
            "Master directory with the test cases that can" + " be run by the framework", ttcpath,
            RunnerRepository.TESTSUITEPATH, 10, true, null);
    tMasterXML = new JTextField();
    tUsers = new JTextField();

    addPanel("Projects Path", "Location of projects XML files", tUsers, RunnerRepository.REMOTEUSERSDIRECTORY,
            83, true, null);

    tSuites = new JTextField();
    addPanel("Predefined Suites Path", "Location of predefined suites", tSuites,
            RunnerRepository.PREDEFINEDSUITES, 156, true, null);

    testconfigpath = new JTextField();
    addPanel("Test Configuration Path", "Test Configuration path", testconfigpath,
            RunnerRepository.TESTCONFIGPATH, 303, true, null);

    tepid = new JTextField();
    addPanel("EP name File", "Location of the file that contains" + " the Ep name list", tepid,
            RunnerRepository.REMOTEEPIDDIR, 595, true, null);
    tlog = new JTextField();
    addPanel("Logs Path", "Location of the directory that stores the most recent log files."
            + " The files are re-used each Run.", tlog, RunnerRepository.LOGSPATH, 667, true, null);
    tsecondarylog = new JTextField();

    JPanel p = addPanel("Secondary Logs Path",
            "Location of the directory that archives copies of the most recent log files, with"
                    + " original file names appended with <.epoch time>",
            tsecondarylog, RunnerRepository.SECONDARYLOGSPATH, 930, true, null);
    logsenabled.setSelected(Boolean.parseBoolean(RunnerRepository.PATHENABLED));
    logsenabled.setBackground(Color.WHITE);
    p.add(logsenabled);

    JPanel p7 = new JPanel();
    p7.setBackground(Color.WHITE);
    TitledBorder border7 = BorderFactory.createTitledBorder("Log Files");
    border7.setTitleFont(new Font("Arial", Font.PLAIN, 14));
    border7.setBorder(BorderFactory.createLineBorder(new Color(150, 150, 150), 1));
    p7.setBorder(border7);
    p7.setLayout(new BoxLayout(p7, BoxLayout.Y_AXIS));
    p7.setBounds(80, 740, 800, 190);
    paths.add(p7);
    JTextArea log2 = new JTextArea("All the log files that will be monitored");
    log2.setWrapStyleWord(true);
    log2.setLineWrap(true);
    log2.setEditable(false);
    log2.setCursor(null);
    log2.setOpaque(false);
    log2.setFocusable(false);
    log2.setBorder(null);
    log2.setFont(new Font("Arial", Font.PLAIN, 12));
    log2.setBackground(getBackground());
    log2.setMaximumSize(new Dimension(170, 25));
    log2.setPreferredSize(new Dimension(170, 25));
    JPanel p71 = new JPanel();
    p71.setBackground(Color.WHITE);
    p71.setLayout(new GridLayout());
    p71.setMaximumSize(new Dimension(700, 13));
    p71.setPreferredSize(new Dimension(700, 13));
    p71.add(log2);
    JPanel p72 = new JPanel();
    p72.setBackground(Color.WHITE);
    p72.setLayout(new BoxLayout(p72, BoxLayout.Y_AXIS));
    trunning = new JTextField();
    p72.add(addField(trunning, "Running: ", 0));
    tdebug = new JTextField();
    p72.add(addField(tdebug, "Debug: ", 1));
    tsummary = new JTextField();
    p72.add(addField(tsummary, "Summary: ", 2));
    tinfo = new JTextField();
    p72.add(addField(tinfo, "Info: ", 3));
    tcli = new JTextField();
    p72.add(addField(tcli, "Cli: ", 4));
    p7.add(p71);
    p7.add(p72);
    libpath = new JTextField();

    addPanel("Library path", "Secondary user library path", libpath, RunnerRepository.REMOTELIBRARY, 229, true,
            null);

    JPanel p8 = new JPanel();
    p8.setBackground(Color.WHITE);
    TitledBorder border8 = BorderFactory.createTitledBorder("File");
    border8.setTitleFont(new Font("Arial", Font.PLAIN, 14));
    border8.setBorder(BorderFactory.createLineBorder(new Color(150, 150, 150), 1));
    p8.setBorder(border8);
    p8.setLayout(null);
    p8.setBounds(80, 1076, 800, 50);
    if (PermissionValidator.canChangeFWM()) {
        paths.add(p8);
    }
    JButton save = new JButton("Save");
    save.setToolTipText("Save and automatically load config");
    save.setBounds(490, 20, 70, 20);
    save.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            saveXML(false, "fwmconfig");
            loadConfig("fwmconfig.xml");
        }
    });
    p8.add(save);
    //         if(!PermissionValidator.canChangeFWM()){
    //             save.setEnabled(false);
    //         }
    JButton saveas = new JButton("Save as");
    saveas.setBounds(570, 20, 90, 20);
    saveas.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            String filename = CustomDialog.showInputDialog(JOptionPane.QUESTION_MESSAGE,
                    JOptionPane.OK_CANCEL_OPTION, ConfigFiles.this, "File Name", "Please enter file name");
            if (!filename.equals("NULL")) {
                saveXML(false, filename);
            }
        }
    });
    p8.add(saveas);

    final JButton loadXML = new JButton("Load Config");
    loadXML.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            try {
                String[] configs = RunnerRepository
                        .getRemoteFolderContent(RunnerRepository.USERHOME + "/twister/config/");
                JComboBox combo = new JComboBox(configs);
                int resp = (Integer) CustomDialog.showDialog(combo, JOptionPane.INFORMATION_MESSAGE,
                        JOptionPane.OK_CANCEL_OPTION, ConfigFiles.this, "Config", null);
                final String config;
                if (resp == JOptionPane.OK_OPTION)
                    config = combo.getSelectedItem().toString();
                else
                    config = null;
                if (config != null) {
                    new Thread() {
                        public void run() {
                            setEnabledTabs(false);
                            JFrame progress = new JFrame();
                            progress.setAlwaysOnTop(true);
                            progress.setLocation((int) loadXML.getLocationOnScreen().getX(),
                                    (int) loadXML.getLocationOnScreen().getY());
                            progress.setUndecorated(true);
                            JProgressBar bar = new JProgressBar();
                            bar.setIndeterminate(true);
                            progress.add(bar);
                            progress.pack();
                            progress.setVisible(true);
                            loadConfig(config);
                            progress.dispose();
                            setEnabledTabs(true);
                        }
                    }.start();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
    loadXML.setBounds(670, 20, 120, 20);
    p8.add(loadXML);
    //         if(!PermissionValidator.canChangeFWM()){
    //             loadXML.setEnabled(false);
    //         }

    tdbfile = new JTextField();
    addPanel("Database XML path", "File location for database configuration", tdbfile,
            RunnerRepository.REMOTEDATABASECONFIGPATH + RunnerRepository.REMOTEDATABASECONFIGFILE, 375, true,
            null);
    temailfile = new JTextField();
    //         emailpanel = (JPanel)
    addPanel("Email XML path", "File location for email configuration", temailfile,
            RunnerRepository.REMOTEEMAILCONFIGPATH + RunnerRepository.REMOTEEMAILCONFIGFILE, 448, true, null)
                    .getParent();
    //paths.remove(emailpanel);

    //         emailpanel.setBounds(360,440,350,100);
    //         RunnerRepository.window.mainpanel.p4.getEmails().add(emailpanel);

    tglobalsfile = new JTextField();
    addPanel("Globals XML file", "File location for globals parameters", tglobalsfile,
            RunnerRepository.GLOBALSREMOTEFILE, 521, true, null);

    tceport = new JTextField();
    addPanel("Central Engine Port", "Central Engine port", tceport, RunnerRepository.getCentralEnginePort(),
            1003, false, null);
    //         traPort = new JTextField();
    //         addPanel("Resource Allocator Port","Resource Allocator Port",
    //                 traPort,RunnerRepository.getResourceAllocatorPort(),808,false,null);                
    //         thttpPort = new JTextField();
    //         addPanel("HTTP Server Port","HTTP Server Port",thttpPort,
    //                 RunnerRepository.getHTTPServerPort(),740,false,null);

    //paths.add(loadXML);

    if (!PermissionValidator.canChangeFWM()) {
        ttcpath.setEnabled(false);
        tMasterXML.setEnabled(false);
        tUsers.setEnabled(false);
        tepid.setEnabled(false);
        tSuites.setEnabled(false);
        tlog.setEnabled(false);
        trunning.setEnabled(false);
        tdebug.setEnabled(false);
        tsummary.setEnabled(false);
        tinfo.setEnabled(false);
        tcli.setEnabled(false);
        tdbfile.setEnabled(false);
        temailfile.setEnabled(false);
        tceport.setEnabled(false);
        libpath.setEnabled(false);
        tsecondarylog.setEnabled(false);
        testconfigpath.setEnabled(false);
        tglobalsfile.setEnabled(false);
        logsenabled.setEnabled(false);
    }

}

From source file:es.emergya.ui.plugins.admin.aux1.SummaryAction.java

private JFrame createJDialog(final String titulo) {
    final JFrame d = new JFrame(titulo);
    d.setResizable(false);/*ww w.j a  va  2s  . c om*/
    d.setAlwaysOnTop(true);
    d.setIconImage(window.getIconImage());
    d.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    d.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            super.windowClosing(e);
            if (cambios) {
                int res = JOptionPane.showConfirmDialog(d,
                        "Existen cambios sin guardar. Seguro que desea cerrar la ventana?",
                        "Cambios sin guardar", JOptionPane.OK_CANCEL_OPTION);
                if (res != JOptionPane.CANCEL_OPTION) {
                    e.getWindow().dispose();
                }
            } else {
                e.getWindow().dispose();
            }
        }
    });
    d.setLayout(new BorderLayout(5, 5));
    d.setBackground(Color.WHITE);
    d.getContentPane().setBackground(Color.WHITE);
    return d;
}

From source file:configuration.Util.java

public static JFrame createSearchFrame() {
    JFrame f = new JFrame();
    f.pack();//from www .  ja v a 2s.  c  o  m
    f.setSize(new Dimension(1, 1));
    f.setLocationRelativeTo(null);
    f.setVisible(false);
    f.setAlwaysOnTop(true);
    return f;
}

From source file:at.becast.youploader.gui.FrmMain.java

protected void startUploads() {
    UploadMgr.setSpeed_limit(speed);/*from ww w  . j a  va  2  s.  com*/
    if ("0".equals(Main.s.setting.get("tos_agreed")) && !this.tos) {
        if (Main.debug)
            LOG.debug("Asking about ToS Agreement");

        //Dummy JFrame to keep Dialog on top
        JFrame frmOpt = new JFrame();
        frmOpt.setAlwaysOnTop(true);
        JCheckBox checkbox = new JCheckBox(LANG.getString("frmMain.tos.Remember"));
        String message = LANG.getString("frmMain.tos.Message");
        Object[] params = { message, checkbox };
        int n;
        do {
            n = JOptionPane.showConfirmDialog(frmOpt, params, LANG.getString("frmMain.tos.Title"),
                    JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE);
        } while (n == JOptionPane.CLOSED_OPTION);
        if (n == JOptionPane.OK_OPTION) {
            if (Main.debug)
                LOG.debug("Agreed to ToS");

            if (checkbox.isSelected()) {
                Main.s.setting.put("tos_agreed", "1");
                Main.s.save("tos_agreed");
            }
            this.tos = true;
            UploadMgr.start();
        }
        frmOpt.dispose();
    } else {
        if (Main.debug)
            LOG.debug("Previously agreed to ToS");

        UploadMgr.start();
    }
}

From source file:com.diversityarrays.kdxplore.curate.TrialDataEditor.java

public void pushDownAllGraphAndPlotFrames() {
    for (JFrame f : toolFrames) {
        f.setAlwaysOnTop(false);
    }
}

From source file:edu.ku.brc.ui.UIHelper.java

/**
 * @param frame to be positioned//  w  ww  . j av a  2  s .  c om
 * 
 * positions frame on screen relative to position of TOPFRAME.
 * Sets frame.alwaysOnTop to true if TOPFRAME is maximized.
 */
public static void positionFrameRelativeToTopFrame(final JFrame frame) {
    // not sure of safest surest way to get main window???
    JFrame topFrame = (JFrame) UIRegistry.getTopWindow();

    // for now this just sets the top of frame to the top of topFrame
    // if there is room on the left side of topFrame, frame is set so it's right edge is next to topFrame's left edge.
    // otherwise, if frame will fit, frame's left edge is aligned with topFrame's right edge.
    // If it won't fit then frame's right edge is aligned with right of edge of screen.
    if (topFrame != null) {
        int x = 0;
        int y = topFrame.getY();
        Rectangle screenRect = topFrame.getGraphicsConfiguration().getBounds();
        if (topFrame.getX() >= frame.getWidth()) {
            x = topFrame.getX() - frame.getWidth();
        } else if (screenRect.width - topFrame.getX() - topFrame.getWidth() >= frame.getWidth()) {
            x = topFrame.getWidth();
        } else {
            x = screenRect.width - frame.getWidth();
        }
        frame.setBounds(x, y, frame.getWidth(), frame.getHeight());

        frame.setAlwaysOnTop(topFrame.getExtendedState() == Frame.MAXIMIZED_BOTH
                || topFrame.getExtendedState() == Frame.MAXIMIZED_VERT
                || topFrame.getExtendedState() == Frame.MAXIMIZED_HORIZ);
    }
}

From source file:edu.ku.brc.specify.tasks.subpane.wb.WorkbenchPaneSS.java

/**
 * Shows / Hides the Image Window. //from  w  w w  .j  av a2s. c  om
 */
public void setImageFrameVisible(final boolean visible, final JFrame imgFrame, final JButton toolBtn,
        final String ttHelpVisible, final String ttHelpHidden, final String helpContext) {
    if (visible == imgFrame.isVisible()) {
        return;
    }

    if (spreadSheet.getCellEditor() != null) {
        spreadSheet.getCellEditor().stopCellEditing();
    }

    // and add or remove the ListSelectionListener (to avoid loading images when not visible)
    if (!visible) {
        spreadSheet.setTransferHandler(null);

        // hide the image window

        // turn off alwaysOnTop for Swing repaint reasons (prevents a lock up)
        if (imgFrame.isAlwaysOnTop()) {
            imgFrame.setAlwaysOnTop(false);
        }
        // if the image frame is minimized or iconified, set it to fully visible before doing anything else
        if (imgFrame.getState() == Frame.ICONIFIED) {
            imgFrame.setState(Frame.NORMAL);
        }
        toolBtn.setToolTipText(getResourceString(ttHelpVisible));

        spreadSheet.getSelectionModel().removeListSelectionListener(workbenchRowChangeListener);

        // set the image window and the image column invisible
        imgFrame.setVisible(false);
        imageColExt.setVisible(false);
    } else {
        spreadSheet.setTransferHandler(new WBImageTransferable());

        // show the image window

        UIHelper.positionFrameRelativeToTopFrame(imgFrame);

        // when a user hits the "show image" button, for some reason the selection gets nullified
        // so we'll grab it here, then set it at the end of this method

        toolBtn.setToolTipText(getResourceString(ttHelpHidden));

        spreadSheet.getSelectionModel().addListSelectionListener(workbenchRowChangeListener);
        HelpMgr.setHelpID(this, helpContext);

        // set the image window and the image column visible
        imgFrame.setVisible(true);
        imageColExt.setVisible(true);

        // if the image frame is minimized or iconified, set it to fully visible before doing anything else
        if (imgFrame.getState() == Frame.ICONIFIED) {
            imgFrame.setState(Frame.NORMAL);
        }

        showCardImageForSelectedRow();

        // Without this code below the Image Column doesn't get selected
        // when toggling 
        if (currentPanelType == PanelType.Spreadsheet && currentRow != -1) {
            spreadSheet.setRowSelectionInterval(currentRow, currentRow);
            spreadSheet.setColumnSelectionInterval(0, spreadSheet.getColumnCount() - 1);
            spreadSheet.scrollToRow(Math.min(currentRow + 4, model.getRowCount()));
        }

        TableColumn column = spreadSheet.getTableHeader().getColumnModel()
                .getColumn(spreadSheet.getTableHeader().getColumnModel().getColumnCount() - 1);
        column.setCellRenderer(new WbCellRenderer());
        spreadSheet.repaint();
    }
}

From source file:org.squidy.nodes.ReacTIVision.java

public static void showErrorPopUp(String errorMessage) {
    //get screen size
    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
    //create pop up
    final JFrame frame = new JFrame();
    frame.setResizable(false);/*from  w  ww. j a  v  a2  s  .c o m*/
    frame.setAlwaysOnTop(true);
    frame.setUndecorated(true);
    JLabel text = new JLabel(" " + errorMessage + " ");
    frame.getContentPane().setBackground(Color.RED);
    text.setForeground(Color.WHITE);
    frame.add(text);
    frame.pack();
    frame.setLocation((dim.width - frame.getWidth()) / 2, (dim.height - frame.getHeight()) / 2);
    frame.setVisible(true);
    frame.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent arg0) {
            frame.dispose();
        }
    });
}