Tabnine Logo
Window.addWindowListener
Code IndexAdd Tabnine to your IDE (free)

How to use
addWindowListener
method
in
java.awt.Window

Best Java code snippets using java.awt.Window.addWindowListener (Showing top 20 results out of 702)

Refine searchRefine arrow

  • Window.setVisible
  • Container.add
  • Window.pack
  • JFrame.<init>
  • JFrame.setDefaultCloseOperation
  • Window.setSize
origin: stackoverflow.com

 import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;
import javax.swing.WindowConstants;

public class test {

  public static void main(String[] args) {
    final JFrame frame = new JFrame("Test");
    frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    frame.addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent ev) {
        //frame.dispose();
      }
    });
    frame.setVisible(true);

  }

}
origin: stackoverflow.com

 import java.awt.*;
import java.awt.event.*;

class FrameByeBye {

  // The method we wish to call on exit.
  public static void showMessage() {
    System.out.println("Bye Bye!");
  }

  public static void main(String[] args) {
    Frame f = new Frame("Say Bye Bye!");
    f.addWindowListener( new WindowAdapter() {
      @Override
      public void windowClosing(WindowEvent we) {
        showMessage();
        System.exit(0);
      }
    } );
    f.setSize(300,200);
    f.setLocationByPlatform(true);
    f.setVisible(true);
  }
}
origin: camunda/camunda-bpm-platform

