当前位置: 首页>>代码示例>>Java>>正文


Java JFrame.addWindowListener方法代码示例

本文整理汇总了Java中javax.swing.JFrame.addWindowListener方法的典型用法代码示例。如果您正苦于以下问题:Java JFrame.addWindowListener方法的具体用法?Java JFrame.addWindowListener怎么用?Java JFrame.addWindowListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JFrame的用法示例。


在下文中一共展示了JFrame.addWindowListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import javax.swing.JFrame; //导入方法依赖的package包/类
/**
 * Simple test case for the gradient painter
 * 
 * @param argv The arguments supplied at the command line
 */
public static void main(String[] argv) {
	JFrame frame = new JFrame();
	JPanel panel = new JPanel();
	panel.setBorder(BorderFactory.createTitledBorder("Gradient"));
	panel.setLayout(null);
	frame.setContentPane(panel);
		
	GradientEditor editor = new GradientEditor();
	editor.setBounds(10,15,270,100);
	panel.add(editor);
	frame.setSize(300,200);
	
	frame.addWindowListener(new WindowAdapter() {
		public void windowClosing(WindowEvent e) {
			System.exit(0);
		}
	});
	
	frame.setVisible(true);
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:26,代码来源:GradientEditor.java

示例2: main

import javax.swing.JFrame; //导入方法依赖的package包/类
public static void main(String[] args) {
    // Main method
    Main m = new Main(); // Create the game object
    Main.m = m;
    frame = new JFrame("Game");
    frame.setResizable(false);
    frame.setUndecorated(true);
    frame.add(m.canvas);
 
    frame.pack();
    frame.addWindowListener(m);

    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    frame.requestFocus();
    m.start();
}
 
开发者ID:ritcat14,项目名称:The-Mysterious-Mind-Of-Jack,代码行数:18,代码来源:Main.java

示例3: dispatch

import javax.swing.JFrame; //导入方法依赖的package包/类
/**
 * Description: dispatches the console from its current place properly.
 */
public static void  dispatch(JScrollPane scrollPane, JTextPane cons,
                             JTabbedPane outputTabs, Component tabComp, JFrame frame,
                             Boolean consoleOut, Attachable mainFrame) {
    frame.setSize(600, 400);
    frame.setLocationRelativeTo( (Component) mainFrame);
    frame.setLayout(new BorderLayout());
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    
    scrollPane.setViewportView(cons);
    frame.add(scrollPane);
    
    if (frame.getWindowListeners().length > 0)
        frame.removeWindowListener(frame.getWindowListeners()[0]);
    frame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            mainFrame.attachConsole();
        }
    });
    frame.setVisible(true);
}
 
开发者ID:bufferhe4d,项目名称:call-IDE,代码行数:25,代码来源:ConsoleCore.java

示例4: TableExample2

import javax.swing.JFrame; //导入方法依赖的package包/类
public TableExample2(String URL, String driver, String user,
        String passwd, String query) {
    JFrame frame = new JFrame("Table");
    frame.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
    JDBCAdapter dt = new JDBCAdapter(URL, driver, user, passwd);
    dt.executeQuery(query);

    // Create the table
    JTable tableView = new JTable(dt);

    JScrollPane scrollpane = new JScrollPane(tableView);
    scrollpane.setPreferredSize(new Dimension(700, 300));

    frame.getContentPane().add(scrollpane);
    frame.pack();
    frame.setVisible(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:TableExample2.java

示例5: onJFrameClose_Disconnect

import javax.swing.JFrame; //导入方法依赖的package包/类
public static void onJFrameClose_Disconnect(JFrame frame) {
	if(frame != null) {
		frame.addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				if(Server.isHosting() || Client.isConnected()) {
					if(Server.isHosting()) {
						Server.shutdown("");
					}else {
						Client.disconnect();
					}
				}
			}
		});
	}else {
		System.out.println("Can't add Window Event on a null JFrame.");
	}
}
 
开发者ID:giannismarinakis,项目名称:java-open-nl,代码行数:18,代码来源:ONLSettings.java

示例6: initLayerManager

import javax.swing.JFrame; //导入方法依赖的package包/类
protected void initLayerManager() {

		JFrame d = new JFrame();
		d.addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				((JCheckBoxMenuItem)(XML_Menu.commandToMenuItemHash.get("layer_manager_cmd"))).setSelected(false);
			}
		});
		LayerManager lm;
		
		//use existing layer manager if it already exists
		if (layerManager != null) {
			lm = layerManager;
		} else {
			lm = new LayerManager();
		}
		
		lm.setLayerList( toLayerList(map.overlays) );
		lm.setMap(map);

		lm.setDialog(d);
		JScrollPane sp = new JScrollPane(lm);
		sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
		d.setTitle("Layer Manager");
		d.setContentPane(sp);
//		d.getContentPane().add(sp);
		d.pack();
		d.setSize(new Dimension(lm.getPreferredSize().width+20,lm.getPreferredSize().height+55));
		d.setMaximumSize(new Dimension(400,300));

		d.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
		d.setLocationRelativeTo(frame);
		d.setState(Frame.NORMAL);
		d.setAlwaysOnTop(true);
		this.layerManager = lm;
		this.layerManagerDialog = d;	
	}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:38,代码来源:MapApp.java

示例7: main2

