Co-authored-by: Fastium <Fastium@users.noreply.github.com>
This commit is contained in:
parent
b8951031cd
commit
9a97e6dfbd
9
.vscode/launch.json
vendored
9
.vscode/launch.json
vendored
@ -1,5 +1,13 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"type": "java",
|
||||
"name": "Launch GUI1",
|
||||
"request": "launch",
|
||||
"mainClass": "GUI.GUI1",
|
||||
"projectName": "Lab15_OOP_90898795",
|
||||
"liveshare.allowGuestDebugControl": true
|
||||
},
|
||||
{
|
||||
"type": "java",
|
||||
"name": "Launch BankController",
|
||||
@ -10,3 +18,4 @@
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
@ -3,5 +3,7 @@
|
||||
"java.project.outputPath": "bin",
|
||||
"java.project.referencedLibraries": [
|
||||
"lib/**/*.jar"
|
||||
]
|
||||
],
|
||||
"liveshare.shareExternalFiles": false,
|
||||
"liveshare.allowGuestDebugControl": true
|
||||
}
|
||||
|
BIN
bin/GUI/ButtonListener.class
Normal file
BIN
bin/GUI/ButtonListener.class
Normal file
Binary file not shown.
BIN
bin/GUI/GUI1.class
Normal file
BIN
bin/GUI/GUI1.class
Normal file
Binary file not shown.
BIN
bin/GUI/GUI2.class
Normal file
BIN
bin/GUI/GUI2.class
Normal file
Binary file not shown.
64
src/GUI/GUI1.java
Normal file
64
src/GUI/GUI1.java
Normal file
@ -0,0 +1,64 @@
|
||||
package GUI;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import java.awt.AWTEvent;
|
||||
import java.awt.Color;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public class GUI1 extends JFrame {
|
||||
public static void main(String[] args) {
|
||||
GUI1 f1 = new GUI1();
|
||||
|
||||
|
||||
}
|
||||
|
||||
GUI1(){
|
||||
setTitle("Me");
|
||||
setSize(200,200);
|
||||
setLocation(600,200);
|
||||
|
||||
FlowLayout fl = new FlowLayout();
|
||||
this.setLayout(fl);
|
||||
|
||||
this.getContentPane().setBackground(Color.GREEN);
|
||||
|
||||
JButton jb1 = new JButton("Foo");
|
||||
JButton jb2 = new JButton("bar");
|
||||
|
||||
ButtonListener bl = new ButtonListener(this);
|
||||
jb1.addActionListener(bl);
|
||||
jb2.addActionListener(bl);
|
||||
|
||||
|
||||
this.add(jb1);
|
||||
this.add(jb2);
|
||||
|
||||
this.setVisible(true);
|
||||
|
||||
}
|
||||
}
|
||||
class ButtonListener implements ActionListener{
|
||||
JFrame f1;
|
||||
|
||||
ButtonListener(JFrame f1){
|
||||
this.f1 = f1;
|
||||
}
|
||||
|
||||
//change color from background
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e){
|
||||
if(f1.getContentPane().getBackground()==Color.GREEN) {
|
||||
f1.getContentPane().setBackground(Color.BLUE);
|
||||
}
|
||||
else {
|
||||
f1.getContentPane().setBackground(Color.GREEN);
|
||||
}
|
||||
|
||||
if (e.getActionCommand().contains("bar")) {
|
||||
f1.getContentPane().setBackground(Color.ORANGE);
|
||||
}
|
||||
}
|
||||
}
|
10
src/GUI/GUI2.java
Normal file
10
src/GUI/GUI2.java
Normal file
@ -0,0 +1,10 @@
|
||||
package GUI;
|
||||
|
||||
public class GUI2 {
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user