diff --git a/.vscode/launch.json b/.vscode/launch.json index 5570fe5..991d31d 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -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", @@ -9,4 +17,5 @@ "vmArgs": "-enableassertions" } ] -} \ No newline at end of file +} + diff --git a/.vscode/settings.json b/.vscode/settings.json index e112a70..37d5d4a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,5 +3,7 @@ "java.project.outputPath": "bin", "java.project.referencedLibraries": [ "lib/**/*.jar" - ] + ], + "liveshare.shareExternalFiles": false, + "liveshare.allowGuestDebugControl": true } diff --git a/bin/GUI/ButtonListener.class b/bin/GUI/ButtonListener.class new file mode 100644 index 0000000..20094e9 Binary files /dev/null and b/bin/GUI/ButtonListener.class differ diff --git a/bin/GUI/GUI1.class b/bin/GUI/GUI1.class new file mode 100644 index 0000000..960e727 Binary files /dev/null and b/bin/GUI/GUI1.class differ diff --git a/bin/GUI/GUI2.class b/bin/GUI/GUI2.class new file mode 100644 index 0000000..2e298c9 Binary files /dev/null and b/bin/GUI/GUI2.class differ diff --git a/src/GUI/GUI1.java b/src/GUI/GUI1.java new file mode 100644 index 0000000..a484750 --- /dev/null +++ b/src/GUI/GUI1.java @@ -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); + } + } +} diff --git a/src/GUI/GUI2.java b/src/GUI/GUI2.java new file mode 100644 index 0000000..818ff5f --- /dev/null +++ b/src/GUI/GUI2.java @@ -0,0 +1,10 @@ +package GUI; + +public class GUI2 { + public static void main(String[] args) { + + } + + + +}