本文整理汇总了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);
}