Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Main.java
- package com.wikia.myscooll.awt;
- public class Main
- {
- static Rahmen_01 Fenster1 = new Rahmen_01("Fenster 1");
- static Rahmen_02 Fenster2 = new Rahmen_02("Fenster 2");
- static Rahmen_03 Fenster3 = new Rahmen_03("Fenster 3");
- static Basis_01 Panel1 = new Basis_01();
- static Basis_02 Panel2 = new Basis_02();
- static Basis_03 Panel3 = new Basis_03();
- static boolean Fenster1active = false;
- static boolean Fenster2active = false;
- static boolean Fenster3active = false;
- static int TotalWindowsDisplayed = 0;
- public static void main(String[] args)
- {
- Fenster1.add(Panel1);
- Fenster1.pack();
- Fenster1.setVisible(true);
- TotalWindowsDisplayed ++;
- Fenster1active = true;
- }
- }
- //ExitListener.java
- package com.wikia.myscooll.awt;
- import java.awt.event.WindowAdapter;
- import java.awt.event.WindowEvent;
- public class ExitListener extends WindowAdapter
- {
- @Override
- public void windowClosing(WindowEvent e)
- {
- System.exit(0);
- }
- }
- //Rahmen_01.java
- package com.wikia.myscooll.awt;
- import java.awt.Frame;
- public class Rahmen_01 extends Frame{
- Rahmen_01(String titel)
- {
- super(titel);
- addWindowListener(new ExitListener());
- }
- }
- //Rahmen_02.java
- package com.wikia.myscooll.awt;
- import java.awt.Frame;
- public class Rahmen_02 extends Frame
- {
- Rahmen_02(String titel)
- {
- super(titel);
- addWindowListener(new ExitListener());
- }
- }
- //Rahmen_03.java
- package com.wikia.myscooll.awt;
- import java.awt.Frame;
- public class Rahmen_03 extends Frame
- {
- Rahmen_03(String titel)
- {
- super(titel);
- addWindowListener(new ExitListener());
- }
- }
- //Basis_01.java
- package com.wikia.myscooll.awt;
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- public class Basis_01 extends Panel
- {
- private GridLayout LayoutBasis1 = new GridLayout(4,3);
- private GridLayout LayoutColorChoice = new GridLayout(1,3);
- private Panel PanelColorChoice = new Panel();
- static Label ColorOutput = new Label();
- static Label TextOutput = new Label();
- private Button ApplyColor = new Button("Einfaerben");
- private Button ApplyText = new Button("Text setzen");
- private TextField TextInput = new TextField();
- private CheckboxGroup ColorChoice = new CheckboxGroup();
- private Checkbox ColorChoiceRed = new Checkbox("Rot", ColorChoice, false);
- private Checkbox ColorChoiceGreen = new Checkbox("Gruen", ColorChoice, false);
- private Checkbox ColorChoiceBlue = new Checkbox("Blau", ColorChoice, false);
- private Checkbox WindowChoice1 = new Checkbox("Fenster 1", false);
- private Checkbox WindowChoice2 = new Checkbox("Fenster 2", false);
- private Checkbox WindowChoice3 = new Checkbox("Fenster 3", false);
- private Button AddWindow = new Button("Fenster Hinzufuegen");
- private Button RemoveWindow = new Button("Fenster Entfernen");
- Basis_01()
- {
- setLayout(LayoutBasis1);
- add(ApplyText);
- add(TextInput);
- add(TextOutput);
- add(ApplyColor);
- add(PanelColorChoice);
- PanelColorChoice.setLayout(LayoutColorChoice);
- PanelColorChoice.add(ColorChoiceRed);
- PanelColorChoice.add(ColorChoiceGreen);
- PanelColorChoice.add(ColorChoiceBlue);
- add(ColorOutput);
- add(WindowChoice1);
- add(WindowChoice2);
- add(WindowChoice3);
- add(AddWindow);
- add(RemoveWindow);
- ApplyText.addActionListener(new ApplyTextListener());
- AddWindow.addActionListener(new OpenWindowListener());
- RemoveWindow.addActionListener(new CloseWindowListener());
- ApplyColor.addActionListener(new ApplyColorListener());
- }
- private class ApplyTextListener implements ActionListener
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- if(WindowChoice1.getState() == true)Basis_01.TextOutput.setText(TextInput.getText());
- if(WindowChoice2.getState() == true)Basis_02.TextOutput.setText(TextInput.getText());
- if(WindowChoice3.getState() == true)Basis_03.TextOutput.setText(TextInput.getText());
- }
- }
- private class ApplyColorListener implements ActionListener
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- if(ColorChoiceRed.getState() == true)
- {
- if(WindowChoice1.getState() == true && Main.Fenster1active == true)Basis_01.ColorOutput.setBackground(Color.RED);
- if(WindowChoice2.getState() == true && Main.Fenster2active == true)Basis_02.ColorOutput.setBackground(Color.RED);
- if(WindowChoice3.getState() == true && Main.Fenster3active == true)Basis_03.ColorOutput.setBackground(Color.RED);
- }
- else if(ColorChoiceGreen.getState() == true)
- {
- if(WindowChoice1.getState() == true && Main.Fenster1active == true)Basis_01.ColorOutput.setBackground(Color.GREEN);
- if(WindowChoice2.getState() == true && Main.Fenster2active == true)Basis_02.ColorOutput.setBackground(Color.GREEN);
- if(WindowChoice3.getState() == true && Main.Fenster3active == true)Basis_03.ColorOutput.setBackground(Color.GREEN);
- }
- else if(ColorChoiceBlue.getState() == true)
- {
- if(WindowChoice1.getState() == true && Main.Fenster1active == true)Basis_01.ColorOutput.setBackground(Color.BLUE);
- if(WindowChoice2.getState() == true && Main.Fenster2active == true)Basis_02.ColorOutput.setBackground(Color.BLUE);
- if(WindowChoice3.getState() == true && Main.Fenster3active == true)Basis_03.ColorOutput.setBackground(Color.BLUE);
- }
- }
- }
- private class CloseWindowListener implements ActionListener
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- Main.Fenster1.removeAll();
- Main.Panel1.setEnabled(false);
- Main.Fenster1.dispose();
- Main.Fenster1active = false;
- Main.TotalWindowsDisplayed --;
- }
- }
- private class OpenWindowListener implements ActionListener
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- if(Main.TotalWindowsDisplayed == 3)System.out.println("");
- else if(Main.Fenster2active == false)
- {
- Main.Fenster2.add(Main.Panel2);
- Main.Fenster2.pack();
- Main.Fenster2.setVisible(true);
- Main.TotalWindowsDisplayed ++;
- Main.Fenster2active = true;
- Main.Panel2.setEnabled(true);
- }
- else if(Main.Fenster3active == false)
- {
- Main.Fenster3.add(Main.Panel3);
- Main.Fenster3.pack();
- Main.Fenster3.setVisible(true);
- Main.TotalWindowsDisplayed ++;
- Main.Fenster3active = true;
- Main.Panel3.setEnabled(true);
- }
- }
- }
- }
- //Basis_02.java
- package com.wikia.myscooll.awt;
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- public class Basis_02 extends Panel
- {
- private GridLayout LayoutBasis1 = new GridLayout(4,3);
- private GridLayout LayoutColorChoice = new GridLayout(1,3);
- private Panel PanelColorChoice = new Panel();
- static Label ColorOutput = new Label();
- static Label TextOutput = new Label();
- private Button ApplyColor = new Button("Einfaerben");
- private Button ApplyText = new Button("Text setzen");
- private TextField TextInput = new TextField();
- private CheckboxGroup ColorChoice = new CheckboxGroup();
- private Checkbox ColorChoiceRed = new Checkbox("Rot", ColorChoice, false);
- private Checkbox ColorChoiceGreen = new Checkbox("Gruen", ColorChoice, false);
- private Checkbox ColorChoiceBlue = new Checkbox("Blau", ColorChoice, false);
- private Checkbox WindowChoice1 = new Checkbox("Fenster 1", false);
- private Checkbox WindowChoice2 = new Checkbox("Fenster 2", false);
- private Checkbox WindowChoice3 = new Checkbox("Fenster 3", false);
- private Button AddWindow = new Button("Fenster Hinzufuegen");
- private Button RemoveWindow = new Button("Fenster Entfernen");
- Basis_02()
- {
- setLayout(LayoutBasis1);
- add(ApplyText);
- add(TextInput);
- add(TextOutput);
- add(ApplyColor);
- add(PanelColorChoice);
- PanelColorChoice.setLayout(LayoutColorChoice);
- PanelColorChoice.add(ColorChoiceRed);
- PanelColorChoice.add(ColorChoiceGreen);
- PanelColorChoice.add(ColorChoiceBlue);
- add(ColorOutput);
- add(WindowChoice1);
- add(WindowChoice2);
- add(WindowChoice3);
- add(AddWindow);
- add(RemoveWindow);
- ApplyText.addActionListener(new ApplyTextListener());
- AddWindow.addActionListener(new OpenWindowListener());
- RemoveWindow.addActionListener(new CloseWindowListener());
- ApplyColor.addActionListener(new ApplyColorListener());
- }
- private class ApplyTextListener implements ActionListener
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- if(WindowChoice1.getState() == true)Basis_01.TextOutput.setText(TextInput.getText());
- if(WindowChoice2.getState() == true)Basis_02.TextOutput.setText(TextInput.getText());
- if(WindowChoice3.getState() == true)Basis_03.TextOutput.setText(TextInput.getText());
- }
- }
- private class ApplyColorListener implements ActionListener
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- if(ColorChoiceRed.getState() == true)
- {
- if(WindowChoice1.getState() == true && Main.Fenster1active == true)Basis_01.ColorOutput.setBackground(Color.RED);
- if(WindowChoice2.getState() == true && Main.Fenster2active == true)Basis_02.ColorOutput.setBackground(Color.RED);
- if(WindowChoice3.getState() == true && Main.Fenster3active == true)Basis_03.ColorOutput.setBackground(Color.RED);
- }
- else if(ColorChoiceGreen.getState() == true)
- {
- if(WindowChoice1.getState() == true && Main.Fenster1active == true)Basis_01.ColorOutput.setBackground(Color.GREEN);
- if(WindowChoice2.getState() == true && Main.Fenster2active == true)Basis_02.ColorOutput.setBackground(Color.GREEN);
- if(WindowChoice3.getState() == true && Main.Fenster3active == true)Basis_03.ColorOutput.setBackground(Color.GREEN);
- }
- else if(ColorChoiceBlue.getState() == true)
- {
- if(WindowChoice1.getState() == true && Main.Fenster1active == true)Basis_01.ColorOutput.setBackground(Color.BLUE);
- if(WindowChoice2.getState() == true && Main.Fenster2active == true)Basis_02.ColorOutput.setBackground(Color.BLUE);
- if(WindowChoice3.getState() == true && Main.Fenster3active == true)Basis_03.ColorOutput.setBackground(Color.BLUE);
- }
- }
- }
- private class CloseWindowListener implements ActionListener
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- Main.Fenster2.removeAll();
- Main.Panel2.setEnabled(false);
- Main.Fenster2.dispose();
- Main.Fenster2active = false;
- Main.TotalWindowsDisplayed --;
- }
- }
- private class OpenWindowListener implements ActionListener
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- if(Main.TotalWindowsDisplayed == 3)System.out.println("");
- else if(Main.Fenster1active == false)
- {
- Main.Fenster1.add(Main.Panel1);
- Main.Fenster1.pack();
- Main.Fenster1.setVisible(true);
- Main.TotalWindowsDisplayed ++;
- Main.Fenster1active = true;
- Main.Panel1.setEnabled(true);
- }
- else if(Main.Fenster3active == false)
- {
- Main.Fenster3.add(Main.Panel3);
- Main.Fenster3.pack();
- Main.Fenster3.setVisible(true);
- Main.TotalWindowsDisplayed ++;
- Main.Fenster3active = true;
- Main.Panel3.setEnabled(true);
- }
- }
- }
- }
- //Basis_03.java
- package com.wikia.myscooll.awt;
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- public class Basis_03 extends Panel
- {
- private GridLayout LayoutBasis1 = new GridLayout(4,3);
- private GridLayout LayoutColorChoice = new GridLayout(1,3);
- private Panel PanelColorChoice = new Panel();
- static Label ColorOutput = new Label();
- static Label TextOutput = new Label();
- private Button ApplyColor = new Button("Einfaerben");
- private Button ApplyText = new Button("Text setzen");
- private TextField TextInput = new TextField();
- private CheckboxGroup ColorChoice = new CheckboxGroup();
- private Checkbox ColorChoiceRed = new Checkbox("Rot", ColorChoice, false);
- private Checkbox ColorChoiceGreen = new Checkbox("Gruen", ColorChoice, false);
- private Checkbox ColorChoiceBlue = new Checkbox("Blau", ColorChoice, false);
- private Checkbox WindowChoice1 = new Checkbox("Fenster 1", false);
- private Checkbox WindowChoice2 = new Checkbox("Fenster 2", false);
- private Checkbox WindowChoice3 = new Checkbox("Fenster 3", false);
- private Button AddWindow = new Button("Fenster Hinzufuegen");
- private Button RemoveWindow = new Button("Fenster Entfernen");
- Basis_03()
- {
- setLayout(LayoutBasis1);
- add(ApplyText);
- add(TextInput);
- add(TextOutput);
- add(ApplyColor);
- add(PanelColorChoice);
- PanelColorChoice.setLayout(LayoutColorChoice);
- PanelColorChoice.add(ColorChoiceRed);
- PanelColorChoice.add(ColorChoiceGreen);
- PanelColorChoice.add(ColorChoiceBlue);
- add(ColorOutput);
- add(WindowChoice1);
- add(WindowChoice2);
- add(WindowChoice3);
- add(AddWindow);
- add(RemoveWindow);
- ApplyText.addActionListener(new ApplyTextListener());
- AddWindow.addActionListener(new OpenWindowListener());
- RemoveWindow.addActionListener(new CloseWindowListener());
- ApplyColor.addActionListener(new ApplyColorListener());
- }
- private class ApplyTextListener implements ActionListener
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- if(WindowChoice1.getState() == true)Basis_01.TextOutput.setText(TextInput.getText());
- if(WindowChoice2.getState() == true)Basis_02.TextOutput.setText(TextInput.getText());
- if(WindowChoice3.getState() == true)Basis_03.TextOutput.setText(TextInput.getText());
- }
- }
- private class ApplyColorListener implements ActionListener
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- if(ColorChoiceRed.getState() == true)
- {
- if(WindowChoice1.getState() == true && Main.Fenster1active == true)Basis_01.ColorOutput.setBackground(Color.RED);
- if(WindowChoice2.getState() == true && Main.Fenster2active == true)Basis_02.ColorOutput.setBackground(Color.RED);
- if(WindowChoice3.getState() == true && Main.Fenster3active == true)Basis_03.ColorOutput.setBackground(Color.RED);
- }
- else if(ColorChoiceGreen.getState() == true)
- {
- if(WindowChoice1.getState() == true && Main.Fenster1active == true)Basis_01.ColorOutput.setBackground(Color.GREEN);
- if(WindowChoice2.getState() == true && Main.Fenster2active == true)Basis_02.ColorOutput.setBackground(Color.GREEN);
- if(WindowChoice3.getState() == true && Main.Fenster3active == true)Basis_03.ColorOutput.setBackground(Color.GREEN);
- }
- else if(ColorChoiceBlue.getState() == true)
- {
- if(WindowChoice1.getState() == true && Main.Fenster1active == true)Basis_01.ColorOutput.setBackground(Color.BLUE);
- if(WindowChoice2.getState() == true && Main.Fenster2active == true)Basis_02.ColorOutput.setBackground(Color.BLUE);
- if(WindowChoice3.getState() == true && Main.Fenster3active == true)Basis_03.ColorOutput.setBackground(Color.BLUE);
- }
- }
- }
- private class CloseWindowListener implements ActionListener
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- Main.Fenster3.removeAll();
- Main.Panel3.setEnabled(false);
- Main.Fenster3.dispose();
- Main.Fenster3active = false;
- Main.TotalWindowsDisplayed --;
- }
- }
- private class OpenWindowListener implements ActionListener
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- if(Main.TotalWindowsDisplayed == 3)System.out.println("");
- else if(Main.Fenster1active == false)
- {
- Main.Fenster1.add(Main.Panel1);
- Main.Fenster1.pack();
- Main.Fenster1.setVisible(true);
- Main.TotalWindowsDisplayed ++;
- Main.Fenster1active = true;
- Main.Panel1.setEnabled(true);
- }
- else if(Main.Fenster2active == false)
- {
- Main.Fenster2.add(Main.Panel2);
- Main.Fenster2.pack();
- Main.Fenster2.setVisible(true);
- Main.TotalWindowsDisplayed ++;
- Main.Fenster2active = true;
- Main.Panel2.setEnabled(true);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement