From 7462d6ea4ab9dfd034bd4168553d54b347ab4780 Mon Sep 17 00:00:00 2001 From: Komlovski Date: Fri, 5 Jul 2019 19:51:10 +0200 Subject: [PATCH 1/2] BorderLayout --- Info Datei Nur für Alpha | 83 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 Info Datei Nur für Alpha diff --git a/Info Datei Nur für Alpha b/Info Datei Nur für Alpha new file mode 100644 index 0000000..4c33c0f --- /dev/null +++ b/Info Datei Nur für Alpha @@ -0,0 +1,83 @@ +Java AWT | BorderLayout Class +BorderLayout is the default layout for the window objects such as JFrame, JWindow, JDialog, JInternalFrame etc. BorderLayout arranges the components in the five regions. Four sides are referred to as north, south, east, and west. The middle part is called the center. Each region can contain only one component and is identified by a corresponding constant as NORTH, SOUTH, EAST, WEST, and CENTER. + +Constructors: + +BorderLayout(): It will construct a new borderlayout with no gaps between the components. +BorderLayout(int, int): It will constructs a border layout with the specified gaps between the components. +Commonly Used Methods: + +toString(): Returns a string which is representation of the state of border layout. +getLayoutAlignmentX(Container parent): Returns the layout alignment along the X-axis. +getLayoutAlignmentY(Container parent): It will returns the layout alignment along the Y-axis. +removeLayoutComponent(Component comp): This method is used to remove the specified component from the borderlayout. +getVgap(): Return the vertical gap between the components. +getHgap(): Returns the Horizontal gap between the components. +setHgap(int hgap): It is used to set the horizontal gap between the components. +setVgap(int vgap): It is used to set the vertical gap between the components. +Below Programs will illustrate the BorderLayout class: + +Program 1: The following program creates JButton components in a JFrame, whose instance class is “BorderLayoutDemo”. We create 5 JButton and then add them to the JFrame by using add() method. We will set the size and visibility of the frame by using setSize() and setVisible() method respectively. The layout is set by using the setLayout() method. +filter_none +brightness_4 +// Java program to illustrate the BorderLayout +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; + +// class extends JFrame +class BoderLayoutDemo extends JFrame { + + BoderLayoutDemo() + { + + // Creating Object of Jpanel class + JPanel pa = new JPanel(); + + // set the layout + pa.setLayout(new BorderLayout()); + + // add a new JButton with name "wel" and it is + // lie top of the container + pa.add(new JButton("WelCome"), BorderLayout.NORTH); + + // add a new JButton with name "come" and it is + // lie buttom of the container + pa.add(new JButton("Geeks"), BorderLayout.SOUTH); + + // add a new JButton with name "Layout" and it is + // lie left of the container + pa.add(new JButton("Layout"), BorderLayout.EAST); + + // add a new JButton with name "Border" and it is + // lie right of the container + pa.add(new JButton("Border"), BorderLayout.WEST); + + // add a new JButton with name "hello everybody" and it is + // lie center of the container + pa.add(new JButton("GeeksforGeeks"), BorderLayout.CENTER); + + // add the pa object which refer to the Jpanel + add(pa); + + // Function to close the operation of JFrame. + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + // Function to set size of JFrame. + setSize(300, 300); + + // Function to set visible status of JFrame. + setVisible(true); + } +} + +class MainFrame { + + // Driver code + public static void main(String[] args) + { + + // calling the constructor + new BoderLayoutDemo(); + } +} From 22c1ab13c5aeeb942fc6f02e0b3b88f36b74047d Mon Sep 17 00:00:00 2001 From: Hauch IT Date: Fri, 5 Jul 2019 19:52:52 +0200 Subject: [PATCH 2/2] Fenster wird um Auswahl Fenster erweitert --- .idea/workspace.xml | 86 +++++++++++++++--- out/production/Alpha/Main$1.class | Bin 160 -> 746 bytes .../Alpha/Main$ActionListener1.class | Bin 779 -> 779 bytes out/production/Alpha/Main.class | Bin 1911 -> 2792 bytes src/Main.java | 47 +++++++++- 5 files changed, 118 insertions(+), 15 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index f276c2f..2d581ad 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,7 +2,11 @@ - + + + + + - + - + @@ -219,14 +238,22 @@ - + @@ -276,13 +303,6 @@ - - - - - - - @@ -293,6 +313,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/out/production/Alpha/Main$1.class b/out/production/Alpha/Main$1.class index 060183ffe1b771166f0175e527f3ead66f497e64..02f2d5915608e7deb81e8cf5de2f33b1d88b511d 100644 GIT binary patch literal 746 zcmaJ6Spt9Ox>1!b>uiI=7K$I@jj8z*_%2^snai zeSzk%m@0uF(Ybnkd^Azzo}6Tibdw^L*}g2b^)G@=OD5pI%yU%^Gg(!N?p#e14#*wI z)aW9AtIBspd8DQSEB%^2mM11wGnJcoyDk~o`<9j9XwohJuS&q%Eso1n?Px2lZ3lg9 zH$uWuo@PbGwTzWHD5fqR_?X8-AD7|#Xv5=-vGOrEeyO zDm4PVI`pU3L{~;}VhhDyfkxj7U;O){2)LCp_KgG6FO)tRRhwD}vJ_Y=><4J;9-fty5da0|C-n^;B<*DNM; IEn5D50EMHPxBvhE delta 125 zcmaFGx`0vO)W2Q(7#J8#7`WLP*x4C4Cz~_sCUY?|u=yrt=BXGmGVplj<)s!m=Oh*v zrxr6Z2xKLeCFm#Hfiw#P8<6Ax OVlJQ>Mj*`~zySad$`xq< diff --git a/out/production/Alpha/Main$ActionListener1.class b/out/production/Alpha/Main$ActionListener1.class index eef8589b278d289527ab4cae376d4ec66d921ba0..26cb4b9a8985407565adf7e5c96823ffc5ccb8a3 100644 GIT binary patch delta 32 mcmeBX>t@?v$;22s*^0@AHIjjaA!>3plRJ=qn8}TafdK%783%X( delta 32 mcmeBX>t@?v$;7BJ*^0@ARfmCvL3eUBlRJ=qn8}SvfCB(|0S4Rv diff --git a/out/production/Alpha/Main.class b/out/production/Alpha/Main.class index 390ffe943d98236555d3a08a0cdc2b69e6012d3f..e2ebe7aed87be9bc396ac701274c3ad2b0341cde 100644 GIT binary patch literal 2792 zcmZuzTX!4P75-Tpv|OaM&{{mRSUk3`@B{kN*Y=^S-=0x|6x&|2kIugDv%j-v zKL6h*p8~iA@9Ve|r9RA|ETkgD67rak6(Oq{>;%?yB=ES9s)m{l10~rw8r%fV=ok>8 zf$wPW5~%AKlKlXD4GkTmI4hiU8rF4;hn7!hIG@0Gb?gw$aeOaE^BhY9>BfeWJlw1yw+m=ZrzviXUQ9G($PM);|YSv-@#vkCl6{5~gXKG%nz zbDdYP1})#OA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zj~l*#a2j&E}xfr-1gj?;3KH|+p9v)s#HE?oW(1irGF delta 768 zcmZ9K*-{fx5Qe`=fSC-Z2t<~W(vk>7L?wb7xC0U)CIW5ZL>$haf5q;gdVuPn9&lJyjAqot;zF&y9 zOca*=xunTU#VZ!WuF5^tRpoKI4H`PauaU;hnaUv}jGFVKDf!P(C7&oFh!&;HqDz@Y znlg(zWfp;iBN+0SKEcyqWT_Mjeuf{+FS{$YNOry>BE0`iIrog<6pi6}Y`pZ1ef*$> zvl3I=Rh;9zcrh+;al0dVxgjF4y0^3@+O}x_L~8Oq2Xg-!))1A1R#}WTYGo62!^Z6* j`WXPdSF%Jq;YsnI(I7H+xI_80I diff --git a/src/Main.java b/src/Main.java index 4b45221..cf01735 100644 --- a/src/Main.java +++ b/src/Main.java @@ -26,7 +26,52 @@ public class Main { this.contantPane = new JPanel(); this.fr.setContentPane(contantPane); - this.contantPane.add(new JLabel("Beispiel JLabel")); + this.contantPane.add(new JLabel("Ein Tool der CI!")); + this.contantPane.add(new JLabel("1) Tools von Daniel")); + + ButtonGroup buttonGroup = new ButtonGroup(); + JRadioButton hzeit = new JRadioButton("Hochzeit"); + hzeit.setBounds(100, 170, 100, 20); + buttonGroup.add(hzeit); + this.contantPane.add(hzeit); + JRadioButton gtag = new JRadioButton("Geburtstag"); + gtag.setBounds(250, 170, 100, 20); + buttonGroup.add(gtag); + this.contantPane.add(gtag); + + JLabel auswahl = new JLabel("Ihre Auswahl:"); + auswahl.setBounds(10, 200, 100, 20); + this.contantPane.add(auswahl); + final JTextField text1 = new JTextField(); + text1.setBounds(100, 200, 300, 20); + this.contantPane.add(text1); + + hzeit.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ie) { + text1.setText("MALE"); + } + }); + + gtag.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ie) { + text1.setText("FEMALE"); + } + }); + + + + this.contantPane.add(new JLabel("2) Tools von Eugen")); + + + + + + + + + this.contantPane.add(new JLabel("3) Tools von Michael")); + + this.contantPane.setVisible(true); this.fr.setVisible(true); }