📄 textguione.java
字号:
public class TextGuiOne extends JFrame
{
private JFrame mainFrame;
private JButton messageButton;
private JButton clearButton;
private JButton exitButton;
private JTextField tField;
public TextGuiOne() // a constructor
{
mainFrame = new JFrame("The Hello Application-Ver.2.0");
// create all components
messageButton = new JButton("Message");
clearButton = new JButton("Clear");
exitButton = new JButton("Exit");
tField = new JTextField("Hello World!");
// get the content pane
Container c = mainFrame.getContentPane(); // Step 2 - first statement
// add the components to the ContentPane
c.add(tfield,BorderLayout.NORTH);
c.add(messageButton,BorderLayout.WEST);
c.add(clearButton,BorderLayout.CENTER);
c.add(exitButton,BorderLayout.EAST);
// create accelerator keys
messageButton.setMnemonic('M');
clearButton.setMnemonic('C');
exitButton.setMnemonic('x');
mainFrame.setSize(300,150);
// define and register window event handler
mainFrame.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e) {System.exit(0);}
});
mainFrame.show();
}
public static void main(String args[])
{
new TextGuiOne(); // instantiate a GUI object
}
} // end of class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -