java.awt.Toolkit#addAWTEventListener ( )源码实例Demo

下面列出了java.awt.Toolkit#addAWTEventListener ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: haxademic   文件: ScreenSizeChangeTest.java
protected void firstFrame() {
	GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
	screenSize = ge.getMaximumWindowBounds();

	Toolkit toolkit = Toolkit.getDefaultToolkit();
	toolkit.addAWTEventListener(new AWTEventListener() {

		@Override
		public void eventDispatched(AWTEvent event) {
			// take a look at http://stackoverflow.com/questions/10123735/get-effective-screen-size-from-java
			
			Rectangle newSize = ge.getMaximumWindowBounds();
			if (newSize.width != screenSize.width || newSize.height != screenSize.height) {
				screenSize.setSize(newSize.width, newSize.height);
				resize();
			}
		}
	}, AWTEvent.PAINT_EVENT_MASK);

}
 
源代码2 项目: jadx   文件: MainWindow.java
private void registerMouseNavigationButtons() {
	Toolkit toolkit = Toolkit.getDefaultToolkit();
	toolkit.addAWTEventListener(event -> {
		if (event instanceof MouseEvent) {
			MouseEvent mouseEvent = (MouseEvent) event;
			if (mouseEvent.getID() == MouseEvent.MOUSE_PRESSED) {
				int rawButton = mouseEvent.getButton();
				if (rawButton <= 3) {
					return;
				}
				int button = remapMouseButton(rawButton);
				switch (button) {
					case 4:
						tabbedPane.navBack();
						break;
					case 5:
						tabbedPane.navForward();
						break;
				}
			}
		}
	}, AWTEvent.MOUSE_EVENT_MASK);
}
 
源代码3 项目: jdk1.8-source-analysis   文件: BasicLookAndFeel.java
public Object run() {
    Toolkit tk = Toolkit.getDefaultToolkit();
    if(invocator == null) {
        tk.addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK);
    } else {
        tk.removeAWTEventListener(invocator);
    }
    // Return value not used.
    return null;
}
 
源代码4 项目: hottub   文件: BasicLookAndFeel.java
public Object run() {
    Toolkit tk = Toolkit.getDefaultToolkit();
    if(invocator == null) {
        tk.addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK);
    } else {
        tk.removeAWTEventListener(invocator);
    }
    // Return value not used.
    return null;
}
 
源代码5 项目: dragonwell8_jdk   文件: BasicLookAndFeel.java
public Object run() {
    Toolkit tk = Toolkit.getDefaultToolkit();
    if(invocator == null) {
        tk.addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK);
    } else {
        tk.removeAWTEventListener(invocator);
    }
    // Return value not used.
    return null;
}
 
private DockingWindowsContextSensitiveHelpListener() {
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    AWTEventListener listener = new AWTEventListener() {            
        public void eventDispatched( AWTEvent event ) {
            DockingWindowManager.setMouseOverObject( event.getSource() );
        }
    }; 
    toolkit.addAWTEventListener( listener, AWTEvent.MOUSE_MOTION_EVENT_MASK );
}
 
源代码7 项目: TencentKona-8   文件: BasicLookAndFeel.java
public Object run() {
    Toolkit tk = Toolkit.getDefaultToolkit();
    if(invocator == null) {
        tk.addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK);
    } else {
        tk.removeAWTEventListener(invocator);
    }
    // Return value not used.
    return null;
}
 
源代码8 项目: openjdk-8   文件: BasicLookAndFeel.java
public Object run() {
    Toolkit tk = Toolkit.getDefaultToolkit();
    if(invocator == null) {
        tk.addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK);
    } else {
        tk.removeAWTEventListener(invocator);
    }
    // Return value not used.
    return null;
}
 
