當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。