[Schmitzm-commits] r2283 - trunk/schmitzm-core/src/main/java/de/schmitzm/swing
scm-commit at wald.intevation.org
scm-commit at wald.intevation.org
Mon Mar 25 22:03:58 CET 2013
Author: mojays
Date: 2013-03-25 22:03:58 +0100 (Mon, 25 Mar 2013)
New Revision: 2283
Added:
trunk/schmitzm-core/src/main/java/de/schmitzm/swing/GUIBuilder.java
Log:
new GUIBuilder
Added: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/GUIBuilder.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/GUIBuilder.java (rev 0)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/GUIBuilder.java 2013-03-25 21:03:58 UTC (rev 2283)
@@ -0,0 +1,168 @@
+/**
+ * Copyright (c) 2009 Martin O. J. Schmitz.
+ *
+ * This file is part of the SCHMITZM library - a collection of utility
+ * classes based on Java 1.6, focusing (not only) on Java Swing
+ * and the Geotools library.
+ *
+ * The SCHMITZM project is hosted at:
+ * http://wald.intevation.org/projects/schmitzm/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License (license.txt)
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * or try this link: http://www.gnu.org/licenses/lgpl.html
+ *
+ * Contributors:
+ * Martin O. J. Schmitz - initial API and implementation
+ * Stefan A. Tzeggai - additional utility classes
+ */
+package de.schmitzm.swing;
+
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.event.ActionListener;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.Icon;
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JLabel;
+import javax.swing.JMenuItem;
+import javax.swing.JToggleButton;
+import javax.swing.JToolBar;
+
+/**
+ * This class provides some methods to build GUI components a common way (application
+ * wide).
+ * To change some behavior application wide (through all generic sub-components)
+ * the static field {@link #INST} can be reset with an overwritten instance of
+ * this class.
+ * @author Martin O.J. Schmitz
+ *
+ */
+public class GUIBuilder {
+ /** Application wide instance of {@link GUIBuilder} */
+ public static GUIBuilder INST = new GUIBuilder();
+
+ /** Font for comment labels in the frames. */
+ public final Font FONT_COMMENT_LABEL = SwingUtil.DEFAULT_FONT
+ .deriveFont(Font.ITALIC).deriveFont( SwingUtil.DEFAULT_FONT.getSize()-1f );
+ /** Font for header labels in the frames. */
+ public final Font FONT_HEADER_LABEL = SwingUtil.DEFAULT_FONT
+ .deriveFont(Font.BOLD);
+ /** Font for section labels in the frames. */
+ public final Font FONT_SECTION_LABEL = SwingUtil.DEFAULT_FONT
+ .deriveFont(Font.BOLD).deriveFont( SwingUtil.DEFAULT_FONT.getSize()+1f );
+ /** Color for section labels in the frames. */
+ public final Color COLOR_SECTION_LABEL = new Color(0,51,153); // dark blue
+
+ /**
+ * Creates a menu item, standardized for the application.
+ *
+ * @param title
+ * title for the menu item
+ * @param actionListener
+ * listener to perform the action
+ * @param commandID
+ * identifies the action in the action listener (if the listener
+ * is used for multiple actions)
+ * @param desc
+ * optional (tooltip) description
+ * @param icon
+ * optional icon
+ */
+ public Action createAction(String title,
+ final ActionListener actionListener, String commandID, String desc,
+ Icon icon) {
+ Action action = SwingUtil.createAction(title, actionListener, commandID, desc, icon);
+ return action;
+ }
+
+ /**
+ * Creates a menu item, standardized for the WIME application.
+ */
+ public JMenuItem createMenuItem(Action action) {
+ JMenuItem menuItem = new JMenuItem(action);
+ return menuItem;
+ }
+
+ /**
+ * Creates a menu item, standardized for the WIME application.
+ */
+ public JCheckBoxMenuItem createCheckboxMenuItem(Action action, boolean selected) {
+ JCheckBoxMenuItem menuItem = SwingUtil.createCheckboxMenuItem(action, selected);
+ return menuItem;
+ }
+
+ /**
+ * Creates a {@link JToggleButton} for the use in a {@link JToolBar}.
+ * Regardless of the {@linkplain AbstractAction#NAME action name},
+ * the button will only show the icon.
+ */
+ public JToggleButton createToggleToolbarButton(Action action, boolean selected) {
+ JToggleButton button = SwingUtil.createToggleToolbarButton(action,selected);
+ return button;
+ }
+
+ /**
+ * Creates a {@link JToggleButton} for the use in a {@link JToolBar}.
+ * Regardless of the {@linkplain AbstractAction#NAME action name},
+ * the button will only show the icon.
+ */
+ public JToggleButton createToggleToolbarButton(Action action) {
+ JToggleButton button = SwingUtil.createToggleToolbarButton(action);
+ return button;
+ }
+
+ /**
+ * Creates a {@link JLabel} styled as header label in
+ * {@link KontaktInformationPanel}.
+ */
+ public JLabel createHeaderLabel(String caption) {
+ JLabel label = new JLabel(caption);
+ label.setFont(FONT_HEADER_LABEL);
+ return label;
+ }
+
+ /**
+ * Creates a {@link JLabel} styled as header label in
+ * {@link KontaktInformationPanel}.
+ */
+ public JLabel createSectionLabel(String caption) {
+ JLabel label = new JLabel(caption);
+ label.setFont(FONT_SECTION_LABEL);
+ label.setForeground(COLOR_SECTION_LABEL);
+ return label;
+ }
+
+ /**
+ * Creates a {@link JLabel} styled to show a comment in
+ * {@link KontaktInformationPanel}.
+ */
+ public JLabel createCommentLabel(String caption) {
+ JLabel label = new JLabel(caption);
+ label.setFont(FONT_COMMENT_LABEL);
+ return label;
+ }
+
+ /**
+ * Creates a {@link JLabel} styled to show normal (read-only) content in
+ * {@link KontaktInformationPanel}.
+ */
+ public JLabel createContentLabel(String caption) {
+ JLabel label = new JLabel(caption);
+ return label;
+ }
+
+}
More information about the Schmitzm-commits
mailing list