源代码9 项目: oim-fx   文件: RemoteControlFrame.java
private void initEvent() {

		class AWTEventListenerImpl implements AWTEventListener {
			@Override
			public void eventDispatched(AWTEvent event) {
				if (event.getClass() == KeyEvent.class) {
					// 被处理的事件是键盘事件.
					KeyEvent keyEvent = (KeyEvent) event;
					if (keyEvent.getID() == KeyEvent.KEY_PRESSED) {
						// 按下时你要做的事情
						keyPressed(keyEvent);
					} else if (keyEvent.getID() == KeyEvent.KEY_RELEASED) {
						// 放开时你要做的事情
						keyReleased(keyEvent);
					}
				}
			}

		}

		Toolkit tk = Toolkit.getDefaultToolkit();  
        tk.addAWTEventListener(new AWTEventListenerImpl(), AWTEvent.KEY_EVENT_MASK);  
        label.addMouseListener(new MouseAdapter() {
        	 public void mouseClicked(MouseEvent e) {
        		 panel.requestFocus();
        	 }
		});
	}
 
源代码10 项目: jdk8u60   文件: BasicLookAndFeel.java
public Object run() {
    Toolkit tk = Toolkit.getDefaultToolkit();
    if(invocator == null) {
        tk.addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK);
    } else {
        tk.removeAWTEventListener(invocator);
    }
    // Return value not used.
    return null;
}
 
源代码11 项目: JDKSourceCode1.8   文件: BasicLookAndFeel.java
public Object run() {
    Toolkit tk = Toolkit.getDefaultToolkit();
    if(invocator == null) {
        tk.addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK);
    } else {
        tk.removeAWTEventListener(invocator);
    }
    // Return value not used.
    return null;
}
 
源代码12 项目: openjdk-jdk8u   文件: BasicLookAndFeel.java
public Object run() {
    Toolkit tk = Toolkit.getDefaultToolkit();
    if(invocator == null) {
        tk.addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK);
    } else {
        tk.removeAWTEventListener(invocator);
    }
    // Return value not used.
    return null;
}
 
源代码13 项目: Bytecoder   文件: BasicLookAndFeel.java
public Object run() {
    Toolkit tk = Toolkit.getDefaultToolkit();
    if(invocator == null) {
        tk.addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK);
    } else {
        tk.removeAWTEventListener(invocator);
    }
    // Return value not used.
    return null;
}
 
源代码14 项目: openjdk-jdk9   文件: BasicLookAndFeel.java
public Object run() {
    Toolkit tk = Toolkit.getDefaultToolkit();
    if(invocator == null) {
        tk.addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK);
    } else {
        tk.removeAWTEventListener(invocator);
    }
    // Return value not used.
    return null;
}
 
源代码15 项目: jdk8u-dev-jdk   文件: BasicLookAndFeel.java
public Object run() {
    Toolkit tk = Toolkit.getDefaultToolkit();
    if(invocator == null) {
        tk.addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK);
    } else {
        tk.removeAWTEventListener(invocator);
    }
    // Return value not used.
    return null;
}
 
源代码16 项目: jdk8u-jdk   文件: BasicLookAndFeel.java
public Object run() {
    Toolkit tk = Toolkit.getDefaultToolkit();
    if(invocator == null) {
        tk.addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK);
    } else {
        tk.removeAWTEventListener(invocator);
    }
    // Return value not used.
    return null;
}
 
