javax.swing.JFrame.addWindowListener()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(299)

本文整理了Java中javax.swing.JFrame.addWindowListener()方法的一些代码示例,展示了JFrame.addWindowListener()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JFrame.addWindowListener()方法的具体详情如下:
包路径:javax.swing.JFrame
类名称:JFrame
方法名:addWindowListener

JFrame.addWindowListener介绍

暂无

代码示例

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

private static void createWindowForPanel(AwtPanel panel, int location){
  JFrame frame = new JFrame("Render Display " + location);
  frame.getContentPane().setLayout(new BorderLayout());
  frame.getContentPane().add(panel, BorderLayout.CENTER);
  frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  frame.addWindowListener(new WindowAdapter() {
    @Override
    public void windowClosed(WindowEvent e) {
      if (++panelsClosed == 2){
        app.stop();
      }
    }
  });
  frame.pack();
  frame.setLocation(location, Toolkit.getDefaultToolkit().getScreenSize().height - 400);
  frame.setVisible(true);
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

private static void createFrame(){
  frame = new JFrame("Test");
  frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  frame.addWindowListener(new WindowAdapter(){
    @Override
    public void windowClosed(WindowEvent e) {
      app.stop();
    }
  });
  createTabs();
  createMenu();
}

代码示例来源:origin: stackoverflow.com

private static JFrame frame = new JFrame();
  frame.setVisible(true);
  t.start();
  frame.addWindowListener(new WindowAdapter() {
        frame.setVisible(false);
        lock.notify();

代码示例来源:origin: 4thline/cling

protected MediaRendererController() {
  super(new JFrame(MediaRenderer.APPNAME), new MediaRendererLogCategories());
  getView().add(getLogPanel(), BorderLayout.CENTER);
  getView().addWindowListener(this);
  getView().pack();
  getView().setResizable(true);

代码示例来源:origin: wiztools/rest-client

@PostConstruct
public void show() {
  initJFC();
  
  frame.setContentPane(view.getContainer());
  createMenu();
  ImageIcon icon =
      UIUtil.getIconFromClasspath("org/wiztools/restclient/logo_30.png");
  frame.setIconImage(icon.getImage());
  frame.addWindowListener(new WindowAdapter() {
    @Override
    public void windowClosing(WindowEvent event){
      shutdownCall();
    }
  });
  frame.pack();
  frame.setLocationRelativeTo(null);
  frame.setVisible(true);
  
  // Update check:
  new Thread(ServiceLocator.getInstance(AppUpdateRunner.class)).start();
}

代码示例来源:origin: elki-project/elki

public void run() {
 assert (frame != null);
 frame.setVisible(true);
 frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
 frame.addWindowListener(new WindowAdapter() {
  @Override
  public void windowClosed(WindowEvent e) {
   stop();
  }
 });
 startLayoutThread();
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

public void run(){
    JFrame frame = new JFrame("Render Display");
    display = new ImageDisplay();
    display.setPreferredSize(new Dimension(width, height));
    frame.getContentPane().add(display);
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.addWindowListener(new WindowAdapter(){
      public void windowClosed(WindowEvent e){
        stop();
      }
    });
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setResizable(false);
    frame.setVisible(true);
  }
});

代码示例来源:origin: igniterealtime/Smack

JFrame window = new JFrame();
JPanel jp = new JPanel();
window.add(jp);
window.setSize(600, 600);
window.addWindowListener(new WindowAdapter() {
  @Override
  public void windowClosed(WindowEvent e) {
receiver.setVisible(true);
window.setAlwaysOnTop(true);
window.setVisible(true);

代码示例来源:origin: approvals/ApprovalTests.Java

/***********************************************************************/
 public static void testFrame(JFrame frame, WindowAdapter... array)
 {
  frame.pack();
  for (WindowAdapter closer : array)
  {
   frame.addWindowListener(closer);
  }
  WindowUtils.centerWindow(frame);
  frame.setVisible(true);
 }
}

代码示例来源:origin: haraldk/TwelveMonkeys

private static JFrame createWindow(final String pTitle) {
  JFrame frame = new JFrame(pTitle);
  frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
  frame.addWindowListener(new WindowAdapter() {
    public void windowClosed(WindowEvent e) {
      System.exit(0);
    }
  });
  return frame;
}

代码示例来源:origin: apache/shiro

methodPanel.add(secureMethod3Button);
frame = new JFrame("Apache Shiro Sample Application");
frame.setSize(500, 200);
Container panel = frame.getContentPane();
panel.setLayout(new BorderLayout());
panel.add(logo, BorderLayout.NORTH);
panel.add(valuePanel, BorderLayout.CENTER);
panel.add(methodPanel, BorderLayout.SOUTH);
frame.setVisible(true);
frame.addWindowListener(new WindowAdapter() {
  public void windowClosing(WindowEvent e) {
    System.exit(0);

代码示例来源:origin: fossasia/neurolab-desktop

content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
frame = new JFrame();
frame.setSize(400, 600);
frame.setLocationRelativeTo(null);
frame.addWindowListener(new WindowAdapter()
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

代码示例来源:origin: haraldk/TwelveMonkeys

private static JFrame createWindow(final String pTitle) {
  JFrame frame = new JFrame(pTitle);
  frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
  frame.addWindowListener(new WindowAdapter() {
    public void windowClosed(WindowEvent e) {
      System.exit(0);
    }
  });
  return frame;
}

代码示例来源:origin: kiegroup/optaplanner

return;
final JFrame exceptionFrame = new JFrame("Uncaught exception: " + e.getMessage());
Icon errorIcon = UIManager.getIcon("OptionPane.errorIcon");
BufferedImage errorImage = new BufferedImage(
exceptionFrame.setIconImage(errorImage);
exceptionFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
JPanel contentPanel = new JPanel(new BorderLayout(5, 5));
contentPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
contentPanel.add(new JLabel("An uncaught exception has occurred: "), BorderLayout.NORTH);
buttonPanel.add(exitApplicationButton);
contentPanel.add(buttonPanel, BorderLayout.SOUTH);
exceptionFrame.addWindowListener(new WindowAdapter() {
  @Override
  public void windowClosed(WindowEvent e) {
exceptionFrame.pack();
exceptionFrame.setLocationRelativeTo(null);
exceptionFrame.setVisible(true);

代码示例来源:origin: stackoverflow.com

JFrame f = new JFrame("Blah");
f.addWindowListener(new WindowAdapter() {
  public void windowClosing(WindowEvent e) {
    //do whatever you want before the window closes.
  }
});
f.setVisible(true);

代码示例来源:origin: stanfordnlp/CoreNLP

public static void main(String[] args) throws IOException {
 TreeJPanel tjp = new TreeJPanel();
 // String ptbTreeString1 = "(ROOT (S (NP (DT This)) (VP (VBZ is) (NP (DT a) (NN test))) (. .)))";
 String ptbTreeString = "(ROOT (S (NP (NNP Interactive_Tregex)) (VP (VBZ works)) (PP (IN for) (PRP me)) (. !))))";
 if (args.length > 0) {
  ptbTreeString = args[0];
 }
 Tree tree = (new PennTreeReader(new StringReader(ptbTreeString), new LabeledScoredTreeFactory(new StringLabelFactory()))).readTree();
 tjp.setTree(tree);
 tjp.setBackground(Color.white);
 JFrame frame = new JFrame();
 frame.getContentPane().add(tjp, BorderLayout.CENTER);
 frame.addWindowListener(new WindowAdapter() {
  @Override
  public void windowClosing(WindowEvent e) {
   System.exit(0);
  }
 });
 frame.pack();
 frame.setVisible(true);
 frame.setVisible(true);
}

代码示例来源:origin: stackoverflow.com

public static void main(String args[]) throws Exception {

  final JFrame oldFrame = new JFrame("Test");

  oldFrame.addWindowListener(new WindowAdapter() {
    @Override
    public void windowClosing(WindowEvent e) {
      JFrame newFrame = new JFrame("Test");
      newFrame.setBounds(oldFrame.getBounds());
      newFrame.setVisible(true);
    }
  });
  oldFrame.setSize(400, 300);
  oldFrame.setVisible(true);
}

代码示例来源:origin: igniterealtime/Smack

private void createDebug() {
  frame = new JFrame("Smack Debug Window");
    frame.addWindowListener(new WindowAdapter() {
      @Override
      public void windowClosing(WindowEvent evt) {
  frame.getContentPane().add(tabbedPane);
    frame.setVisible(true);

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

JFrame frame = new JFrame("Test");
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.addWindowListener(new WindowAdapter() {
  @Override
  public void windowClosing(WindowEvent e) {
frame.getContentPane().add(canvas);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
frame.getContentPane().remove(canvas);
frame.getContentPane().add(canvas);

代码示例来源:origin: marytts/marytts

public JFrame showInJFrame(String title, int width, int height, boolean allowZoom, boolean showControls, boolean exitOnClose) {
  final JFrame main = new JFrame(title);
  int mainWidth = width;
  JScrollPane scroll = new JScrollPane(this);
  main.getContentPane().add(scroll, BorderLayout.CENTER);
  final CursorDisplayer glass = new CursorDisplayer();
  main.setGlassPane(glass);
    JPanel zoomPanel = new JPanel();
    zoomPanel.setLayout(new BoxLayout(zoomPanel, BoxLayout.Y_AXIS));
    main.getContentPane().add(zoomPanel, BorderLayout.WEST);
    zoomPanel.add(Box.createVerticalGlue());
    JButton zoomIn = new JButton("Zoom In");
    main.addWindowListener(new java.awt.event.WindowAdapter() {
      public void windowClosing(java.awt.event.WindowEvent evt) {
        System.exit(0);
  main.setVisible(true);
  this.requestFocus();
  return main;

相关文章

JFrame类方法