diff options
| author | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
|---|---|---|
| committer | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
| commit | 33613a85afc4b1481367fbe92a17ee59c240250b (patch) | |
| tree | 670b842326116b376b505ec2263878912fca97e2 /Master/Reference Architectures and Patterns/hjp5/examples/Listing3607.java | |
| download | Studium-33613a85afc4b1481367fbe92a17ee59c240250b.tar.gz Studium-33613a85afc4b1481367fbe92a17ee59c240250b.tar.bz2 | |
Diffstat (limited to 'Master/Reference Architectures and Patterns/hjp5/examples/Listing3607.java')
| -rw-r--r-- | Master/Reference Architectures and Patterns/hjp5/examples/Listing3607.java | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/Master/Reference Architectures and Patterns/hjp5/examples/Listing3607.java b/Master/Reference Architectures and Patterns/hjp5/examples/Listing3607.java new file mode 100644 index 0000000..75d88e5 --- /dev/null +++ b/Master/Reference Architectures and Patterns/hjp5/examples/Listing3607.java @@ -0,0 +1,58 @@ +/* Listing3607.java */
+
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+
+class DesktopFrame
+extends JFrame
+{
+ private JDesktopPane desk;
+
+ public DesktopFrame()
+ {
+ super("DesktopFrame");
+ this.desk = new JDesktopPane();
+ desk.setDesktopManager(new DefaultDesktopManager());
+ setContentPane(desk);
+ addWindowListener(new WindowClosingAdapter(true));
+ }
+
+ public void addChild(JInternalFrame child, int x, int y)
+ {
+ child.setLocation(x, y);
+ child.setSize(200, 150);
+ child.setDefaultCloseOperation(
+ JInternalFrame.DISPOSE_ON_CLOSE
+ );
+ desk.add(child);
+ child.setVisible(true);
+ }
+}
+
+class ChildFrame
+extends JInternalFrame
+{
+ public ChildFrame(String title)
+ {
+ super("Child " + title, true, true);
+ setIconifiable(true);
+ setMaximizable(true);
+ setBackground(Color.lightGray);
+ }
+}
+
+public class Listing3607
+{
+ public static void main(String[] args)
+ {
+ //Desktop erzeugen
+ DesktopFrame desktop = new DesktopFrame();
+ desktop.setLocation(100, 100);
+ desktop.setSize(400, 300);
+ desktop.setVisible(true);
+ //Zwei ChildFrames hinzufügen
+ desktop.addChild(new ChildFrame("1"), 10, 10);
+ desktop.addChild(new ChildFrame("2"), 20, 20);
+ }
+}
\ No newline at end of file |