源代码17 项目: freehealth-connector   文件: PinPadPanelImpl.java
public PinPadPanelImpl() {
   this.setLayout((LayoutManager)null);
   Toolkit toolkit = this.getToolkit();
   toolkit.addAWTEventListener(new PinPadPanelImpl.KeyBoardAWTEventListener(), 8L);
   Font fntButton = new Font("Arial", 1, 35);
   Font fntLabel = new Font("Arial", 1, 12);
   Font fntField = new Font("Arial", 1, 35);
   Color clrGreen = new Color(128, 175, 60);
   Color clrRed = Color.red;
   Insets marginButton = new Insets(0, 0, 0, 0);
   this.add(this.createButton("1", fntButton, marginButton, new Rectangle(22, 126, 75, 50)));
   this.add(this.createButton("2", fntButton, marginButton, new Rectangle(104, 126, 75, 50)));
   this.add(this.createButton("3", fntButton, marginButton, new Rectangle(192, 126, 75, 50)));
   this.add(this.createButton("4", fntButton, marginButton, new Rectangle(22, 187, 75, 50)));
   this.add(this.createButton("5", fntButton, marginButton, new Rectangle(104, 187, 75, 50)));
   this.add(this.createButton("6", fntButton, marginButton, new Rectangle(192, 187, 75, 50)));
   this.add(this.createButton("7", fntButton, marginButton, new Rectangle(22, 250, 75, 50)));
   this.add(this.createButton("8", fntButton, marginButton, new Rectangle(104, 250, 75, 50)));
   this.add(this.createButton("9", fntButton, marginButton, new Rectangle(192, 250, 75, 50)));
   this.add(this.createButton("0", fntButton, marginButton, new Rectangle(22, 311, 75, 50)));
   this.add(this.createButton("<", fntButton, marginButton, new Rectangle(104, 311, 75, 50), new ActionListener() {
      public void actionPerformed(ActionEvent e) {
         PinPadPanelImpl.this.processBackspace();
      }
   }));
   this.btnGo = new JButton("GO");
   this.btnGo.setForeground(clrGreen);
   this.btnGo.setMargin(marginButton);
   this.btnGo.setFont(fntButton);
   this.btnGo.setBounds(192, 311, 75, 50);
   this.btnGo.setEnabled(false);
   this.add(this.btnGo);
   this.txtPassWord = new JPasswordField();
   this.txtPassWord.setHorizontalAlignment(0);
   this.txtPassWord.setFocusable(false);
   this.txtPassWord.setFont(fntField);
   this.txtPassWord.setText("");
   this.txtPassWord.setBorder(new LineBorder(Color.GRAY, 1, true));
   this.txtPassWord.setBounds(22, 65, 245, 50);
   this.add(this.txtPassWord);
   JLabel lblPinCode = new JLabel("Please enter your pincode to authenticate yourself.");
   lblPinCode.setFont(fntLabel);
   lblPinCode.setBounds(22, 40, 245, 14);
   this.add(lblPinCode);
   this.setFocusable(true);
   this.lblRetriesleft = new JLabel("Retries left: ");
   this.lblRetriesleft.setFont(fntLabel);
   this.lblRetriesleft.setForeground(clrRed);
   this.lblRetriesleft.setBounds(22, 15, 245, 14);
   this.lblRetriesleft.setVisible(false);
   this.add(this.lblRetriesleft);
}
 
源代码18 项目: freehealth-connector   文件: PinPadPanelImpl.java
public PinPadPanelImpl() {
   this.setLayout((LayoutManager)null);
   Toolkit toolkit = this.getToolkit();
   toolkit.addAWTEventListener(new PinPadPanelImpl.KeyBoardAWTEventListener(), 8L);
   Font fntButton = new Font("Arial", 1, 35);
   Font fntLabel = new Font("Arial", 1, 12);
   Font fntField = new Font("Arial", 1, 35);
   Color clrGreen = new Color(128, 175, 60);
   Color clrRed = Color.red;
   Insets marginButton = new Insets(0, 0, 0, 0);
   this.add(this.createButton("1", fntButton, marginButton, new Rectangle(22, 126, 75, 50)));
   this.add(this.createButton("2", fntButton, marginButton, new Rectangle(104, 126, 75, 50)));
   this.add(this.createButton("3", fntButton, marginButton, new Rectangle(192, 126, 75, 50)));
   this.add(this.createButton("4", fntButton, marginButton, new Rectangle(22, 187, 75, 50)));
   this.add(this.createButton("5", fntButton, marginButton, new Rectangle(104, 187, 75, 50)));
   this.add(this.createButton("6", fntButton, marginButton, new Rectangle(192, 187, 75, 50)));
   this.add(this.createButton("7", fntButton, marginButton, new Rectangle(22, 250, 75, 50)));
   this.add(this.createButton("8", fntButton, marginButton, new Rectangle(104, 250, 75, 50)));
   this.add(this.createButton("9", fntButton, marginButton, new Rectangle(192, 250, 75, 50)));
   this.add(this.createButton("0", fntButton, marginButton, new Rectangle(22, 311, 75, 50)));
   this.add(this.createButton("<", fntButton, marginButton, new Rectangle(104, 311, 75, 50), new ActionListener() {
      public void actionPerformed(ActionEvent e) {
         PinPadPanelImpl.this.processBackspace();
      }
   }));
   this.btnGo = new JButton("GO");
   this.btnGo.setForeground(clrGreen);
   this.btnGo.setMargin(marginButton);
   this.btnGo.setFont(fntButton);
   this.btnGo.setBounds(192, 311, 75, 50);
   this.btnGo.setEnabled(false);
   this.add(this.btnGo);
   this.txtPassWord = new JPasswordField();
   this.txtPassWord.setHorizontalAlignment(0);
   this.txtPassWord.setFocusable(false);
   this.txtPassWord.setFont(fntField);
   this.txtPassWord.setText("");
   this.txtPassWord.setBorder(new LineBorder(Color.GRAY, 1, true));
   this.txtPassWord.setBounds(22, 65, 245, 50);
   this.add(this.txtPassWord);
   JLabel lblPinCode = new JLabel("Please enter your pincode to authenticate yourself.");
   lblPinCode.setFont(fntLabel);
   lblPinCode.setBounds(22, 40, 245, 14);
   this.add(lblPinCode);
   this.setFocusable(true);
   this.lblRetriesleft = new JLabel("Retries left: ");
   this.lblRetriesleft.setFont(fntLabel);
   this.lblRetriesleft.setForeground(clrRed);
   this.lblRetriesleft.setBounds(22, 15, 245, 14);
   this.lblRetriesleft.setVisible(false);
   this.add(this.lblRetriesleft);
}
 
