?? helloworld.java
字號(hào):
//HelloWorld
import javax.swing.*;
import java.awt.*;
public class HelloWorld
{
public static void main(String[] args)
{
TextFrame frame = new TextFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.show();
}
}
class TextFrame extends JFrame
{
public TextFrame()
{
setTitle("HelloWorld");
setSize(WIDTH, HEIGHT);
//將panel加入到frame
TextPanel panel = new TextPanel();
Container contentPane = getContentPane();
contentPane.add(panel);
}
public static final int WIDTH = 300;
public static final int HEIGHT = 200;
}
class TextPanel extends JPanel
{
public void paintComponent(Graphics g)
{
super.paintComponent(g);
//顯示文本
g.drawString(" Hello, World!", x, y);
}
public int x = 100;
public int y = 100;
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -