⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 textxy.java

📁 初期JAVA学习非常有用的资料。帮助深入了解API。特别是Applet。
💻 JAVA
字号:
/*  * Swing version. */import java.awt.*;import java.awt.event.*;import javax.swing.*;/*  * Very simple applet that illustrates parameters to text-drawing methods. */public class TextXY extends JApplet {    //Invoked only when executed as applet.    public void init() {        buildUI(getContentPane());    }    public void buildUI(Container container) {        TextPanel textPanel = new TextPanel();        container.add(textPanel, BorderLayout.CENTER);    }        class TextPanel extends JPanel {        public TextPanel() {            setPreferredSize(new Dimension(400, 100));        }        public void paintComponent(Graphics g) {            super.paintComponent(g);            g.drawString("drawString() at (2, 5)", 2, 5);            g.drawString("drawString() at (2, 30)", 2, 30);            g.drawString("drawString() at (2, height)", 2, getHeight());        }    }    //Invoked only when executed as application.    public static void main(String[] args) {        JFrame f = new JFrame("TextXY");        f.addWindowListener(new WindowAdapter() {            public void windowClosing(WindowEvent e) {                System.exit(0);            }        });        TextXY controller = new TextXY();        controller.buildUI(f.getContentPane());        f.pack();        f.setVisible(true);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -