List of usage examples for java.awt.event WindowAdapter WindowAdapter
WindowAdapter
From source file:ScrollBarColorSelect.java
public ScrollBarColorSelect() { setTitle("ColorSelect"); setSize(300, 200);/* w w w . j a v a 2 s . c o m*/ addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); Container contentPane = getContentPane(); JPanel p = new JPanel(); p.setLayout(new GridLayout(3, 2, 3, 3)); p.add(redLabel = new JLabel("Red 0")); p.add(red = new JScrollBar(Adjustable.HORIZONTAL, 0, 0, 0, 255)); red.setBlockIncrement(16); red.addAdjustmentListener(this); p.add(greenLabel = new JLabel("Green 0")); p.add(green = new JScrollBar(Adjustable.HORIZONTAL, 0, 0, 0, 255)); green.setBlockIncrement(16); green.addAdjustmentListener(this); p.add(blueLabel = new JLabel("Blue 0")); p.add(blue = new JScrollBar(Adjustable.HORIZONTAL, 0, 0, 0, 255)); blue.setBlockIncrement(16); blue.addAdjustmentListener(this); contentPane.add(p, "South"); colorPanel = new JPanel(); colorPanel.setBackground(new Color(0, 0, 0)); contentPane.add(colorPanel, "Center"); }
From source file:TDialog.java
public TDialog(Frame f, String title, boolean modal) { super(f, title, modal); bCancel = false;/* www . j av a2 s. co m*/ addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { bCancel = true; } }); }
From source file:BezLab.java
BezLab() { setSize(500, 450);//w ww . ja v a 2 s . c o m addMouseListener(this); addMouseMotionListener(this); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); }
From source file:Main.java
public Main() throws Exception { super();/*w w w . ja v a2 s . com*/ ImageIcon ii = new ImageIcon(new URL("http://www.java2s.com/style/download.png")); GrabAndScrollLabel label = new GrabAndScrollLabel(ii); label.setPreferredSize(new Dimension(300, 300)); JScrollPane jsp = new JScrollPane(label); getContentPane().add(jsp); setSize(300, 250); setVisible(true); WindowListener l = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(l); }
From source file:GestureTest.java
public GestureTest() { super("Gesture Test"); setSize(200, 150);//from w w w .j av a 2 s. c o m addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { System.exit(0); } }); jl = new JList(items); jl.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); getContentPane().add(new JScrollPane(jl), BorderLayout.CENTER); ds = new DragSource(); DragGestureRecognizer dgr = ds.createDefaultDragGestureRecognizer(jl, DnDConstants.ACTION_COPY, this); setVisible(true); }
From source file:ColorChooserDemo.java
protected void createUI() { setSize(400, 400);//from w w w . j a v a 2 s . co m getContentPane().setLayout(new GridBagLayout()); JButton colorButton = new JButton("Choose a color..."); getContentPane().add(colorButton); colorButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { Color c = JColorChooser.showDialog(ColorChooserDemo.this, "Choose a color...", getBackground()); if (c != null) getContentPane().setBackground(c); } }); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { System.exit(0); } }); }
From source file:SingleChoiceMenu.java
public SingleChoiceMenu() { super("BasicTextEditor with JColorChooser"); setSize(450, 350);// w ww .ja va2 s .com fonts = new Font[FontName.length]; for (int k = 0; k < FontName.length; k++) fonts[k] = new Font(FontName[k], Font.PLAIN, 12); JMenuBar menuBar = createMenuBar(); setJMenuBar(menuBar); WindowListener wndCloser = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(wndCloser); setVisible(true); }
From source file:BoxLayoutTest.java
public BoxLayoutTest() { setTitle("BoxLayoutTest"); setSize(300, 300);// w w w . j av a2 s . com addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); horizontalBox = createBox(true, false); verticalBox = createBox(false, false); horizontalStrutsAndGlueBox = createBox(true, true); verticalStrutsAndGlueBox = createBox(false, true); JPanel panel = new JPanel(); panel.setLayout(new GridLayout(3, 1, 3, 3)); ButtonGroup directionGroup = new ButtonGroup(); horizontalButton = addRadioButton(panel, directionGroup, "Horizontal", true); verticalButton = addRadioButton(panel, directionGroup, "Vertical", false); strutsAndGlueCheckBox = addCheckBox(panel, "Struts and Glue"); Container contentPane = getContentPane(); contentPane.add(panel, "South"); contentPane.add(horizontalBox, "Center"); currentBox = horizontalBox; }
From source file:EditorDropTarget4.java
public static void main(String[] args) { try {//from ww w. j av a 2 s . c o m UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch (Exception evt) { } final JFrame f = new JFrame("JEditor Pane Drop Target Example 4"); // Create an editor with autoscrolling support final JEditorPane pane = new AutoScrollingEditorPane(); // Add a drop target to the JEditorPane EditorDropTarget4 target = new EditorDropTarget4(pane); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { System.exit(0); } }); JPanel panel = new JPanel(); final JCheckBox editable = new JCheckBox("Editable"); editable.setSelected(true); panel.add(editable); editable.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { pane.setEditable(editable.isSelected()); } }); final JCheckBox enabled = new JCheckBox("Enabled"); enabled.setSelected(true); panel.add(enabled); enabled.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { pane.setEnabled(enabled.isSelected()); } }); f.getContentPane().add(new JScrollPane(pane), BorderLayout.CENTER); f.getContentPane().add(panel, BorderLayout.SOUTH); f.setSize(500, 400); f.setVisible(true); }
From source file:ColorChooserMenu.java
public ColorChooserMenu() { super("Color Chooser Menu"); setSize(450, 350);//w ww . j a va 2s .c o m JMenuBar menuBar = createMenuBar(); setJMenuBar(menuBar); WindowListener wndCloser = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(wndCloser); setVisible(true); }