getContentPane().add(cp, BorderLayout.NORTH);
getContentPane().add(jsp, BorderLayout.CENTER);
addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent aEvent) {
      ExitAction.INSTANCE.actionPerformed(null);
pack();
setVisible(true);
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

public void setPalette(Window newValue) {
  if (palette != null) {
    palette.removeWindowListener(windowHandler);
  }
  
  palette = newValue;
  
  if (palette != null) {
    palette.addWindowListener(windowHandler);
    if (getValue(ActionUtil.SELECTED_KEY) == Boolean.TRUE) {
      app.addPalette(palette);
      palette.setVisible(true);
    } else {
      app.removePalette(palette);
      palette.setVisible(false);
    }
  }
}

origin: stackoverflow.com

public void run() {
  final JFrame f = new JFrame("Say Bye Bye!");
  f.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
  f.addWindowListener( new WindowAdapter() {
    @Override
    public void windowClosing(WindowEvent we) {
  f.setSize(300,200);
  f.setLocationByPlatform(true);
  f.setVisible(true);
origin: stackoverflow.com

 import java.awt.Frame;
import java.awt.Label;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class HowdyWindow extends Frame{
  public static void main(String arg[]){
  new HowdyWindow();
}
HowdyWindow() {
  Label label;
  label = new Label("Howdy!");
  add(label);
  pack();
  show();
  this.addWindowListener(new WindowAdapter() {
    @Override
    public void windowClosing(WindowEvent e) {
      processWindowEvent(e);
    }
  });

}
public void processWindowEvent(WindowEvent event) {
  if(event.getID() == WindowEvent.WINDOW_CLOSING)
    System.exit(0);
}
}
origin: stackoverflow.com

 import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class Graphics2dUmlaut extends Frame {
  public void paint(Graphics g) {
    Graphics2D g1 = (Graphics2D) g;
    g1.drawString("\u00fc\u00df", 100, 100);
  }

  public static void main(String args[]) {
    Frame frame = new Graphics2dUmlaut();
    frame.addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent we) {
        System.exit(0);
      }
    });
    frame.setSize(200, 200);
    frame.setVisible(true);
  }
}
origin: stackoverflow.com

 import java.awt.event.*;
import javax.swing.*;

public class ExitApp extends JFrame
{
  public ExitApp()
  {
   addWindowListener(new WindowAdapter()
   {
     public void windowClosing(WindowEvent e)
     {
      dispose();
      System.exit(0); //calling the method is a must
     }
   });
  }

  public static void main(String[] args)
  {
   ExitApp app=new ExitApp();
   app.setBounds(133,100,532,400);
   app.setVisible(true);
  }
}
origin: stackoverflow.com

go = new JButton("Do it");
go.addActionListener(this);
add(go);
JFrame frame = new JFrame("");
DemoJFileChooser panel = new DemoJFileChooser();
frame.addWindowListener(
 new WindowAdapter() {
  public void windowClosing(WindowEvent e) {
frame.getContentPane().add(panel,"Center");
frame.setSize(panel.getPreferredSize());
frame.setVisible(true);
origin: stackoverflow.com

 import java.awt.Color;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;



public class Test
{
  public static void main(String[] args)
  {
    Frame frame = new Frame("Title");
    frame.setSize(400, 400);
    frame.setLocationRelativeTo(null);
    frame.addWindowListener(new WindowAdapter() {
      @Override public void windowClosing(WindowEvent e) {
        System.exit(0);
      }
    });

    frame.setBackground(Color.BLUE);

    frame.setVisible(true);
  }
}
origin: stackoverflow.com

final JFrame f = new JFrame("Good Location & Size");
f.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
f.addWindowListener( new WindowAdapter() {
  public void windowClosing(WindowEvent we) {
    try {
f.add(ta);
f.pack();
  f.setLocationByPlatform(true);
f.setVisible(true);
origin: stackoverflow.com

setSize(400, 400);
setBackground(Color.red);
addWindowListener(new WindowAdapter() {
  public void windowClosing(WindowEvent we) {
    System.out.println(
  public void run() {
    System.out.println("Run: Window 1");
    (new Test11("Window 1")).setVisible(true);
    System.out.println("Run: Window 2");
    (new Test11("Window 2")).setVisible(true);
origin: stackoverflow.com

JFrame f = new JFrame("QuitStrategyTest");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.addWindowListener(new WindowAdapter() {
f.add(new JTextArea(getInfo()));
f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true);
origin: stackoverflow.com

JFrame frame = new JFrame();
frame.setTitle("Test Background");
frame.setLocation(200, 100);
frame.setSize(600, 400);
frame.addWindowListener(new WindowAdapter() {
frame.setVisible(true);
origin: stackoverflow.com

JFrame frame = new JFrame("DialogClosing");
mainPanel.add(new JButton(new MyAction(frame, JDialog.DISPOSE_ON_CLOSE, "DISPOSE_ON_CLOSE")));
mainPanel.add(new JButton(new MyAction(frame, JDialog.HIDE_ON_CLOSE, "HIDE_ON_CLOSE")));
mainPanel.add(new JButton(new MyAction(frame, JDialog.DO_NOTHING_ON_CLOSE, "DO_NOTHING_ON_CLOSE")));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(mainPanel);
frame.pack();
frame.setLocationByPlatform(true);
frame.setVisible(true);
dialog.setDefaultCloseOperation(defaultCloseOp);
dialog.setPreferredSize(new Dimension(300, 200));
dialog.pack();
dialog.addWindowListener(new WindowAdapter() {
  @Override
  public void windowClosed(WindowEvent e) {
origin: stackoverflow.com

final JFrame frame = new JFrame("Image zoom");
frame.getContentPane().add(zoomPanel);
final Ticker t = new Ticker(zoomPanel);
frame.addWindowListener(new WindowAdapter() {
  public void windowClosing(WindowEvent we) {
    t.done();
frame.pack();
frame.setVisible(true);
origin: stackoverflow.com

setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
addWindowListener(new WindowAdapter()
JPanel panProgressBars = new JPanel(new BorderLayout(0, 5));
panInputLabels.add(lblSource, BorderLayout.NORTH);
panInputLabels.add(lblTarget, BorderLayout.CENTER);
panInputFields.add(txtSource, BorderLayout.NORTH);
panInputFields.add(txtTarget, BorderLayout.CENTER);
panProgressLabels.add(lblProgressAll, BorderLayout.NORTH);
contentPane.add(panControls, BorderLayout.SOUTH);
pack();
setLocationRelativeTo(null);
  public void run()
    new FileCopierUtility().setVisible(true);
origin: stackoverflow.com

frame = new JFrame();
frame.addWindowListener(new FrameClose());
frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
frame.setSize(width * scale, height * scale);
frame.setVisible(true);
frame.add(canvas, 0);
origin: stackoverflow.com

private JFrame frame = new JFrame();
private static final long serialVersionUID = 1L;
private JMenuBar MenuBar;
  MenuBar = new JMenuBar();
  MenuBar.add(File);
  frame.addWindowListener(exitListener);
  frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
  frame.setJMenuBar(MenuBar);
  frame.setPreferredSize(new Dimension(400, 300));
  frame.setLocation(100, 100);
  frame.pack();
  frame.setVisible(true);
  SwingUtilities.invokeLater(new Runnable() {
  dialog.add(btn);
  dialog.add(btn1);
  dialog.setVisible(false);
  dialog.setAlwaysOnTop(true);
  JPanel pane = (JPanel) dialog.getContentPane();
  pane.setBorder(new EmptyBorder(10, 10, 10, 10));
  dialog.addWindowListener(closeListener);
  dialog.pack();
origin: stackoverflow.com

setSize(400, 300);
s.getViewport().add(m_tree);
getContentPane().add(s, BorderLayout.CENTER);
addWindowListener(wndCloser);
setVisible(true);
java.awtWindowaddWindowListener

Javadoc

Adds the specified window listener to receive window events from this window. If l is null, no exception is thrown and no action is performed.

Popular methods of Window

  • dispose
    Releases all of the native screen resources used by thisWindow, its subcomponents, and all of its ow
  • setVisible
  • setLocation
  • pack
    Causes this Window to be sized to fit the preferred size and layouts of its subcomponents. If the wi
  • getSize
  • getWidth
  • getHeight
  • setSize
  • setBounds
  • getBounds
  • removeWindowListener
    Removes the specified window listener so that it no longer receives window events from this window.
  • getGraphicsConfiguration
    This method returns the GraphicsConfiguration used by this Window.
  • removeWindowListener,
  • getGraphicsConfiguration,
  • isVisible,
  • addComponentListener,
  • getX,
  • getY,
  • toFront,
  • getLocation,
  • removeComponentListener

Popular in Java

  • Start an intent from android
  • getSharedPreferences (Context)
  • findViewById (Activity)
  • addToBackStack (FragmentTransaction)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • Path (java.nio.file)
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now