From de8cb996a0e2fc2546782a8a5944209eb0e56c14 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 27 Jul 2015 18:41:02 +0200 Subject: [client] Swing --- .../src/main/java/org/openslx/dozmod/gui/Gui.java | 10 ++-- .../gui/window/layout/LoginWindowLayout.java | 10 ++-- .../gui/window/layout/MainMenuWindowLayout.java | 57 ++++++++++------------ 3 files changed, 36 insertions(+), 41 deletions(-) (limited to 'dozentenmodul/src/main/java') diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/Gui.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/Gui.java index 54d4ab4a..34a10ea1 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/Gui.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/Gui.java @@ -105,12 +105,12 @@ public class Gui { } /** - * Get the {@link Monitor} which the given {@link Point} lies in. + * Get the {@link GraphicsDevice} which the given {@link Point} lies in. * * @param point The point in question * @param defaultToPrimary if no monitor matches the check, return the * primary monitor if true, null otherwise - * @return the {@link Monitor} + * @return the {@link GraphicsDevice} */ private static GraphicsDevice getMonitorFromPoint(GraphicsDevice[] screens, Point point, boolean defaultToPrimary) { @@ -129,12 +129,12 @@ public class Gui { } /** - * Get the {@link Monitor} which most of the given rectangle overlaps. + * Get the {@link GraphicsDevice} which most of the given rectangle overlaps. * * @param rect The rectangle to check * @param defaultToPrimary if no monitor matches the check, return the * primary monitor if true, null otherwise - * @return the {@link Monitor} + * @return the {@link GraphicsDevice} */ public static GraphicsDevice getMonitorFromRectangle(Rectangle rect, boolean defaultToPrimary) { // Make sure rectangle is in bounds. This is not completely accurate @@ -142,7 +142,7 @@ public class Gui { GraphicsDevice[] screens = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices(); Rectangle bounds = new Rectangle(); for (GraphicsDevice dev : screens) { - bounds.union(dev.getDefaultConfiguration().getBounds()); + bounds = bounds.union(dev.getDefaultConfiguration().getBounds()); } LOGGER.debug("Display bounds are " + bounds.toString() + ", rect is " + rect.toString()); if (rect.x + rect.width >= bounds.x + bounds.width) { diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LoginWindowLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LoginWindowLayout.java index 81a4ffce..c31f4f82 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LoginWindowLayout.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LoginWindowLayout.java @@ -9,6 +9,7 @@ import javax.swing.BoxLayout; import javax.swing.ButtonGroup; import javax.swing.ImageIcon; import javax.swing.JButton; +import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; @@ -19,9 +20,10 @@ import javax.swing.UIManager; import javax.swing.border.TitledBorder; import org.apache.log4j.Logger; +import org.openslx.dozmod.gui.Gui; import org.openslx.dozmod.util.ResourceLoader; -public abstract class LoginWindowLayout extends JFrame { +public abstract class LoginWindowLayout extends JDialog { private static final Logger LOGGER = Logger.getLogger(LoginWindowLayout.class); @@ -54,10 +56,9 @@ public abstract class LoginWindowLayout extends JFrame { public LoginWindowLayout() { super(); setTitle("Simple example"); - setSize(600, 300); setLocationRelativeTo(null); setResizable(false); - setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); GridBagLayout bag = new GridBagLayout(); GridBagConstraints con = new GridBagConstraints(); setLayout(bag); @@ -134,12 +135,13 @@ public abstract class LoginWindowLayout extends JFrame { con.gridwidth = GridBagConstraints.REMAINDER; bag.setConstraints(loginFormPanel, con); add(loginFormPanel); + pack(); } private ImageIcon loadImage() { try { ImageIcon image = ResourceLoader.getIcon("/img/Logo_bwLehrpool.png"); - java.awt.Rectangle screenSize = getBounds(); + java.awt.Rectangle screenSize = Gui.getMonitorFromRectangle(getBounds(), true).getDefaultConfiguration().getBounds(); float scaleX = (float)screenSize.width / (float)image.getIconWidth(); float scaleY = (float)screenSize.height / (float)image.getIconHeight(); final float scaling; diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/MainMenuWindowLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/MainMenuWindowLayout.java index 379f3e12..5cf3dfa0 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/MainMenuWindowLayout.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/MainMenuWindowLayout.java @@ -1,12 +1,12 @@ package org.openslx.dozmod.gui.window.layout; -import java.awt.Button; import java.awt.FlowLayout; -import java.awt.GridLayout; -import java.awt.Label; -import java.security.acl.Group; +import javax.swing.BoxLayout; import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.border.TitledBorder; import org.openslx.dozmod.gui.helper.CompositePage; @@ -50,35 +50,28 @@ public abstract class MainMenuWindowLayout extends CompositePage { public MainMenuWindowLayout() { super(new FlowLayout()); - this.setLayout(new GridLayout(2, true)); - // group for the vm selection - Group vmGroup = new Group(this, SWT.NONE); - vmGroup.setLayout(new GridLayout()); - vmGroup.setText("VMs"); - vmGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - - vmButton = new Button(vmGroup, SWT.PUSH); - vmButton.setText("VM - Übersicht"); - vmButton.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true)); - - Label vmInfoLabel = new Label(vmGroup, SWT.NONE); - vmInfoLabel.setText(vmInfo); - vmInfoLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - - //g group for the lecture selection - Group lecturesGroup = new Group(this, SWT.NONE); - lecturesGroup.setLayout(new GridLayout()); - lecturesGroup.setText("Veranstaltungen"); - lecturesGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - - lecturesButton = new Button(lecturesGroup, SWT.PUSH); - lecturesButton.setText("Veranstanstaltungen"); - lecturesButton.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true)); - - Label lecturesInfoLabel = new Label(lecturesGroup, SWT.NONE); - lecturesInfoLabel.setText(lecturesInfo); - lecturesInfoLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + JPanel vmGroup = new JPanel(); + vmGroup.setLayout(new BoxLayout(vmGroup, BoxLayout.PAGE_AXIS)); + vmGroup.setBorder(new TitledBorder("VM")); + + vmButton = new JButton("VM-Übersicht"); + JLabel vmInfoLabel = new JLabel(vmInfo); + + // group for the lecture selection + JPanel lecturesGroup = new JPanel(); + lecturesGroup.setLayout(new BoxLayout(vmGroup, BoxLayout.PAGE_AXIS)); + lecturesGroup.setBorder(new TitledBorder("Veranstaltungen")); + + lecturesButton = new JButton("Veranstaltungen"); + JLabel lecturesInfoLabel = new JLabel(lecturesInfo); + + vmGroup.add(vmButton); + vmGroup.add(vmInfoLabel); + lecturesGroup.add(lecturesButton); + lecturesGroup.add(lecturesInfoLabel); + add(vmGroup); + add(lecturesGroup); } } -- cgit v1.2.3-55-g7522