use of java.awt.event.WindowEvent in project JMRI by JMRI.
the class EditNodeFrame method cancelButtonActionPerformed.
/**
* Method to handle cancel button
*/
@Override
public void cancelButtonActionPerformed() {
// Reset
curNode = null;
// Switch buttons
editButton.setVisible(true);
cancelButton.setVisible(false);
this.dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
}
use of java.awt.event.WindowEvent in project jdk8u_jdk by JetBrains.
the class JOptionPane method initDialog.
private void initDialog(final JDialog dialog, int style, Component parentComponent) {
dialog.setComponentOrientation(this.getComponentOrientation());
Container contentPane = dialog.getContentPane();
contentPane.setLayout(new BorderLayout());
contentPane.add(this, BorderLayout.CENTER);
dialog.setResizable(false);
if (JDialog.isDefaultLookAndFeelDecorated()) {
boolean supportsWindowDecorations = UIManager.getLookAndFeel().getSupportsWindowDecorations();
if (supportsWindowDecorations) {
dialog.setUndecorated(true);
getRootPane().setWindowDecorationStyle(style);
}
}
dialog.pack();
dialog.setLocationRelativeTo(parentComponent);
final PropertyChangeListener listener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
// (newValue = null in that case). Otherwise, close the dialog.
if (dialog.isVisible() && event.getSource() == JOptionPane.this && (event.getPropertyName().equals(VALUE_PROPERTY)) && event.getNewValue() != null && event.getNewValue() != JOptionPane.UNINITIALIZED_VALUE) {
dialog.setVisible(false);
}
}
};
WindowAdapter adapter = new WindowAdapter() {
private boolean gotFocus = false;
public void windowClosing(WindowEvent we) {
setValue(null);
}
public void windowClosed(WindowEvent e) {
removePropertyChangeListener(listener);
dialog.getContentPane().removeAll();
}
public void windowGainedFocus(WindowEvent we) {
// Once window gets focus, set initial focus
if (!gotFocus) {
selectInitialValue();
gotFocus = true;
}
}
};
dialog.addWindowListener(adapter);
dialog.addWindowFocusListener(adapter);
dialog.addComponentListener(new ComponentAdapter() {
public void componentShown(ComponentEvent ce) {
// reset value to ensure closing works properly
setValue(JOptionPane.UNINITIALIZED_VALUE);
}
});
addPropertyChangeListener(listener);
}
use of java.awt.event.WindowEvent in project jdk8u_jdk by JetBrains.
the class KeyboardFocusManager method retargetFocusEvent.
static AWTEvent retargetFocusEvent(AWTEvent event) {
if (clearingCurrentLightweightRequests) {
return event;
}
KeyboardFocusManager manager = getCurrentKeyboardFocusManager();
if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
if (event instanceof FocusEvent || event instanceof WindowEvent) {
focusLog.finer(">>> {0}", String.valueOf(event));
}
if (focusLog.isLoggable(PlatformLogger.Level.FINER) && event instanceof KeyEvent) {
focusLog.finer(" focus owner is {0}", String.valueOf(manager.getGlobalFocusOwner()));
focusLog.finer(">>> {0}", String.valueOf(event));
}
}
synchronized (heavyweightRequests) {
/*
* This code handles FOCUS_LOST event which is generated by
* DefaultKeyboardFocusManager for FOCUS_GAINED.
*
* This code based on knowledge of DefaultKeyboardFocusManager's
* implementation and might be not applicable for another
* KeyboardFocusManager.
*
* Fix for 4472032
*/
if (newFocusOwner != null && event.getID() == FocusEvent.FOCUS_LOST) {
FocusEvent fe = (FocusEvent) event;
if (manager.getGlobalFocusOwner() == fe.getComponent() && fe.getOppositeComponent() == newFocusOwner) {
newFocusOwner = null;
return event;
}
}
}
processCurrentLightweightRequests();
switch(event.getID()) {
case FocusEvent.FOCUS_GAINED:
{
event = retargetFocusGained((FocusEvent) event);
break;
}
case FocusEvent.FOCUS_LOST:
{
event = retargetFocusLost((FocusEvent) event);
break;
}
default:
}
return event;
}
use of java.awt.event.WindowEvent in project JMRI by JMRI.
the class PaneProgAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
if (log.isDebugEnabled()) {
log.debug("Pane programmer requested");
}
// create the initial frame that steers
final JmriJFrame f = new JmriJFrame(SymbolicProgBundle.getMessage("FrameServiceProgrammerSetup"));
f.getContentPane().setLayout(new BoxLayout(f.getContentPane(), BoxLayout.Y_AXIS));
// ensure status line is cleared on close so it is normal if re-opened
f.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent we) {
statusLabel.setText(SymbolicProgBundle.getMessage("StateIdle"));
f.windowClosing(we);
}
});
// add the Roster menu
JMenuBar menuBar = new JMenuBar();
// menuBar.setBorder(new BevelBorder(BevelBorder.RAISED));
JMenu j = new JMenu(SymbolicProgBundle.getMessage("MenuFile"));
j.add(new jmri.jmrit.decoderdefn.PrintDecoderListAction(SymbolicProgBundle.getMessage("MenuPrintDecoderDefinitions"), f, false));
j.add(new jmri.jmrit.decoderdefn.PrintDecoderListAction(SymbolicProgBundle.getMessage("MenuPrintPreviewDecoderDefinitions"), f, true));
menuBar.add(j);
menuBar.add(new jmri.jmrit.roster.swing.RosterMenu(SymbolicProgBundle.getMessage("MenuRoster"), jmri.jmrit.roster.swing.RosterMenu.MAINMENU, f));
f.setJMenuBar(menuBar);
// new Loco on programming track
JPanel pane1 = new CombinedLocoSelTreePane(statusLabel, modePane) {
@Override
protected void startProgrammer(DecoderFile decoderFile, RosterEntry re, String filename) {
String title = java.text.MessageFormat.format(SymbolicProgBundle.getMessage("FrameServiceProgrammerTitle"), new Object[] { "new decoder" });
if (re != null) {
title = java.text.MessageFormat.format(SymbolicProgBundle.getMessage("FrameServiceProgrammerTitle"), new Object[] { re.getId() });
}
JFrame p = new PaneServiceProgFrame(decoderFile, re, title, "programmers" + File.separator + filename + ".xml", modePane.getProgrammer());
p.pack();
p.setVisible(true);
// f.setVisible(false);
// f.dispose();
}
};
// load primary frame
JPanel tempPane = new JPanel();
tempPane.add(modePane);
f.getContentPane().add(tempPane);
f.getContentPane().add(new JSeparator(javax.swing.SwingConstants.HORIZONTAL));
pane1.setAlignmentX(JLabel.CENTER_ALIGNMENT);
f.getContentPane().add(pane1);
f.getContentPane().add(new JSeparator(javax.swing.SwingConstants.HORIZONTAL));
statusLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);
f.getContentPane().add(statusLabel);
f.pack();
if (log.isDebugEnabled()) {
log.debug("Tab-Programmer setup created");
}
f.setVisible(true);
}
use of java.awt.event.WindowEvent in project processdash by dtuma.
the class TimeLogEditor method constructUserInterface.
/*
* methods for constructing the user interface
*/
private void constructUserInterface() {
loadCustomDimensions();
frame = new JFrame(getResource("Time_Log_Editor_Window_Title"));
DashboardIconFactory.setWindowIcon(frame);
frame.setSize(new Dimension(frameWidth, frameHeight));
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
confirmClose(true);
}
});
frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
PCSH.enableHelpKey(frame, "UsingTimeLogEditor");
splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, constructTreePanel(), constructEditPanel());
splitPane.setDividerLocation(dividerLocation);
// Setup drag-and-drop support on Java 6 and above
new FallbackObjectFactory<TimeLogEditorDragDropSetup>(TimeLogEditorDragDropSetup.class).add(//
"TimeLogEditorDragDropSetupJava6").get(true).setupEditorForDragDrop(this);
Container panel = frame.getContentPane();
panel.setLayout(new BorderLayout());
panel.add(BorderLayout.NORTH, constructFilterPanel());
panel.add(BorderLayout.CENTER, splitPane);
panel.add(BorderLayout.SOUTH, constructControlPanel());
createRecalcTimer();
}
Aggregations