Co-authored-by: Fastium <Fastium@users.noreply.github.com>

This commit is contained in:
Rémi Heredero 2022-05-05 14:40:19 +02:00
parent b8951031cd
commit 9a97e6dfbd
7 changed files with 87 additions and 2 deletions

9
.vscode/launch.json vendored
View File

@ -1,5 +1,13 @@
{ {
"configurations": [ "configurations": [
{
"type": "java",
"name": "Launch GUI1",
"request": "launch",
"mainClass": "GUI.GUI1",
"projectName": "Lab15_OOP_90898795",
"liveshare.allowGuestDebugControl": true
},
{ {
"type": "java", "type": "java",
"name": "Launch BankController", "name": "Launch BankController",
@ -10,3 +18,4 @@
} }
] ]
} }

View File

@ -3,5 +3,7 @@
"java.project.outputPath": "bin", "java.project.outputPath": "bin",
"java.project.referencedLibraries": [ "java.project.referencedLibraries": [
"lib/**/*.jar" "lib/**/*.jar"
] ],
"liveshare.shareExternalFiles": false,
"liveshare.allowGuestDebugControl": true
} }

Binary file not shown.

BIN
bin/GUI/GUI1.class Normal file

Binary file not shown.

BIN
bin/GUI/GUI2.class Normal file

Binary file not shown.

64
src/GUI/GUI1.java Normal file
View 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
View File

@ -0,0 +1,10 @@
package GUI;
public class GUI2 {
public static void main(String[] args) {
}
}