源代码19 项目: freehealth-connector   文件: PinPadPanelImpl.java
public PinPadPanelImpl() {
   this.setLayout((LayoutManager)null);
   Toolkit toolkit = this.getToolkit();
   toolkit.addAWTEventListener(new PinPadPanelImpl.KeyBoardAWTEventListener(null), 8L);
   Font fntButton = new Font("Arial", 1, 35);
   Font fntLabel = new Font("Arial", 1, 12);
   Font fntField = new Font("Arial", 1, 35);
   Color clrGreen = new Color(128, 175, 60);
   Color clrRed = Color.red;
   Insets marginButton = new Insets(0, 0, 0, 0);
   this.add(this.createButton("1", fntButton, marginButton, new Rectangle(22, 126, 75, 50)));
   this.add(this.createButton("2", fntButton, marginButton, new Rectangle(104, 126, 75, 50)));
   this.add(this.createButton("3", fntButton, marginButton, new Rectangle(192, 126, 75, 50)));
   this.add(this.createButton("4", fntButton, marginButton, new Rectangle(22, 187, 75, 50)));
   this.add(this.createButton("5", fntButton, marginButton, new Rectangle(104, 187, 75, 50)));
   this.add(this.createButton("6", fntButton, marginButton, new Rectangle(192, 187, 75, 50)));
   this.add(this.createButton("7", fntButton, marginButton, new Rectangle(22, 250, 75, 50)));
   this.add(this.createButton("8", fntButton, marginButton, new Rectangle(104, 250, 75, 50)));
   this.add(this.createButton("9", fntButton, marginButton, new Rectangle(192, 250, 75, 50)));
   this.add(this.createButton("0", fntButton, marginButton, new Rectangle(22, 311, 75, 50)));
   this.add(this.createButton("<", fntButton, marginButton, new Rectangle(104, 311, 75, 50), new ActionListener() {
      public void actionPerformed(ActionEvent e) {
         PinPadPanelImpl.this.processBackspace();
      }
   }));
   this.btnGo = new JButton("GO");
   this.btnGo.setForeground(clrGreen);
   this.btnGo.setMargin(marginButton);
   this.btnGo.setFont(fntButton);
   this.btnGo.setBounds(192, 311, 75, 50);
   this.btnGo.setEnabled(false);
   this.add(this.btnGo);
   this.txtPassWord = new JPasswordField();
   this.txtPassWord.setHorizontalAlignment(0);
   this.txtPassWord.setFocusable(false);
   this.txtPassWord.setFont(fntField);
   this.txtPassWord.setText("");
   this.txtPassWord.setBorder(new LineBorder(Color.GRAY, 1, true));
   this.txtPassWord.setBounds(22, 65, 245, 50);
   this.add(this.txtPassWord);
   JLabel lblPinCode = new JLabel("Please enter your pincode to authenticate yourself.");
   lblPinCode.setFont(fntLabel);
   lblPinCode.setBounds(22, 40, 245, 14);
   this.add(lblPinCode);
   this.setFocusable(true);
   this.lblRetriesleft = new JLabel("Retries left: ");
   this.lblRetriesleft.setFont(fntLabel);
   this.lblRetriesleft.setForeground(clrRed);
   this.lblRetriesleft.setBounds(22, 15, 245, 14);
   this.lblRetriesleft.setVisible(false);
   this.add(this.lblRetriesleft);
}
 
