本文整理匯總了Java中javax.swing.JFrame.requestFocus方法的典型用法代碼示例。如果您正苦於以下問題:Java JFrame.requestFocus方法的具體用法?Java JFrame.requestFocus怎麽用?Java JFrame.requestFocus使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.JFrame
的用法示例。
在下文中一共展示了JFrame.requestFocus方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import javax.swing.JFrame; //導入方法依賴的package包/類
public static void main(String[] args) {
// Main method
Main m = new Main(); // Create the game object
Main.m = m;
frame = new JFrame("Game");
frame.setResizable(false);
frame.setUndecorated(true);
frame.add(m.canvas);
frame.pack();
frame.addWindowListener(m);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
frame.requestFocus();
m.start();
}
示例2: show
import javax.swing.JFrame; //導入方法依賴的package包/類
/** Make the frame visible, non-iconized, and focused. */
public static void show(JFrame frame) {
frame.setVisible(true);
frame.setExtendedState(frame.getExtendedState() & ~JFrame.ICONIFIED);
frame.requestFocus();
frame.toFront();
}
示例3: show
import javax.swing.JFrame; //導入方法依賴的package包/類
/** Make the frame visible, non-iconized, and focused. */
public static void show(JFrame frame) {
frame.setVisible(true);
frame.setExtendedState(frame.getExtendedState() & ~JFrame.ICONIFIED);
frame.requestFocus();
frame.toFront();
}
示例4: createAndShowGUI
import javax.swing.JFrame; //導入方法依賴的package包/類
private static void createAndShowGUI() {
frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JDesktopPane desktopPane = new JDesktopPane();
desktopPane.setBackground(DESKTOPPANE_COLOR);
internalFrame = new JInternalFrame("Test") {
@Override
public void paint(Graphics g) {
super.paint(g);
g.setColor(FRAME_COLOR);
g.fillRect(0, 0, getWidth(), getHeight());
}
};
internalFrame.setSize(WIN_WIDTH / 3, WIN_HEIGHT / 3);
internalFrame.setVisible(true);
desktopPane.add(internalFrame);
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.add(desktopPane, BorderLayout.CENTER);
frame.add(panel);
frame.setSize(WIN_WIDTH, WIN_HEIGHT);
frame.setVisible(true);
frame.requestFocus();
}