List of usage examples for javax.swing WindowConstants HIDE_ON_CLOSE
int HIDE_ON_CLOSE
To view the source code for javax.swing WindowConstants HIDE_ON_CLOSE.
Click Source Link
From source file:de.jakop.ngcalsync.application.TrayStarter.java
private JFrame createAboutWindow() { final JFrame aboutWindow = new JFrame(UserMessage.get().TITLE_ABOUT_WINDOW()); final JEditorPane textarea = new JEditorPane("text/html", getApplicationInformation()); //$NON-NLS-1$ textarea.setEditable(false);/*from w ww .j a v a 2s .co m*/ aboutWindow.getContentPane().add(new JScrollPane(textarea)); aboutWindow.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); aboutWindow.pack(); aboutWindow.setSize(500, 400); return aboutWindow; }
From source file:de.jakop.ngcalsync.application.TrayStarter.java
private JFrame createLogWindow(final Level popupThreshold) { final JFrame logWindow = new JFrame(UserMessage.get().TITLE_SYNC_LOG_WINDOW()); final Log4JSwingAppender appender = new Log4JSwingAppender(); appender.setLayout(new PatternLayout(LOG4J_PATTERN)); appender.addObserver(new LogLevelObserver(popupThreshold, logWindow)); final Logger rootLogger = Logger.getRootLogger(); rootLogger.addAppender(appender);//from w w w .j av a 2s. co m rootLogger.setLevel(Level.INFO); logWindow.getContentPane().add(appender.getLogPanel()); logWindow.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); logWindow.pack(); logWindow.setSize(500, 400); return logWindow; }
From source file:com.hexidec.ekit.component.UnicodeDialog.java
public void init(int startIndex) { String customFont = Translatrix.getTranslationString("UnicodeDialogButtonFont"); if (customFont != null && customFont.length() > 0) { buttonFont = new Font(Translatrix.getTranslationString("UnicodeDialogButtonFont"), Font.PLAIN, 12); } else {//from www .j a va2s . c o m buttonFont = new Font("Monospaced", Font.PLAIN, 12); } Container contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); JPanel centerPanel = new JPanel(); centerPanel.setLayout(new GridLayout(0, 17, 0, 0)); buttonGroup = new ButtonGroup(); int prefButtonWidth = 32; int prefButtonHeight = 32; centerPanel.add(new JLabel("")); for (int labelLoop = 0; labelLoop < 16; labelLoop++) { JLabel jlblMarker = new JLabel( "x" + (labelLoop > 9 ? "" + (char) (65 + (labelLoop - 10)) : "" + labelLoop)); jlblMarker.setHorizontalAlignment(SwingConstants.CENTER); jlblMarker.setVerticalAlignment(SwingConstants.CENTER); jlblMarker.setForeground(new Color(0.5f, 0.5f, 0.75f)); centerPanel.add(jlblMarker); } int labelcount = 0; for (int counter = 0; counter < UNICODEBLOCKSIZE; counter++) { if ((counter % 16) == 0) { JLabel jlblMarker = new JLabel( (labelcount > 9 ? "" + (char) (65 + (labelcount - 10)) : "" + labelcount) + "x"); jlblMarker.setHorizontalAlignment(SwingConstants.CENTER); jlblMarker.setVerticalAlignment(SwingConstants.CENTER); jlblMarker.setForeground(new Color(0.5f, 0.5f, 0.75f)); centerPanel.add(jlblMarker); labelcount++; } buttonArray[counter] = new JToggleButton(" "); buttonArray[counter].getModel().setActionCommand(""); buttonArray[counter].setFont(buttonFont); buttonArray[counter].setBorder( javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.LOWERED)); buttonArray[counter].addActionListener(this); if (counter == 0) { FontRenderContext frcLocal = ((java.awt.Graphics2D) (parentEkit.getGraphics())) .getFontRenderContext(); Rectangle2D fontBounds = buttonFont.getMaxCharBounds(frcLocal); int maxCharWidth = (int) (Math.abs(fontBounds.getX())) + (int) (Math.abs(fontBounds.getWidth())); int maxCharHeight = (int) (Math.abs(fontBounds.getY())) + (int) (Math.abs(fontBounds.getHeight())); Insets buttonInsets = buttonArray[counter].getBorder().getBorderInsets(buttonArray[counter]); prefButtonWidth = maxCharWidth + buttonInsets.left + buttonInsets.right; prefButtonHeight = maxCharHeight + buttonInsets.top + buttonInsets.bottom; } buttonArray[counter].setPreferredSize(new Dimension(prefButtonWidth, prefButtonHeight)); centerPanel.add(buttonArray[counter]); buttonGroup.add(buttonArray[counter]); } JPanel selectorPanel = new JPanel(); jcmbBlockSelector = new JComboBox(unicodeBlocks); jcmbBlockSelector.setSelectedIndex(startIndex); jcmbBlockSelector.setActionCommand(CMDCHANGEBLOCK); jcmbBlockSelector.addActionListener(this); String[] sPages = { "1" }; jcmbPageSelector = new JComboBox(sPages); jcmbPageSelector.setSelectedIndex(0); jcmbPageSelector.setActionCommand(CMDCHANGEBLOCK); jcmbPageSelector.addActionListener(this); selectorPanel.add(new JLabel(Translatrix.getTranslationString("SelectorToolUnicodeBlock"))); selectorPanel.add(jcmbBlockSelector); selectorPanel.add(new JLabel(Translatrix.getTranslationString("SelectorToolUnicodePage"))); selectorPanel.add(jcmbPageSelector); JPanel buttonPanel = new JPanel(); JButton closeButton = new JButton(Translatrix.getTranslationString("DialogClose")); closeButton.setActionCommand("close"); closeButton.addActionListener(this); buttonPanel.add(closeButton); contentPane.add(centerPanel, BorderLayout.CENTER); contentPane.add(selectorPanel, BorderLayout.NORTH); contentPane.add(buttonPanel, BorderLayout.SOUTH); this.pack(); populateButtons(startIndex, 0); this.setVisible(true); }
From source file:com.joey.software.regionSelectionToolkit.controlers.ImageProfileTool.java
public void showAScanPanel() { if (chartHolder == null) { chartHolder = new JFrame("A - Scan"); chartHolder.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); chartHolder.getContentPane().setLayout(new BorderLayout()); chartHolder.getContentPane().add(getChartHolderPanel(), BorderLayout.CENTER); chartHolder.setSize(600, 480);//from w w w .j av a 2 s. c o m } chartHolder.setVisible(true); }
From source file:com.net2plan.gui.GUINet2Plan.java
private void showKeyCombinations() { Component component = container.getComponent(0); if (!(component instanceof IGUIModule)) { ErrorHandling.showErrorDialog("No tool is active", "Unable to show key associations"); return;/*ww w . ja v a2 s .com*/ } final JDialog dialog = new JDialog(); dialog.setTitle("Key combinations"); SwingUtils.configureCloseDialogOnEscape(dialog); dialog.setModalityType(Dialog.ModalityType.APPLICATION_MODAL); dialog.setSize(new Dimension(500, 300)); dialog.setLocationRelativeTo(null); dialog.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); dialog.setLayout(new MigLayout("fill, insets 0 0 0 0")); final String[] tableHeader = StringUtils.arrayOf("Key combination", "Action"); DefaultTableModel model = new ClassAwareTableModel(); model.setDataVector(new Object[1][tableHeader.length], tableHeader); AdvancedJTable table = new AdvancedJTable(model); JScrollPane scrollPane = new JScrollPane(table); dialog.add(scrollPane, "grow"); RowSorter<TableModel> sorter = new TableRowSorter<TableModel>(model); table.setRowSorter(sorter); table.getTableHeader().addMouseListener(new ColumnFitAdapter()); IGUIModule module = (IGUIModule) component; Map<String, KeyStroke> keyCombinations = module.getKeyCombinations(); if (!keyCombinations.isEmpty()) { model.removeRow(0); for (Entry<String, KeyStroke> keyCombination : keyCombinations.entrySet()) { String description = keyCombination.getKey(); KeyStroke keyStroke = keyCombination.getValue(); model.addRow(StringUtils.arrayOf(description, keyStroke.toString().replaceAll(" pressed ", " "))); } } dialog.setVisible(true); }
From source file:gda.gui.mca.McaGUI.java
private void makeTcaControlDialog() { if (tcaControlPanel == null) { tcaControlPanel = new TcaPanel(); tcaDialog = new JDialog(); Object[] options = { "OK" }; Object[] array = { tcaControlPanel }; // Create the JOptionPane. final JOptionPane optionPane = new JOptionPane(array, JOptionPane.PLAIN_MESSAGE, JOptionPane.YES_OPTION, null, options, options[0]); optionPane.addPropertyChangeListener(new PropertyChangeListener() { @Override/*from www.jav a 2s . c om*/ public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (isVisible() && (e.getSource() == optionPane) && (JOptionPane.VALUE_PROPERTY.equals(prop) || JOptionPane.INPUT_VALUE_PROPERTY.equals(prop))) { Object value = optionPane.getValue(); if (value == JOptionPane.UNINITIALIZED_VALUE) { // ignore reset return; } // Reset the JOptionPane's value. // If you don't do this, then if the user // presses the same button next time, no // property change event will be fired. optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE); if ("OK".equals(value)) { tcaDialog.setVisible(false); } } } }); tcaDialog.setContentPane(optionPane); tcaDialog.pack(); tcaDialog.setTitle("TCA Controls"); tcaDialog.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); } }
From source file:gda.gui.mca.McaGUI.java
private void makeAdcControlDialog() { if (adcControlPanel == null) { adcControlPanel = new AdcPanel(); adcDialog = new JDialog(); Object[] options = { "OK" }; Object[] array = { adcControlPanel }; // Create the JOptionPane. final JOptionPane optionPane = new JOptionPane(array, JOptionPane.PLAIN_MESSAGE, JOptionPane.YES_OPTION, null, options, options[0]); optionPane.addPropertyChangeListener(new PropertyChangeListener() { @Override//from w ww .j a v a 2s. c om public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (isVisible() && (e.getSource() == optionPane) && (JOptionPane.VALUE_PROPERTY.equals(prop) || JOptionPane.INPUT_VALUE_PROPERTY.equals(prop))) { Object value = optionPane.getValue(); if (value == JOptionPane.UNINITIALIZED_VALUE) { // ignore reset return; } // Reset the JOptionPane's value. // If you don't do this, then if the user // presses the same button next time, no // property change event will be fired. optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE); if ("OK".equals(value)) { adcDialog.setVisible(false); } } } }); adcDialog.setContentPane(optionPane); adcDialog.pack(); adcDialog.setTitle("ADC Controls"); adcDialog.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); } }
From source file:com.net2plan.gui.utils.onlineSimulationPane.OnlineSimulationPane.java
/** * Shows the future event list.//from w w w. j a v a 2 s . c o m * * @since 0.3.0 */ public void viewFutureEventList() { final JDialog dialog = new JDialog(); dialog.setTitle("Future event list"); SwingUtils.configureCloseDialogOnEscape(dialog); dialog.setModalityType(Dialog.ModalityType.APPLICATION_MODAL); dialog.setSize(new Dimension(500, 300)); dialog.setLocationRelativeTo(null); dialog.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); dialog.setLayout(new MigLayout("fill, insets 0 0 0 0")); final String[] tableHeader = StringUtils.arrayOf("Id", "Time", "Priority", "Type", "To module", "Custom object"); Object[][] data = new Object[1][tableHeader.length]; DefaultTableModel model = new ClassAwareTableModel(); model.setDataVector(new Object[1][tableHeader.length], tableHeader); JTable table = new AdvancedJTable(model); RowSorter<TableModel> sorter = new TableRowSorter<TableModel>(model); table.setRowSorter(sorter); JScrollPane scrollPane = new JScrollPane(table); dialog.add(scrollPane, "grow"); PriorityQueue<SimEvent> futureEventList = simKernel.getSimCore().getFutureEventList().getPendingEvents(); if (!futureEventList.isEmpty()) { int numEvents = futureEventList.size(); SimEvent[] futureEventList_array = futureEventList.toArray(new SimEvent[numEvents]); Arrays.sort(futureEventList_array, futureEventList.comparator()); data = new Object[numEvents][tableHeader.length]; for (int eventId = 0; eventId < numEvents; eventId++) { // List<SimAction> actions = futureEventList_array[eventId].getEventActionList(); Object customObject = futureEventList_array[eventId].getEventObject(); data[eventId][0] = eventId; data[eventId][1] = StringUtils .secondsToYearsDaysHoursMinutesSeconds(futureEventList_array[eventId].getEventTime()); data[eventId][2] = futureEventList_array[eventId].getEventPriority(); data[eventId][3] = futureEventList_array[eventId].getEventType(); data[eventId][4] = futureEventList_array[eventId].getEventDestinationModule().toString(); data[eventId][5] = customObject == null ? "none" : customObject; } } model.setDataVector(data, tableHeader); table.getTableHeader().addMouseListener(new ColumnFitAdapter()); table.setDefaultRenderer(Double.class, new CellRenderers.NumberCellRenderer()); dialog.setVisible(true); }
From source file:sim.util.media.chart.ChartGenerator.java
/** Returns a JFrame suitable or housing the ChartGenerator. This frame largely calls chart.quit() when the JFrame is being closed. By default the JFrame will HIDE itself (not DISPOSE itself) when closed. If inspector == true, the frame will have the look of an inspector */ public JFrame createFrame(boolean inspector) { frame = new JFrame() { public void dispose() { quit();//w ww . j av a 2 s . co m super.dispose(); } }; if (inspector) frame.getRootPane().putClientProperty("Window.style", "small"); // on the Mac frame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); frame.getContentPane().setLayout(new BorderLayout()); frame.getContentPane().add(this, BorderLayout.CENTER); frame.setResizable(true); frame.pack(); frame.setTitle(chart.getTitle().getText()); return frame; }
From source file:edu.gmu.cs.sim.util.media.chart.ChartGenerator.java
/** Returns a JFrame suitable or housing the ChartGenerator. This frame largely calls chart.quit() when the JFrame is being closed. By default the JFrame will HIDE itself (not DISPOSE itself) when closed. If inspector == true, the frame will have the look of an inspector */ public JFrame createFrame(boolean inspector) { frame = new JFrame() { public void dispose() { quit();/* www. j a va 2s . c o m*/ super.dispose(); } }; if (inspector) { frame.getRootPane().putClientProperty("Window.style", "small"); // on the Mac } frame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); frame.getContentPane().setLayout(new BorderLayout()); frame.getContentPane().add(this, BorderLayout.CENTER); frame.setResizable(true); frame.pack(); frame.setTitle(chart.getTitle().getText()); return frame; }