Restore
This commit is contained in:
10
Labs/Lab11/Lab11_2230026071/Question1/.classpath
Normal file
10
Labs/Lab11/Lab11_2230026071/Question1/.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/Lab11/Lab11_2230026071/Question1/.project
Normal file
17
Labs/Lab11/Lab11_2230026071/Question1/.project
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Question1</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/Lab11/Lab11_2230026071/Question1/bin/MyFrame.class
Normal file
BIN
Labs/Lab11/Lab11_2230026071/Question1/bin/MyFrame.class
Normal file
Binary file not shown.
BIN
Labs/Lab11/Lab11_2230026071/Question1/bin/MyPanel$1.class
Normal file
BIN
Labs/Lab11/Lab11_2230026071/Question1/bin/MyPanel$1.class
Normal file
Binary file not shown.
BIN
Labs/Lab11/Lab11_2230026071/Question1/bin/MyPanel.class
Normal file
BIN
Labs/Lab11/Lab11_2230026071/Question1/bin/MyPanel.class
Normal file
Binary file not shown.
BIN
Labs/Lab11/Lab11_2230026071/Question1/bin/Start$1.class
Normal file
BIN
Labs/Lab11/Lab11_2230026071/Question1/bin/Start$1.class
Normal file
Binary file not shown.
BIN
Labs/Lab11/Lab11_2230026071/Question1/bin/Start.class
Normal file
BIN
Labs/Lab11/Lab11_2230026071/Question1/bin/Start.class
Normal file
Binary file not shown.
32
Labs/Lab11/Lab11_2230026071/Question1/src/MyFrame.java
Normal file
32
Labs/Lab11/Lab11_2230026071/Question1/src/MyFrame.java
Normal file
@@ -0,0 +1,32 @@
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.FlowLayout;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
public class MyFrame extends JFrame {
|
||||
public MyFrame() {
|
||||
//Auxiliary
|
||||
this.setTitle("My Frame Title");
|
||||
this.setSize(400, 300);
|
||||
this.setLocationRelativeTo(null);
|
||||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
this.setLayout(new BorderLayout());
|
||||
|
||||
//JPanel
|
||||
JPanel p = new JPanel();
|
||||
p.setLayout(new FlowLayout());
|
||||
this.add(p, BorderLayout.PAGE_START);
|
||||
JButton b1 = new JButton("left");
|
||||
JButton b2 = new JButton("right");
|
||||
p.add(b1);
|
||||
p.add(b2);
|
||||
|
||||
//MyPanel
|
||||
this.add(new MyPanel(), BorderLayout.CENTER);
|
||||
|
||||
//setVisible
|
||||
this.setVisible(true);
|
||||
}
|
||||
}
|
||||
19
Labs/Lab11/Lab11_2230026071/Question1/src/MyPanel.java
Normal file
19
Labs/Lab11/Lab11_2230026071/Question1/src/MyPanel.java
Normal file
@@ -0,0 +1,19 @@
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
public class MyPanel extends JPanel {
|
||||
public MyPanel() {
|
||||
//mouse listener
|
||||
this.addMouseListener(new MouseAdapter() { // Anonymous class.
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
//if left button clicked
|
||||
if(e.getButton() == MouseEvent.BUTTON1) {
|
||||
System.out.println("x: " + e.getX() + " y: " + e.getY());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
13
Labs/Lab11/Lab11_2230026071/Question1/src/Start.java
Normal file
13
Labs/Lab11/Lab11_2230026071/Question1/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