import javax.swing.JFrame; //导入方法依赖的package包/类
public static int main2(String[] args) {
    boolean isDebug = extractIsDebug(args);
    String dataDir = extractDataDir(args);

    LoggerHelper.initLogger(3, null, false, Mode.cmdline);

    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch(ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e1) {
        return 1;
    }

    DrivestrengthParameters params = new DrivestrengthParameters();

    JFrame runframe = new JFrame("ASGdrivestrength runner");
    RunDrivestrengthPanel runpanel = new RunDrivestrengthPanel(runframe, params, isDebug, false, false, dataDir);
    if(runpanel.hasErrorOccured()) {
        return 1;
    }
    runframe.getContentPane().add(runpanel);
    WatchForCloseWindowAdapter closeAdapter = new WatchForCloseWindowAdapter();
    runframe.addWindowListener(closeAdapter);
    runframe.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    runframe.pack();
    runframe.setLocationRelativeTo(null); //center
    runframe.setVisible(true);

    while(!closeAdapter.isClosed()) {
        try {
            Thread.sleep(1000);
        } catch(InterruptedException e) {
        }
    }
    return 0;
}
 
开发者ID:hpiasg,项目名称:asgdrivestrength,代码行数:36,代码来源:DrivestrengthRunMain.java

示例8: main

import javax.swing.JFrame; //导入方法依赖的package包/类
public static void main(String[] args) {
    final JFrame frame = new JFrame("Multistop Gradient Demo");
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            frame.dispose();
        }
    });
    frame.add(new MultiGradientTest());
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:13,代码来源:MultiGradientTest.java

示例9: WaitWindow

import javax.swing.JFrame; //导入方法依赖的package包/类
public WaitWindow(JFrame f) {
    f.addWindowListener(this);
    f.show();
    if (!shown) {
        synchronized(this) {
            try {
                //System.err.println("Waiting for window");
                wait(5000);
            } catch (Exception e) {}
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:RendererDisplayerTest.java

示例10: main

import javax.swing.JFrame; //导入方法依赖的package包/类
public static void main(String[] args) {

        B2Fit graph = new B2Fit();
        JFrame f = new JFrame();
        f.setSize(1000, 600);
        f.getContentPane().add(graph);
        f.setVisible(true);
        f.addWindowListener(SimulationGraphic.WINDOW_CLOSER);
        graph.dPlot.refresh();

    }
 
开发者ID:etomica,项目名称:etomica,代码行数:12,代码来源:B2Fit.java

示例11: main

import javax.swing.JFrame; //导入方法依赖的package包/类
public static void main(String[] args) {
	//新建窗体对象
	frame = new JFrame("2048");
	frame.setIconImage(new ImageIcon(MainPanel.class.getResource("gameicon.png")).getImage());
	//窗体大小
	frame.setSize(460, 680);
	//窗体居中
	frame.setLocationRelativeTo(null);
	//窗体大小不可变
	frame.setResizable(false);
	//默认的关闭操作
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	//新建主面板 对象
	mainPanel = new MainPanel(frame);
	//去掉面板默认布局
	mainPanel.setLayout(new FlowLayout(1, 200, 90));
	//面板背景颜色
	mainPanel.setBackground(new Color(247, 239, 230));
	//把面板添加到窗体中
	frame.add(mainPanel);
	//窗体可见
	frame.setVisible(true);
	//主界面的控制方法
	mainPanel.run();
	frame.addWindowListener(new WindowAdapter() {
		public void windowClosing(WindowEvent e) {
			try {
				mainPanel.getClassicPanel().saveScore();
				mainPanel.getClassicPanel().saveState();
				mainPanel.getDropPanel().updateTopScore();
			} catch (IOException e1) {
				e1.printStackTrace();
			}
		}
	});		
	
}
 
开发者ID:brandonbai,项目名称:game2048_tetris,代码行数:38,代码来源:Main.java

示例12: WaitWindow

import javax.swing.JFrame; //导入方法依赖的package包/类
public WaitWindow(JFrame f) {
    f.addWindowListener(this);
    f.show();
    if (!shown) {
        synchronized(this) {
            try {
                wait(5000);
            } catch (Exception e) {}
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:ComboTest.java

示例13: frameOpened

import javax.swing.JFrame; //导入方法依赖的package包/类
public void frameOpened(JFrame frame) {
	if (!listenerAdded) {
		frame.addWindowListener(myListener);
		listenerAdded = true;
	}
	addToManager();
	WindowMenuManager.setCurrentManager(this);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:9,代码来源:WindowMenuItemManager.java

示例14: CompositionArea

import javax.swing.JFrame; //导入方法依赖的package包/类
CompositionArea() {
    // create composition window with localized title
    String windowTitle = Toolkit.getProperty("AWT.CompositionWindowTitle", "Input Window");
    compositionWindow =
        (JFrame)InputMethodContext.createInputMethodWindow(windowTitle, null, true);

    setOpaque(true);
    setBorder(LineBorder.createGrayLineBorder());
    setForeground(Color.black);
    setBackground(Color.white);

    // if we get the focus, we still want to let the client's
    // input context handle the event
    enableInputMethods(true);
    enableEvents(AWTEvent.KEY_EVENT_MASK);

    compositionWindow.getContentPane().add(this);
    compositionWindow.addWindowListener(new FrameWindowAdapter());
    addInputMethodListener(this);
    compositionWindow.enableInputMethods(false);
    compositionWindow.pack();
    Dimension windowSize = compositionWindow.getSize();
    Dimension screenSize = (getToolkit()).getScreenSize();
    compositionWindow.setLocation(screenSize.width - windowSize.width-20,
                                screenSize.height - windowSize.height-100);
    compositionWindow.setVisible(false);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:28,代码来源:CompositionArea.java

示例15: main

import javax.swing.JFrame; //导入方法依赖的package包/类
public static void main(String[] args) {
  JFrame f = new JFrame();
  f.add(new PolygonEditor(null));
  f.setSize(500, 500);
  f.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
      System.exit(0);
    }
  });
  f.setVisible(true);
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:12,代码来源:PolygonEditor.java


注:本文中的javax.swing.JFrame.addWindowListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。