本文整理汇总了Java中java.awt.event.WindowListener类的典型用法代码示例。如果您正苦于以下问题:Java WindowListener类的具体用法?Java WindowListener怎么用?Java WindowListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WindowListener类属于java.awt.event包,在下文中一共展示了WindowListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: open
import java.awt.event.WindowListener; //导入依赖的package包/类
public boolean open () {
dd = new DialogDescriptor(panel, NbBundle.getMessage(RevisionPicker.class, "LBL_RevisionPickerDialog.title"), //NOI18N
true, new Object[] { okButton, DialogDescriptor.CANCEL_OPTION }, okButton, DialogDescriptor.DEFAULT_ALIGN, new HelpCtx("org.netbeans.modules.git.ui.repository.RevisionPickerDialog"), null); //NOI18N
Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
updateDialogState();
browserPanel.addPropertyChangeListener(this);
Preferences prefs = GitModuleConfig.getDefault().getPreferences();
WindowListener windowListener = new DialogBoundsPreserver(prefs, this.getClass().getName());
dialog.addWindowListener(windowListener);
windowListener.windowOpened(new WindowEvent(dialog, WindowEvent.WINDOW_OPENED));
dialog.pack();
updateSliders(prefs);
dialog.setVisible(true);
persistSliders(prefs);
browserPanel.removePropertyChangeListener(this);
return dd.getValue() == okButton;
}
示例2: createDialog
import java.awt.event.WindowListener; //导入依赖的package包/类
private JDialog createDialog(Component parentComponent, String title,
int style)
throws HeadlessException {
final JDialog dialog;
Window window = JOptionPane.getWindowForComponent(parentComponent);
if (window instanceof Frame) {
dialog = new JDialog((Frame)window, title, true);
} else {
dialog = new JDialog((Dialog)window, title, true);
}
if (window instanceof SwingUtilities.SharedOwnerFrame) {
WindowListener ownerShutdownListener =
SwingUtilities.getSharedOwnerFrameShutdownListener();
dialog.addWindowListener(ownerShutdownListener);
}
initDialog(dialog, style, parentComponent);
return dialog;
}
示例3: Run
import java.awt.event.WindowListener; //导入依赖的package包/类
public Run(){//metodo costruttore del JFrame
WindowListener li = new WindowAdapter(){ //creo listener per controllare la pressione del pulsante di chiusura
@Override
public void windowClosing(WindowEvent e){//se il pulsante "x" è premuto, esco
System.exit(0);
}
};
GArduino g = new GArduino();//creo il JPanel GArduino
this.addWindowListener(li);//aggiungo il listener al JFrame
super.getContentPane().add(g);//aggiungo il JPanel al JFrame
this.setTitle("GArduino Controller");//imposto il titolo della finestra
super.setVisible(true);//imposto la visbilità
super.setResizable(false);//imposto la non possibilità di modificare le dimensioni della finestra
super.setSize(900,600);//imposto le dimensioni della finestra
super.setLocationRelativeTo(null);
}
示例4: addCloseCallback
import java.awt.event.WindowListener; //导入依赖的package包/类
/**
* Creates and registers a {@link WindowListener} to {@code parent} window, which causes
* the {@code child} window to close when the {@code parent} window is closed.
*
* @param parent
* the window whose closing will cause child to close as well.
* @param child
* the window that will be closed when parent is closed.
* @return the created listener
*/
public static WindowListener addCloseCallback( Window parent, Window child )
{
return addCloseCallback(
parent, () -> {
// Dispatch closing event instead of calling dispose() directly,
// so that event listeners are notified.
child.dispatchEvent(
new WindowEvent(
child,
WindowEvent.WINDOW_CLOSING
)
);
}
);
}
示例5: createFrame
import java.awt.event.WindowListener; //导入依赖的package包/类
/**
* Create a frame for SwingSet2 to reside in if brought up
* as an application.
*
* @param gc the gc
* @return the j frame
*/
public static JFrame createFrame(GraphicsConfiguration gc) {
JFrame frame = new JFrame(gc);
if (numSSs == 0) {
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
} else {
WindowListener l = new WindowAdapter() {
public void windowClosing(WindowEvent e) {
numSSs--;
swingSets.remove(this);
}
};
frame.addWindowListener(l);
}
//由Jack Jiang于2012-09-22加上,防止因JToolBar的大小而影响JFrame的prefereSize使得没法再缩小
frame.setMinimumSize(new Dimension(100,100));
return frame;
}
示例6: main
import java.awt.event.WindowListener; //导入依赖的package包/类
/**
* Creates a JFrame with a JCalendarDemo inside and can be used for testing.
*
* @param s
* The command line arguments
*/
public static void main(String[] s) {
WindowListener l = new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
};
JFrame frame = new JFrame("JCalendar Demo");
frame.addWindowListener(l);
JCalendarDemo demo = new JCalendarDemo();
demo.init();
frame.getContentPane().add(demo);
frame.pack();
frame.setBounds(200, 200,
(int) frame.getPreferredSize().getWidth() + 40, (int) frame
.getPreferredSize().getHeight() + 250);
frame.setVisible(true);
}
示例7: wireComponent
import java.awt.event.WindowListener; //导入依赖的package包/类
@Override
protected void wireComponent(final ComponentContext context) {
super.wireComponent(context);
final Window window = (Window) context.getComponent();
final MethodListenerProxy<WindowListener> windowListenerProxy = new MethodListenerProxy<WindowListener>(
WindowListener.class, context.getActionListeners());
final MethodListenerProxy<WindowFocusListener> windowFocusListenerProxy = new MethodListenerProxy<WindowFocusListener>(
WindowFocusListener.class, context.getActionListeners());
if (windowListenerProxy.hasListeningMethod()) {
window.addWindowListener(windowListenerProxy.getProxy());
LOGGER.debug("{}|Window.addWindowListener", context.getId());
}
if (windowFocusListenerProxy.hasListeningMethod()) {
window.addWindowFocusListener(windowFocusListenerProxy.getProxy());
LOGGER.debug("{}|Window.addWindowFocusListener", context.getId());
}
}
示例8: main
import java.awt.event.WindowListener; //导入依赖的package包/类
public static void main(String[] argv) {
JFrame f = new JFrame();
f.setSize(600, 400);
double[] values = new double[4];
String[] names = new String[3];
names[0] = "Item 1";
values[0] = 0.00100000000;
names[1] = "Very long Item 2";
values[1] = 0.00200000;
names[2] = "Item 3";
values[2] = 0.00200000000;
f.getContentPane().add(new HorizontalBarGraph(names, values, "Counts", "Stacked Horizontal Bar Graph Test"));
WindowListener wndCloser = new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
}
};
f.addWindowListener(wndCloser);
f.setVisible(true);
}
示例9: main
import java.awt.event.WindowListener; //导入依赖的package包/类
/**
* Creates a JFrame with a JCalendarDemo inside and can be used for testing.
*
* @param s
* The command line arguments
*/
public static void main(String[] s) {
WindowListener l = new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
}
};
JFrame frame = new JFrame("JCalendar Demo");
frame.addWindowListener(l);
JCalendarDemo demo = new JCalendarDemo();
demo.init();
frame.getContentPane().add(demo);
frame.pack();
frame.setBounds(200, 200,
(int) frame.getPreferredSize().getWidth() + 40, (int) frame
.getPreferredSize().getHeight() + 250);
frame.setVisible(true);
}
示例10: close
import java.awt.event.WindowListener; //导入依赖的package包/类
/**
* Overridden close method to avoid memory leaks by Mikael Valot
*/
public boolean close(){
if(super.close()){
dockableHolder.dispose();
dockableHolder.removeWindowFocusListener(this);
WindowListener[] listeners = dockableHolder.getWindowListeners();
for(int i=0;i<listeners.length;i++){
dockableHolder.removeWindowListener(listeners[i]);
}
Lm.setParent(null);
dockableHolder.removeAll();
dockableHolder.getRootPane().removeAll();
dockableHolder = null;
return true;
}
else{
return false;
}
}
示例11: createVncClientMainWindow
import java.awt.event.WindowListener; //导入依赖的package包/类
protected static Frame createVncClientMainWindow(BufferedImageCanvas canvas, String title, WindowListener windowListener) {
// Create AWT windows
Frame frame = new Frame(title + " - RDP");
// Use scrolling pane to support screens, which are larger than ours
scroller = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED);
scroller.add(canvas);
scroller.setSize(canvas.getWidth(), canvas.getHeight());
frame.add(scroller);
frame.pack();
frame.setVisible(true);
frame.addWindowListener(windowListener);
return frame;
}
示例12: main
import java.awt.event.WindowListener; //导入依赖的package包/类
public static void main(String args[]) {
CertUtil.init();
GridProxyInit gpiFrame = new GridProxyInit(null, true);
gpiFrame.setRunAsApplication(true);
gpiFrame.saveProxy(true);
WindowListener l = new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
};
gpiFrame.addWindowListener(l);
gpiFrame.pack();
UITools.center(null, gpiFrame);
gpiFrame.setVisible(true);
}
示例13: initVisualization
import java.awt.event.WindowListener; //导入依赖的package包/类
private static void initVisualization() {
visualization = new Visualization();
// Override default Exit Application listener -> enforce hide.
for(WindowListener wl: visualization.getWindowListeners()) {
visualization.removeWindowListener(wl);
}
visualization.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
dispose();
}
});
visualization.setVisible(true);
}
示例14: popupFrame
import java.awt.event.WindowListener; //导入依赖的package包/类
public static JFrame popupFrame(String title, String message, int width, int height, WindowListener listener) {
Color bg = Color.WHITE;
JFrame frame = new JFrame(title);
JLabel label = new JLabel(message);
label.setBackground(bg);
label.setBorder(BorderFactory.createBevelBorder(1));
label.setVerticalTextPosition(SwingConstants.TOP);
label.setHorizontalTextPosition(SwingConstants.RIGHT);
label.setOpaque(true);
frame.add(label);
frame.setBackground(bg);
frame.setSize(width, height);
frame.addWindowListener(listener);
frame.show();
return frame;
}
示例15: Main
import java.awt.event.WindowListener; //导入依赖的package包/类
/** Creates a new instance of Main */
public Main(String[] args) {
camera = ViewerManager.getInstance().createPerspectiveCamera(new GlobeNavigator(null));
WalkPerspectiveNavigationAdapter navigationAdapter = new WalkPerspectiveNavigationAdapter(camera);
camera.getCanvas().addKeyListener(navigationAdapter);
camera.getCanvas().addMouseListener(navigationAdapter);
camera.getCanvas().addMouseMotionListener(navigationAdapter);
camera.getCanvas().addMouseWheelListener(navigationAdapter);
if (camera instanceof WindowListener)
addWindowListener((WindowListener)camera);
Component graphic_view = camera.getGraphicsView();
graphic_view.setPreferredSize(new Dimension(800, 600));
this.getContentPane().add(graphic_view, BorderLayout.CENTER);
URL dataset = ApplicationUtils.extractDataset(args);
universe.setDataSet(dataset);
double [] vp = ApplicationUtils.extractViewpoint(args);
if (vp != null) {
camera.getNavigator().gotoViewpoint(vp[0], vp[1], vp[2], vp[3], vp[4]);
}
}