本帖最后由 x-joker 于 2020-10-31 21:06 编辑
[Java] 纯文本查看 复制代码
import javax.swing.*;
import java.awt.*;
public class MyFrame extends JFrame {
public MyFrame() {
this.add(new MyPanel());
this.setSize(80, 100);
}
class MyPanel extends JPanel {
public void paint(Graphics g) {
g.drawString("Hello, Java Applet World!", 10, 20);
}
}
public static void main(String[] args) {
MyFrame frame = new MyFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
JFrame和JPanel,一起用,你可以新建一个demo自己看下 |