Restore
This commit is contained in:
28
Labs/Lab10/Lab10_2230026071/Question6/src/MyFrame.java
Normal file
28
Labs/Lab10/Lab10_2230026071/Question6/src/MyFrame.java
Normal file
@@ -0,0 +1,28 @@
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.GridLayout;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
public class MyFrame extends JFrame{
|
||||
//constructor
|
||||
public MyFrame() {
|
||||
this.setTitle("MyFrame Title");
|
||||
this.setSize(400, 300);
|
||||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
this.setLocationRelativeTo(null);
|
||||
|
||||
this.add(new MyPanel());
|
||||
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
}
|
||||
15
Labs/Lab10/Lab10_2230026071/Question6/src/MyPanel.java
Normal file
15
Labs/Lab10/Lab10_2230026071/Question6/src/MyPanel.java
Normal file
@@ -0,0 +1,15 @@
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
public class MyPanel extends JPanel{
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
//g.drawString("hello",20, 80);
|
||||
g.drawString("hello",
|
||||
(int)Math.round(Math.random() * this.getWidth()),
|
||||
(int)Math.round(Math.random() * this.getHeight()));
|
||||
}
|
||||
}
|
||||
13
Labs/Lab10/Lab10_2230026071/Question6/src/Start.java
Normal file
13
Labs/Lab10/Lab10_2230026071/Question6/src/Start.java
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
public class Start {
|
||||
|
||||
public static void main(String[] args) {
|
||||
javax.swing.SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
new MyFrame();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user