X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fde%2Ftodesbaum%2Futil%2Fswing%2FTWizard.java;h=3eb5062a34fafacba9e1abe9101682fd836891d6;hb=bbfa208695e2a7f1bb555f841623945767f296e7;hp=e865ed4a542907408811b941e86dcfe5ee8155d6;hpb=da127cd41fa65b7ec217f8e9f525ed7534abf5e1;p=jSite.git diff --git a/src/de/todesbaum/util/swing/TWizard.java b/src/de/todesbaum/util/swing/TWizard.java index e865ed4..3eb5062 100644 --- a/src/de/todesbaum/util/swing/TWizard.java +++ b/src/de/todesbaum/util/swing/TWizard.java @@ -1,5 +1,5 @@ /* - * todesbaum-lib - + * todesbaum-lib - * Copyright (C) 2006 David Roden * * This program is free software; you can redistribute it and/or modify @@ -45,9 +45,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 +55,46 @@ public class TWizard extends JFrame implements WindowListener { private JPanel pagePanel; private JLabel pageHeading; private JLabel pageDescription; - + 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 //