Restore
This commit is contained in:
10
Labs/Lab10/Lab10_2230026071/Question4/.classpath
Normal file
10
Labs/Lab10/Lab10_2230026071/Question4/.classpath
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
17
Labs/Lab10/Lab10_2230026071/Question4/.project
Normal file
17
Labs/Lab10/Lab10_2230026071/Question4/.project
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Question4</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
||||
BIN
Labs/Lab10/Lab10_2230026071/Question4/bin/MyFrame.class
Normal file
BIN
Labs/Lab10/Lab10_2230026071/Question4/bin/MyFrame.class
Normal file
Binary file not shown.
BIN
Labs/Lab10/Lab10_2230026071/Question4/bin/Start$1.class
Normal file
BIN
Labs/Lab10/Lab10_2230026071/Question4/bin/Start$1.class
Normal file
Binary file not shown.
BIN
Labs/Lab10/Lab10_2230026071/Question4/bin/Start.class
Normal file
BIN
Labs/Lab10/Lab10_2230026071/Question4/bin/Start.class
Normal file
Binary file not shown.
56
Labs/Lab10/Lab10_2230026071/Question4/src/MyFrame.java
Normal file
56
Labs/Lab10/Lab10_2230026071/Question4/src/MyFrame.java
Normal file
@@ -0,0 +1,56 @@
|
||||
import java.awt.BorderLayout;
|
||||
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.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);
|
||||
|
||||
//JButton b1 = new JButton("b1");
|
||||
this.add(new JButton("b1"), BorderLayout.LINE_START);
|
||||
//JButton b2 = new JButton("b2");
|
||||
this.add(new JButton("b2"), BorderLayout.LINE_END);
|
||||
|
||||
/*
|
||||
GridLayout g1 = new GridLayout(5, 5);
|
||||
this.setLayout(g1);
|
||||
*/
|
||||
//the program presents in 4*2 layout
|
||||
//the program did not use the specified rows and columns, because the lack numbers of components
|
||||
//the layout did not changed as the components are already parallel-aligned
|
||||
//if set number of rows = 0, it would auto ask new lines w.r.t. number of columns
|
||||
|
||||
BorderLayout bl = new BorderLayout();
|
||||
this.setLayout(bl);
|
||||
|
||||
JLabel l = new JLabel("Enter your name: ");
|
||||
this.add(l, BorderLayout.LINE_START);
|
||||
JTextField tx = new JTextField("Type Text Here");
|
||||
this.add(tx, BorderLayout.CENTER);
|
||||
JCheckBox cb = new JCheckBox("I agree");
|
||||
this.add(cb, BorderLayout.LINE_END);
|
||||
JRadioButton rb = new JRadioButton("Yes");
|
||||
this.add(rb, BorderLayout.AFTER_LINE_ENDS);
|
||||
JComboBox<String> cb1 = new JComboBox<String>(new String[]{"Red", "Green", "Blue"});
|
||||
this.add(cb1, BorderLayout.CENTER);
|
||||
JComboBox<Integer> cb2 = new JComboBox<Integer>(new Integer[]{2, 7, -3, 24});
|
||||
this.add(cb2, BorderLayout.LINE_END);
|
||||
//when add more than one component to one of the five areas of the frame, overlap would occurs
|
||||
//when one area does not contain any components, this area would vanished and replaced by the former component
|
||||
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
}
|
||||
13
Labs/Lab10/Lab10_2230026071/Question4/src/Start.java
Normal file
13
Labs/Lab10/Lab10_2230026071/Question4/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