use of java.awt.event.WindowEvent in project sling by apache.
the class RequestAnalyzerWebConsole method showWindow.
private synchronized void showWindow() throws ServletException, IOException {
if (this.frame == null) {
final File toAnalyze = this.getLogFileCopy();
final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
MainFrame frame = new MainFrame(toAnalyze, Integer.MAX_VALUE, screenSize);
// exit the application if the main frame is closed
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
// remove the tmp file we showed
if (toAnalyze.exists()) {
toAnalyze.delete();
}
// clear the window reference
RequestAnalyzerWebConsole.this.frame = null;
}
});
this.frame = frame;
}
// make sure the window is visible, try to bring to the front
this.frame.setVisible(true);
this.frame.toFront();
}
use of java.awt.event.WindowEvent in project sling by apache.
the class Main method main.
public static void main(String[] args) throws IOException {
if (GraphicsEnvironment.isHeadless()) {
System.err.println("Cannot run in headless mode");
System.exit(1);
}
if (args.length == 0) {
System.err.println("Missing argument <file>");
System.exit(1);
}
File file = new File(args[0]);
if (!file.canRead()) {
System.err.println("Cannot read from file " + file);
System.exit(1);
}
final int limit;
if (args.length >= 2) {
limit = Integer.parseInt(args[1]);
} else {
limit = Integer.MAX_VALUE;
}
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
MainFrame frame = new MainFrame(file, limit, screenSize);
frame.setVisible(true);
// exit the application if the main frame is closed
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
use of java.awt.event.WindowEvent in project sling by apache.
the class RequestListSelectionListener method valueChanged.
public void valueChanged(ListSelectionEvent e) {
if (!e.getValueIsAdjusting()) {
ListSelectionModel lsm = (ListSelectionModel) e.getSource();
int idx = lsm.getMinSelectionIndex();
if (idx >= 0) {
try {
idx = table.getRowSorter().convertRowIndexToModel(idx);
TableModel tm = ((RequestTrackerFile) table.getModel()).getData(idx);
if (dataField == null) {
dataField = new JTable();
dataField.setAutoCreateRowSorter(true);
dataField.setGridColor(Color.GRAY);
dataField.setShowGrid(true);
dataField.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
dataField.setRowSelectionAllowed(true);
dataField.setTableHeader(new JTableHeader(dataField.getColumnModel()));
dataField.setFont(new Font("Monospaced", dataField.getFont().getStyle(), dataField.getFont().getSize()));
dataField.setShowHorizontalLines(false);
// dataField.setIntercellSpacing(new Dimension(3, 5));
JDialog d = new JDialog(this.parent);
d.add(new JScrollPane(dataField));
d.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
dataField = null;
}
});
// setup location and size and ensure updating preferences
Util.setupComponentLocationSize(d, REQUEST_X, REQUEST_Y, REQUEST_WIDTH, REQUEST_HEIGHT, (int) screenSize.getWidth() / 4, (int) screenSize.getHeight() / 4, (int) screenSize.getWidth() / 2, (int) screenSize.getHeight() / 2);
d.setVisible(true);
}
dataField.setModel(tm);
Util.setupColumnWidths(dataField.getColumnModel(), REQUEST_COLS);
} catch (IOException e1) {
// ignore
}
}
}
}
use of java.awt.event.WindowEvent in project JMRI by JMRI.
the class VSDecoderPane method setDecoder.
/**
* setDecoder()
*
* set the Decoder ID and update the soundsPanel
*/
public void setDecoder(VSDecoder dec) {
if (dec != null) {
// Store the new decoder
decoder_id = dec.getID();
log.debug("Decoder ID = " + decoder_id + " Decoder = " + dec);
// Register the decoder as a listener on our frame... so it can react
// to the window closing
parent.addWindowListener(new WindowListener() {
@Override
public void windowActivated(WindowEvent e) {
}
@Override
public void windowClosed(WindowEvent e) {
}
@Override
public void windowClosing(WindowEvent e) {
VSDecoderManager.instance().getVSDecoderByID(decoder_id).windowChange(e);
}
@Override
public void windowDeactivated(WindowEvent e) {
}
@Override
public void windowDeiconified(WindowEvent e) {
}
@Override
public void windowIconified(WindowEvent e) {
}
@Override
public void windowOpened(WindowEvent e) {
}
});
// Register ourselves as an event listener to the decoder
dec.addEventListener(new VSDecoderListener() {
@Override
public void eventAction(VSDecoderEvent e) {
decoderEventAction(e);
}
});
// Update the status bar
if (dec.getPosition() != null) {
statusBar.setMessage("Location: " + dec.getPosition().toString());
} else {
statusBar.setMessage("Location: unknown");
}
// Update the sounds pane
tabbedPane.remove(soundsPanel);
soundsPanel = new VSDSoundsPanel(decoder_id, this);
tabbedPane.addTab("Sounds", soundsPanel);
tabbedPane.revalidate();
tabbedPane.repaint();
}
}
use of java.awt.event.WindowEvent in project JMRI by JMRI.
the class EcosLocoToRoster method comboPanel.
// JComboBox combo;
public void comboPanel() {
frame.setTitle("Decoder Selection For Loco " + ecosLoco.getEcosDescription());
frame.getContentPane().setLayout(new BorderLayout());
JPanel topPanel = new JPanel();
JPanel p1 = new JPanel();
JPanel p2 = new JPanel();
JPanel p3 = this.layoutDecoderSelection();
// Create a panel to hold all other components
topPanel.setLayout(new BorderLayout());
//frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
//frame.setDefaultCloseOperation(frameclosed());
JLabel jLabel1 = new JLabel("Decoder installed can not be identified, please select from the list below");
JButton okayButton = new JButton("Okay");
p1.add(jLabel1);
p2.add(okayButton);
topPanel.add(p1);
topPanel.add(p3);
topPanel.add(p2);
topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.Y_AXIS));
frame.getContentPane().add(topPanel);
frame.pack();
frame.setVisible(true);
frame.toFront();
frame.setFocusable(true);
frame.setFocusableWindowState(true);
frame.requestFocus();
frame.setAlwaysOnTop(true);
frame.setAlwaysOnTop(false);
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
int w = frame.getSize().width;
int h = frame.getSize().height;
int x = (dim.width - w) / 2;
int y = (dim.height - h) / 2;
frame.setLocation(x, y);
frame.setVisible(true);
frame.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(WindowEvent winEvt) {
ecosManager.clearLocoToRoster();
}
});
ActionListener okayButtonAction = new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
okayButton();
}
};
okayButton.addActionListener(okayButtonAction);
}
Aggregations