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

📄 window.java

📁 由于想一次上传成功 所以将二个教程打包成了一个 这些例子几乎包含了所有java的框架集合
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;

public class window  
{
    public static void main(String [] args)
    {
       AppFrame f = new AppFrame();

       f.setSize(200, 200);

       f.addWindowListener(new WindowAdapter() { public void
           windowClosing(WindowEvent e) {System.exit(0);}});

       f.show();
    }
}

class AppFrame extends Frame implements ActionListener
{
    Button b1, b2;
    labelWindow window;

    AppFrame()
    {
        setLayout(new FlowLayout());
        b1 = new Button("Display the window");
        add(b1);
        b1.addActionListener(this);

        b2 = new Button("Hide the window");
        add(b2);
        b2.addActionListener(this);

        window = new labelWindow(this);
        window.setSize(300, 200);
        window.setLocation(300, 300);
    }

    public void actionPerformed(ActionEvent event)
    {
        if(event.getSource() == b1){
            window.setVisible(true);
        }
        if(event.getSource() == b2){
            window.setVisible(false);
        }
    }
}

class labelWindow extends Window {
    Label label;

    labelWindow(AppFrame af){
        super(af);
        setLayout(new FlowLayout());
        label = new Label("Hello from Java!");
        add(label);
    }

    public void paint (Graphics g)
    {
        int width = getSize().width;
        int height = getSize().height;

        g.drawRect(0, 0, --width, --height);
    }
}

⌨️ 快捷键说明

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