当前位置: 首页>>代码示例>>Java>>正文


Java JFrame.setFocusable方法代码示例

本文整理汇总了Java中javax.swing.JFrame.setFocusable方法的典型用法代码示例。如果您正苦于以下问题:Java JFrame.setFocusable方法的具体用法?Java JFrame.setFocusable怎么用?Java JFrame.setFocusable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JFrame的用法示例。


在下文中一共展示了JFrame.setFocusable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
 
开发者ID:Vrekt,项目名称:Lunar,代码行数:27,代码来源:Game.java

示例2: telinha

import javax.swing.JFrame; //导入方法依赖的package包/类
public void telinha() {	
	janela = new JFrame();
	//janela.addMouseListener(this);
	//janela.setSize(img.getWidth(null), img.getHeight(null));
	JLabel background = new JLabel();
	ImageIcon icone = new ImageIcon(img);
	background.addMouseListener(this);
	background.setSize(img.getWidth(null), img.getHeight(null));
	background.setIcon(icone);
	janela.add(background);
	janela.setVisible(true);
	janela.setFocusable(true);
	janela.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);	
}
 
开发者ID:mundodehads,项目名称:cc-unespar,代码行数:15,代码来源:Mouse.java


注:本文中的javax.swing.JFrame.setFocusable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。