本文整理匯總了Java中javax.swing.JFrame.addMouseListener方法的典型用法代碼示例。如果您正苦於以下問題:Java JFrame.addMouseListener方法的具體用法?Java JFrame.addMouseListener怎麽用?Java JFrame.addMouseListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.JFrame
的用法示例。
在下文中一共展示了JFrame.addMouseListener方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: Game
import javax.swing.JFrame; //導入方法依賴的package包/類
/**
* Initialize the project.
*
* @param title The string on the window's title bar.
* @param width Width of the window
* @param height Height of the window
* @param tickRate Determines how fast the game loop is.
*/
public Game(String title, int width, int height, int tickRate) {
this.width = width;
this.height = height;
stack = new ArrayList<>();
this.maxTPS = tickRate;
frame = new JFrame(title);
frame.setSize(width, height);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);
frame.setResizable(false);
frame.setFocusable(true);
frame.addKeyListener(new InputListener());
frame.addMouseListener(new MouseInput());
}
示例2: prepareControls
import javax.swing.JFrame; //導入方法依賴的package包/類
protected void prepareControls() {
p = new JPanel(new GridLayout(0, 1));
propagateAWTControls(p);
b = new JButton("Space extender");
p.add(b);
p.setPreferredSize(new Dimension(500, 500));
scrollPane = new JScrollPane(p);
f = new JFrame();
f.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
frameClicked++;
}
});
f.getContentPane().add(scrollPane, BorderLayout.CENTER);
((JComponent) f.getContentPane()).setBorder(
BorderFactory.createEmptyBorder(50, 50, 50, 50));
f.setSize(400, 400);
f.setLocationRelativeTo(null);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
}
示例3: createHistogramFrame
import javax.swing.JFrame; //導入方法依賴的package包/類
public void createHistogramFrame() {
histogramFrame = new JFrame(histogramName);
histogramFrame.setPreferredSize(new Dimension(820, 620));
histogramFrame.getContentPane().setBackground(Color.white);
histogramCanvas = new HistGCanvas(histogram);
histogramFrame.getContentPane().add(histogramCanvas);
histoMouselistener = new HistogramMouselistener(histogramCanvas);
histogramFrame.addMouseListener(histoMouselistener);
histogramCanvas.addMouseListener(histoMouselistener);
histogramFrame.setVisible(true);
}
示例4: Listener
import javax.swing.JFrame; //導入方法依賴的package包/類
protected Listener(JFrame frame){
frame.addMouseMotionListener(this);
frame.addMouseListener(this);
}