开始学gui

This commit is contained in:
2024-06-21 17:53:48 +08:00
parent bb04a70eae
commit 0894537591
6 changed files with 89 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
package frameTest;
import java.awt.*;
public class Main {
public static void main(String[] args) {
// How to create a frame
// R stands for required
// 1.Create a Frame object R
Frame frame = new Frame("My first java gui frame");
// 2.set frame's visibility to true R
frame.setVisible(true);
// 3.set frame's width and height R
frame.setSize(680, 400);
// 4.set frame's background color
// 4-1.it need Color class
Color frameColor = new Color(0X39, 0XC5, 0XBB);
frame.setBackground(frameColor);
// 5.set frame's initial position
frame.setLocation(200, 200);
// 6.set frame can't be resized
frame.setResizable(false);
}
}
+10
View File
@@ -0,0 +1,10 @@
package mutiFrame;
public class Main {
//send to your homie to break your friendship lol
public static void main(String[] args) {
for (int i = 0; i < 114514; i++) {
new myFrame(String.valueOf(i));
}
}
}
+13
View File
@@ -0,0 +1,13 @@
package mutiFrame;
import java.awt.*;
public class myFrame extends Frame {
public myFrame(String title) {
super(title);
super.setVisible(true);
super.setBackground(new Color(0X39, 0XC5, 0XBB));
super.setSize(600, 400);
super.setResizable(false);
}
}