1
0

LS03-02-1 Nachbau FormAendern

This commit is contained in:
2021-05-27 18:00:28 +02:00
parent 4f3c638693
commit 5196764b00
3 changed files with 351 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
+281
View File
@@ -0,0 +1,281 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="TestGUI">
<grid id="27dc6" binding="panel1" default-binding="true" layout-manager="GridLayoutManager" row-count="16" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="719"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="b7dee" class="javax.swing.JButton" binding="rotButton" default-binding="true">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="115" height="25"/>
</grid>
</constraints>
<properties>
<text value="Rot"/>
</properties>
</component>
<component id="6db0a" class="javax.swing.JButton" binding="blauButton" default-binding="true">
<constraints>
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="115" height="25"/>
</grid>
</constraints>
<properties>
<text value="Blau"/>
</properties>
</component>
<component id="95a96" class="javax.swing.JButton" binding="gelbButton" default-binding="true">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="115" height="25"/>
</grid>
</constraints>
<properties>
<text value="Gelb"/>
</properties>
</component>
<component id="35e0c" class="javax.swing.JButton" binding="standardfarbeButton" default-binding="true">
<constraints>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="115" height="25"/>
</grid>
</constraints>
<properties>
<text value="Standardfarbe"/>
</properties>
</component>
<component id="6884b" class="javax.swing.JButton" binding="farbeWechselnButton" default-binding="true">
<constraints>
<grid row="3" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="115" height="25"/>
</grid>
</constraints>
<properties>
<text value="Farbe wählen"/>
</properties>
</component>
<component id="5b9ca" class="javax.swing.JButton" binding="gruenButton">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="115" height="25"/>
</grid>
</constraints>
<properties>
<text value="Grün"/>
</properties>
</component>
<component id="b29e8" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Aufgabe 1: Hintergrundfarbe ändern"/>
</properties>
</component>
<component id="812a0" class="javax.swing.JLabel">
<constraints>
<grid row="4" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Aufgabe 2: Text formatieren"/>
</properties>
</component>
<component id="836ed" class="javax.swing.JButton" binding="arialButton">
<constraints>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="115" height="25"/>
</grid>
</constraints>
<properties>
<text value="Arial"/>
</properties>
</component>
<component id="9c963" class="javax.swing.JButton" binding="comicSansButton">
<constraints>
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="115" height="25"/>
</grid>
</constraints>
<properties>
<text value="Comic Sans MS"/>
</properties>
</component>
<component id="f2e24" class="javax.swing.JButton" binding="courierNewButton">
<constraints>
<grid row="5" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="115" height="25"/>
</grid>
</constraints>
<properties>
<text value="Courier New"/>
</properties>
</component>
<component id="dc19c" class="javax.swing.JTextField" binding="hierBitteTextEingebenTextField" default-binding="true">
<constraints>
<grid row="6" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties>
<text value="Hier bitte Text eingeben"/>
</properties>
</component>
<component id="d64b9" class="javax.swing.JButton" binding="writeToLabelButton">
<constraints>
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="115" height="25"/>
</grid>
</constraints>
<properties>
<text value="ins Label schreiben"/>
</properties>
</component>
<component id="48eee" class="javax.swing.JButton" binding="clearLabelButton">
<constraints>
<grid row="7" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="115" height="25"/>
</grid>
</constraints>
<properties>
<text value="Text im Label löschen"/>
</properties>
</component>
<component id="78cba" class="javax.swing.JLabel">
<constraints>
<grid row="8" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Aufgabe 3: Schriftfarbe ändern"/>
</properties>
</component>
<component id="f55d4" class="javax.swing.JButton" binding="fontRedBtn">
<constraints>
<grid row="9" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="115" height="25"/>
</grid>
</constraints>
<properties>
<text value="Rot"/>
</properties>
</component>
<component id="a3ec7" class="javax.swing.JButton" binding="fontBlueBtn">
<constraints>
<grid row="9" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="115" height="25"/>
</grid>
</constraints>
<properties>
<text value="Blau"/>
</properties>
</component>
<component id="a333e" class="javax.swing.JButton" binding="fontBlackBtn">
<constraints>
<grid row="9" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="115" height="25"/>
</grid>
</constraints>
<properties>
<text value="Schwarz"/>
</properties>
</component>
<component id="ec0d0" class="javax.swing.JLabel">
<constraints>
<grid row="10" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Aufgabe 4: Schriftgröße verändern"/>
</properties>
</component>
<component id="ab3e9" class="javax.swing.JButton" binding="maxFontBtn">
<constraints>
<grid row="11" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="115" height="25"/>
</grid>
</constraints>
<properties>
<text value="+"/>
</properties>
</component>
<component id="13535" class="javax.swing.JButton" binding="minFontBtn">
<constraints>
<grid row="11" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="115" height="25"/>
</grid>
</constraints>
<properties>
<text value="-"/>
</properties>
</component>
<component id="1b72" class="javax.swing.JLabel">
<constraints>
<grid row="12" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Aufgabe 5: Textausrichtung"/>
</properties>
</component>
<component id="8a62f" class="javax.swing.JButton" binding="leftBtn">
<constraints>
<grid row="13" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="115" height="25"/>
</grid>
</constraints>
<properties>
<text value="linksbündig"/>
</properties>
</component>
<component id="d9c1" class="javax.swing.JButton" binding="centerBtn">
<constraints>
<grid row="13" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="115" height="25"/>
</grid>
</constraints>
<properties>
<text value="zentriert"/>
</properties>
</component>
<component id="43170" class="javax.swing.JButton" binding="rightBtn">
<constraints>
<grid row="13" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="115" height="25"/>
</grid>
</constraints>
<properties>
<text value="rechtsbündig"/>
</properties>
</component>
<component id="487e9" class="javax.swing.JLabel">
<constraints>
<grid row="14" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Aufgabe 6: Programm beenden"/>
</properties>
</component>
<component id="18a18" class="javax.swing.JButton" binding="exitBtn">
<constraints>
<grid row="15" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="115" height="60"/>
</grid>
</constraints>
<properties>
<text value="EXIT"/>
</properties>
</component>
<component id="e75b3" class="javax.swing.JLabel" binding="lblTextAnzeige">
<constraints>
<grid row="0" column="0" row-span="1" col-span="3" vsize-policy="7" hsize-policy="7" anchor="0" fill="0" indent="0" use-parent-layout="false">
<minimum-size width="422" height="100"/>
</grid>
</constraints>
<properties>
<text value="Dieser Text soll verändert werden"/>
</properties>
</component>
</children>
</grid>
</form>
+59
View File
@@ -0,0 +1,59 @@
import javax.swing.*;
import java.awt.*;
public class TestGUI {
private JPanel panel1;
private JButton rotButton;
private JButton gruenButton;
private JButton blauButton;
private JButton gelbButton;
private JButton standardfarbeButton;
private JButton farbeWechselnButton;
private JTextField hierBitteTextEingebenTextField;
private JButton arialButton;
private JButton comicSansButton;
private JButton courierNewButton;
private JButton writeToLabelButton;
private JButton clearLabelButton;
private JLabel lblTextAnzeige;
private JButton fontRedBtn;
private JButton fontBlueBtn;
private JButton fontBlackBtn;
private JButton maxFontBtn;
private JButton minFontBtn;
private JButton leftBtn;
private JButton centerBtn;
private JButton rightBtn;
private JButton exitBtn;
public TestGUI() {
rotButton.addActionListener(e -> panel1.setBackground(Color.red));
gruenButton.addActionListener(e -> panel1.setBackground(Color.green));
blauButton.addActionListener(e -> panel1.setBackground(Color.blue));
gelbButton.addActionListener(e -> panel1.setBackground(Color.yellow));
standardfarbeButton.addActionListener(e -> panel1.setBackground(null));
farbeWechselnButton.addActionListener(e -> panel1.setBackground(JColorChooser.showDialog(null, "Farbe auswählen", Color.white)));
arialButton.addActionListener(e -> lblTextAnzeige.setFont(new Font("Arial", Font.PLAIN, lblTextAnzeige.getFont().getSize())));
comicSansButton.addActionListener(e -> lblTextAnzeige.setFont(new Font("Comic Sans MS", Font.PLAIN, lblTextAnzeige.getFont().getSize())));
courierNewButton.addActionListener(e -> lblTextAnzeige.setFont(new Font("Courier New", Font.PLAIN, lblTextAnzeige.getFont().getSize())));
writeToLabelButton.addActionListener(e -> lblTextAnzeige.setText(hierBitteTextEingebenTextField.getText()));
clearLabelButton.addActionListener(e -> lblTextAnzeige.setText(""));
fontRedBtn.addActionListener(e -> lblTextAnzeige.setForeground(Color.red));
fontBlueBtn.addActionListener(e -> lblTextAnzeige.setForeground(Color.blue));
fontBlackBtn.addActionListener(e -> lblTextAnzeige.setForeground(Color.black));
maxFontBtn.addActionListener(e -> lblTextAnzeige.setFont(new Font(lblTextAnzeige.getFont().getName(), Font.PLAIN, lblTextAnzeige.getFont().getSize()+1)));
minFontBtn.addActionListener(e -> lblTextAnzeige.setFont(new Font(lblTextAnzeige.getFont().getName(), Font.PLAIN, lblTextAnzeige.getFont().getSize()-1)));
leftBtn.addActionListener(e -> lblTextAnzeige.setHorizontalAlignment(SwingConstants.LEFT));
centerBtn.addActionListener(e -> lblTextAnzeige.setHorizontalAlignment(SwingConstants.CENTER));
rightBtn.addActionListener(e -> lblTextAnzeige.setHorizontalAlignment(SwingConstants.RIGHT));
exitBtn.addActionListener(e -> System.exit(1));
}
public static void main(String[] args) {
JFrame frame = new JFrame("TestGUI");
frame.setContentPane(new TestGUI().panel1);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
}