源代码20 项目: freehealth-connector   文件: PinPadPanelImpl.java
public PinPadPanelImpl() {
   this.setLayout((LayoutManager)null);
   Toolkit toolkit = this.getToolkit();
   toolkit.addAWTEventListener(new PinPadPanelImpl.KeyBoardAWTEventListener(null), 8L);
   Font fntButton = new Font("Arial", 1, 35);
   Font fntLabel = new Font("Arial", 1, 12);
   Font fntField = new Font("Arial", 1, 35);
   Color clrGreen = new Color(128, 175, 60);
   Color clrRed = Color.red;
   Insets marginButton = new Insets(0, 0, 0, 0);
   this.add(this.createButton("1", fntButton, marginButton, new Rectangle(22, 126, 75, 50)));
   this.add(this.createButton("2", fntButton, marginButton, new Rectangle(104, 126, 75, 50)));
   this.add(this.createButton("3", fntButton, marginButton, new Rectangle(192, 126, 75, 50)));
   this.add(this.createButton("4", fntButton, marginButton, new Rectangle(22, 187, 75, 50)));
   this.add(this.createButton("5", fntButton, marginButton, new Rectangle(104, 187, 75, 50)));
   this.add(this.createButton("6", fntButton, marginButton, new Rectangle(192, 187, 75, 50)));
   this.add(this.createButton("7", fntButton, marginButton, new Rectangle(22, 250, 75, 50)));
   this.add(this.createButton("8", fntButton, marginButton, new Rectangle(104, 250, 75, 50)));
   this.add(this.createButton("9", fntButton, marginButton, new Rectangle(192, 250, 75, 50)));
   this.add(this.createButton("0", fntButton, marginButton, new Rectangle(22, 311, 75, 50)));
   this.add(this.createButton("<", fntButton, marginButton, new Rectangle(104, 311, 75, 50), new ActionListener() {
      public void actionPerformed(ActionEvent e) {
         PinPadPanelImpl.this.processBackspace();
      }
   }));
   this.btnGo = new JButton("GO");
   this.btnGo.setForeground(clrGreen);
   this.btnGo.setMargin(marginButton);
   this.btnGo.setFont(fntButton);
   this.btnGo.setBounds(192, 311, 75, 50);
   this.btnGo.setEnabled(false);
   this.add(this.btnGo);
   this.txtPassWord = new JPasswordField();
   this.txtPassWord.setHorizontalAlignment(0);
   this.txtPassWord.setFocusable(false);
   this.txtPassWord.setFont(fntField);
   this.txtPassWord.setText("");
   this.txtPassWord.setBorder(new LineBorder(Color.GRAY, 1, true));
   this.txtPassWord.setBounds(22, 65, 245, 50);
   this.add(this.txtPassWord);
   JLabel lblPinCode = new JLabel("Please enter your pincode to authenticate yourself.");
   lblPinCode.setFont(fntLabel);
   lblPinCode.setBounds(22, 40, 245, 14);
   this.add(lblPinCode);
   this.setFocusable(true);
   this.lblRetriesleft = new JLabel("Retries left: ");
   this.lblRetriesleft.setFont(fntLabel);
   this.lblRetriesleft.setForeground(clrRed);
   this.lblRetriesleft.setBounds(22, 15, 245, 14);
   this.lblRetriesleft.setVisible(false);
   this.add(this.lblRetriesleft);
}