package org.openslx.dozmod.gui.window.layout; import java.awt.BorderLayout; import java.awt.Window; import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextArea; import org.openslx.dozmod.gui.Gui; import org.openslx.dozmod.gui.control.QLabel; import org.openslx.dozmod.gui.helper.GridManager; @SuppressWarnings("serial") public abstract class CheckUpdateWindowLayout extends JDialog { private final static String title = "Version"; private final static String noticeLabel = "Update"; private final static String closeButtonLabel = "Schließen"; protected static JButton btnLink; protected static JButton btnClose; protected final QLabel lblLocalVersion = new QLabel("-"); protected final QLabel lblRemoteVersion = new QLabel("-"); protected final QLabel lblLocalVersionTime = new QLabel("-"); protected final QLabel lblRemoteVersionTime = new QLabel("-"); protected final JTextArea txtChangelog; public CheckUpdateWindowLayout(Window modalParent) { super(modalParent, title, modalParent != null ? ModalityType.APPLICATION_MODAL : ModalityType.MODELESS); setLayout(new BorderLayout()); setPreferredSize(Gui.getScaledDimension(680, 400)); // Panel used for creating border. We'll add everything into this. JPanel borderPanel = new JPanel(); borderPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); add(borderPanel); // information before the disclaimer JPanel infoPanel = new JPanel(); GridManager infoGrid = new GridManager(infoPanel, 4); infoPanel.setBorder(BorderFactory.createTitledBorder(noticeLabel)); infoGrid.add(new QLabel("Ihre Version")); infoGrid.add(Box.createHorizontalStrut(10)); infoGrid.add(lblLocalVersion); infoGrid.add(Box.createHorizontalGlue()).fill(true, false).expand(true, false); infoGrid.nextRow(); infoGrid.add(new QLabel("Aktuelle Version")); infoGrid.add(Box.createHorizontalStrut(10)); infoGrid.add(lblRemoteVersion); infoGrid.add(Box.createHorizontalGlue()).fill(true, false).expand(true, false); infoGrid.finish(false); txtChangelog = new JTextArea("-", 30, 20); txtChangelog.setLineWrap(true); txtChangelog.setWrapStyleWord(true); JScrollPane changelogPanel = new JScrollPane(txtChangelog, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); changelogPanel.setBorder(BorderFactory.createTitledBorder("Changelog")); // checkbox for acknowledging the disclaimer btnLink = new JButton("Zum Download-Portal"); btnClose = new JButton(closeButtonLabel); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS)); buttonPanel.add(Box.createHorizontalGlue()); buttonPanel.add(btnLink); buttonPanel.add(btnClose); // put everything together GridManager grid = new GridManager(borderPanel, 1); grid.add(infoPanel).fill(true, false).expand(true, false); grid.nextRow(); grid.add(changelogPanel).fill(true, true).expand(true, true); grid.finish(false); add(buttonPanel, BorderLayout.PAGE_END); pack(); if (modalParent != null) { Gui.centerShellOverShell(modalParent, this); } } }