X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fde%2Ftodesbaum%2Futil%2Fswing%2FTWizard.java;h=464ac6930912d1b0441577dfeb5928846ac4d5e0;hb=e47e15fdbb7515f5a3757c3f5df8c1d0950aee8e;hp=e865ed4a542907408811b941e86dcfe5ee8155d6;hpb=e4f461213da0e30faf9e9eb2e97626abff320618;p=jSite.git diff --git a/src/de/todesbaum/util/swing/TWizard.java b/src/de/todesbaum/util/swing/TWizard.java index e865ed4..464ac69 100644 --- a/src/de/todesbaum/util/swing/TWizard.java +++ b/src/de/todesbaum/util/swing/TWizard.java @@ -1,6 +1,5 @@ /* - * todesbaum-lib - - * Copyright (C) 2006 David Roden + * jSite - TWizard.java - Copyright © 2006–2012 David Roden * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -45,9 +44,9 @@ import javax.swing.border.EmptyBorder; * @version $Id$ */ public class TWizard extends JFrame implements WindowListener { - + protected List wizardListeners = new ArrayList(); - + private Action previousAction; private Action nextAction; private Action quitAction; @@ -55,46 +54,47 @@ public class TWizard extends JFrame implements WindowListener { private JPanel pagePanel; private JLabel pageHeading; private JLabel pageDescription; - + + @Override protected void frameInit() { super.frameInit(); setResizable(false); addWindowListener(this); setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); createActions(); - + pageIcon = new JLabel(); pageIcon.setVerticalAlignment(SwingConstants.TOP); pageHeading = new JLabel(); pageHeading.setFont(pageHeading.getFont().deriveFont(pageHeading.getFont().getSize() * 2.0f).deriveFont(Font.BOLD)); pageDescription = new JLabel(); - + JPanel contentPane = new JPanel(new BorderLayout(12, 12)); contentPane.setBorder(new EmptyBorder(12, 12, 12, 12)); - + JPanel topPanel = new JPanel(new BorderLayout(12, 12)); contentPane.add(topPanel, BorderLayout.PAGE_START); - + topPanel.add(pageIcon, BorderLayout.LINE_START); - + JPanel textPanel = new JPanel(new BorderLayout(12, 12)); topPanel.add(textPanel, BorderLayout.CENTER); textPanel.add(pageHeading, BorderLayout.PAGE_START); textPanel.add(pageDescription, BorderLayout.CENTER); - + pagePanel = new JPanel(new BorderLayout(12, 12)); contentPane.add(pagePanel, BorderLayout.CENTER); - + JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.TRAILING, 12, 12)); buttonPanel.setBorder(new EmptyBorder(-12, -12, -12, -12)); buttonPanel.add(new JButton(previousAction)); buttonPanel.add(new JButton(nextAction)); buttonPanel.add(new JButton(quitAction)); contentPane.add(buttonPanel, BorderLayout.PAGE_END); - + setContentPane(contentPane); } - + @Override public void pack() { super.pack(); @@ -102,57 +102,57 @@ public class TWizard extends JFrame implements WindowListener { setLocation((screenSize.width - getWidth()) / 2, (screenSize.height - getHeight()) / 2); // System.out.println("resized to: " + getWidth() + "x" + getHeight()); } - + private void createActions() { previousAction = new AbstractAction("Previous") { public void actionPerformed(ActionEvent actionEvent) { actionPrevious(); } }; - + nextAction = new AbstractAction("Next") { public void actionPerformed(ActionEvent actionEvent) { actionNext(); } }; - + quitAction = new AbstractAction("Quit") { public void actionPerformed(ActionEvent actionEvent) { actionQuit(); } }; } - + public void addWizardListener(WizardListener wizardListener) { wizardListeners.add(wizardListener); } - + public void removeWizardListener(WizardListener wizardListener) { wizardListeners.remove(wizardListener); } - + protected void fireWizardPreviousPressed() { for (WizardListener wizardListener: wizardListeners) { wizardListener.wizardPreviousPressed(this); } } - + protected void fireWizardNextPressed() { for (WizardListener wizardListener: wizardListeners) { wizardListener.wizardNextPressed(this); } } - + protected void fireWizardQuitPressed() { for (WizardListener wizardListener: wizardListeners) { wizardListener.wizardQuitPressed(this); } } - + public void setIcon(Icon icon) { pageIcon.setIcon(icon); } - + public void setPage(TWizardPage page) { setVisible(false); pageHeading.setText(page.getHeading()); @@ -169,35 +169,35 @@ public class TWizard extends JFrame implements WindowListener { setTitle(page.getHeading()); setVisible(true); } - + public TWizardPage getPage() { return (TWizardPage) pagePanel.getComponent(0); } - + public void setPreviousEnabled(boolean previousEnabled) { previousAction.setEnabled(previousEnabled); } - + public void setPreviousName(String previousName) { previousAction.putValue(Action.NAME, previousName); } - + public void setNextEnabled(boolean nextEnabled) { nextAction.setEnabled(nextEnabled); } - + public void setNextName(String nextName) { nextAction.putValue(Action.NAME, nextName); } - + public void setQuitEnabled(boolean quitEnabled) { quitAction.setEnabled(quitEnabled); } - + public void setQuitName(String quitName) { quitAction.putValue(Action.NAME, quitName); } - + protected void actionPrevious() { fireWizardPreviousPressed(); } @@ -205,11 +205,11 @@ public class TWizard extends JFrame implements WindowListener { protected void actionNext() { fireWizardNextPressed(); } - + protected void actionQuit() { fireWizardQuitPressed(); } - + // // INTERFACE WindowListener //