use of java.awt.event.WindowAdapter in project ACS by ACS-Community.
the class CDBAddNodeDlg method initComponents.
private void initComponents() {
GridBagConstraints gridBagConstraints;
curlLabel = new JLabel();
curlCtrl = new JTextField();
xmlDataCtrl = new JTextArea();
getContentPane().setLayout(new GridBagLayout());
setTitle("Add new node");
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent evt) {
closeDialog(evt);
}
});
curlLabel.setText("Curl:");
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.insets = new Insets(11, 11, 11, 11);
gridBagConstraints.anchor = GridBagConstraints.WEST;
getContentPane().add(curlLabel, gridBagConstraints);
curlCtrl.setBorder(new javax.swing.border.EtchedBorder());
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 0;
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new Insets(11, 11, 11, 11);
gridBagConstraints.weightx = 1.0;
getContentPane().add(curlCtrl, gridBagConstraints);
xmlDataCtrl.setBorder(new EtchedBorder());
xmlDataCtrl.setPreferredSize(new Dimension(400, 300));
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
gridBagConstraints.gridheight = GridBagConstraints.RELATIVE;
gridBagConstraints.fill = GridBagConstraints.BOTH;
gridBagConstraints.insets = new Insets(11, 11, 11, 11);
gridBagConstraints.anchor = GridBagConstraints.WEST;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
getContentPane().add(xmlDataCtrl, gridBagConstraints);
JPanel buttonsPanel = new JPanel();
buttonsPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
okBtn = new JButton();
cancelBtn = new JButton();
okBtn.addActionListener(this);
okBtn.setText("OK");
buttonsPanel.add(okBtn);
cancelBtn.addActionListener(this);
cancelBtn.setText("Cancel");
buttonsPanel.add(cancelBtn);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridwidth = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
getContentPane().add(buttonsPanel, gridBagConstraints);
setBounds(70, 70, 70, 70);
pack();
}
use of java.awt.event.WindowAdapter in project ACS by ACS-Community.
the class CDBBrowser method main.
public static void main(String[] args) {
CDBBrowser app = new CDBBrowser();
// test for IOR in cmd line
for (int i = 0; i < args.length; i++) {
if (args[i].equals("-d")) {
if (i < args.length - 1) {
app.setIOR(args[++i]);
}
}
if (args[i].equals("-h") || args[i].equals("-help")) {
System.out.println("Usage: cmd [-d ior -h|-help]");
return;
}
}
Frame frame = new Frame("CDB Browser");
frame.add(app);
frame.setSize(800, 600);
frame.setLocationRelativeTo(null);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
app.init();
app.start();
frame.setVisible(true);
}
use of java.awt.event.WindowAdapter in project ACS by ACS-Community.
the class Launcher method createFrame.
protected JFrame createFrame(String title) {
final JFrame ret = new JFrame(title);
ret.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
ret.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent evt) {
int answer = JOptionPane.showConfirmDialog(ret, "Really close Acs VmTools?", "Close Window", JOptionPane.YES_NO_OPTION);
if (answer == JOptionPane.YES_OPTION) {
ret.setVisible(false);
ret.dispose();
}
}
});
return ret;
}
use of java.awt.event.WindowAdapter in project jdk8u_jdk by JetBrains.
the class WindowsMenuBarUI method installWindowListener.
private void installWindowListener() {
if (windowListener == null) {
Component component = menuBar.getTopLevelAncestor();
if (component instanceof Window) {
window = (Window) component;
windowListener = new WindowAdapter() {
@Override
public void windowActivated(WindowEvent e) {
menuBar.repaint();
}
@Override
public void windowDeactivated(WindowEvent e) {
menuBar.repaint();
}
};
((Window) component).addWindowListener(windowListener);
}
}
}
use of java.awt.event.WindowAdapter in project jdk8u_jdk by JetBrains.
the class MultiResolutionTrayIconTest method createUI.
public static void createUI() throws Exception {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
mainFrame = new JFrame("TrayIcon Test");
boolean trayIsSupported = SystemTray.isSupported();
tray = SystemTray.getSystemTray();
Dimension d = tray.getTrayIconSize();
icon = new TrayIcon(createIcon(d.width, d.height));
icon.setImageAutoSize(true);
layout = new GridBagLayout();
mainControlPanel = new JPanel(layout);
resultButtonPanel = new JPanel(layout);
GridBagConstraints gbc = new GridBagConstraints();
String instructions = "<html>INSTRUCTIONS:<br>" + "Press start button to add icon to system tray.<br><br>" + "If Icon color is green test" + " passes else failed.<br><br></html>";
instructionText = new JLabel();
instructionText.setText(instructions);
gbc.gridx = 0;
gbc.gridy = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
mainControlPanel.add(instructionText, gbc);
startButton = new JButton("Start");
startButton.setActionCommand("Start");
if (trayIsSupported) {
startButton.addActionListener((ActionEvent e) -> {
doTest();
});
} else {
startButton.setEnabled(false);
System.out.println("system tray is not supported");
latch.countDown();
}
gbc.gridx = 0;
gbc.gridy = 0;
resultButtonPanel.add(startButton, gbc);
passButton = new JButton("Pass");
passButton.setActionCommand("Pass");
passButton.addActionListener((ActionEvent e) -> {
latch.countDown();
removeIcon();
mainFrame.dispose();
});
failButton = new JButton("Fail");
failButton.setActionCommand("Fail");
failButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
removeIcon();
latch.countDown();
mainFrame.dispose();
throw new RuntimeException("Test Failed");
}
});
gbc.gridx = 1;
gbc.gridy = 0;
resultButtonPanel.add(passButton, gbc);
gbc.gridx = 2;
gbc.gridy = 0;
resultButtonPanel.add(failButton, gbc);
gbc.gridx = 0;
gbc.gridy = 1;
mainControlPanel.add(resultButtonPanel, gbc);
mainFrame.add(mainControlPanel);
mainFrame.setSize(400, 200);
mainFrame.setLocationRelativeTo(null);
mainFrame.setVisible(true);
mainFrame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
removeIcon();
latch.countDown();
mainFrame.dispose();
}
});
}
});
}
Aggregations