├── DJSwingSuite ├── DJSwingSuite │ ├── documentation │ │ ├── .cvsignore │ │ ├── .gitignore │ │ ├── build.xml │ │ └── javadoc-package-lists │ │ │ └── jdk │ │ │ └── package-list │ ├── Release │ │ ├── .cvsignore │ │ ├── .gitignore │ │ ├── ConfigurableProperties.txt │ │ ├── build.xml │ │ ├── readme.txt │ │ └── changelog.txt │ └── .gitignore ├── .cvsignore ├── .gitignore ├── src │ └── main │ │ ├── resources │ │ └── net │ │ │ └── nextencia │ │ │ └── dj │ │ │ └── swingsuite │ │ │ └── resource │ │ │ ├── autoscroll_h.png │ │ │ ├── autoscroll_v.png │ │ │ ├── warning_obj.png │ │ │ ├── autoscroll_all.png │ │ │ ├── TableColumnFilter16x12.png │ │ │ └── TableColumnFilterOn16x12.png │ │ └── java │ │ └── net │ │ └── nextencia │ │ └── dj │ │ └── swingsuite │ │ ├── TriStateCheckBoxListener.java │ │ ├── TextEntryFieldAdapter.java │ │ ├── TextEntryFormatter.java │ │ ├── LinkListener.java │ │ ├── TextEntryFieldListener.java │ │ ├── TextEntryValidator.java │ │ ├── JSedRegExBuilder.java │ │ ├── TextEntryMask.java │ │ ├── JWidePopupComboBox.java │ │ ├── JTitledSeparator.java │ │ ├── PatternTextEntryMask.java │ │ ├── LayeredIcon.java │ │ ├── SedRegExpPattern.java │ │ ├── JExtendedLabel.java │ │ ├── JLink.java │ │ ├── AutoScrollActivator.java │ │ └── JDragSelectTree.java ├── build.xml ├── .project ├── .classpath └── pom.xml ├── DJSwingSuite-Demo ├── .gitignore ├── src │ └── main │ │ ├── resources │ │ └── net │ │ │ └── nextencia │ │ │ └── dj │ │ │ └── swingsuite │ │ │ └── demo │ │ │ ├── resource │ │ │ ├── brkp_obj.gif │ │ │ ├── fldr_obj.gif │ │ │ ├── DJIcon16x16.png │ │ │ ├── DJIcon24x24.png │ │ │ ├── DJIcon32x32.png │ │ │ ├── DJIcon48x48.png │ │ │ ├── DJIcon256x256.png │ │ │ └── DJIcon32x32Plain.png │ │ │ └── examples │ │ │ ├── utilities │ │ │ └── resource │ │ │ │ ├── loading9.gif │ │ │ │ └── package16.png │ │ │ └── basiccomponents │ │ │ └── resource │ │ │ └── package16.png │ │ └── java │ │ └── net │ │ └── nextencia │ │ └── dj │ │ └── swingsuite │ │ └── demo │ │ ├── common │ │ ├── Disposable.java │ │ └── ui │ │ │ └── source │ │ │ ├── SourcePane.java │ │ │ ├── RegExTokenizer.java │ │ │ ├── TabFilterReader.java │ │ │ ├── EditorKitDocument.java │ │ │ ├── RegExTypes.java │ │ │ └── RegExJavaTypes.java │ │ ├── ExampleGroup.java │ │ ├── examples │ │ ├── basiccomponents │ │ │ ├── DragSelectTreeExample.java │ │ │ ├── TitledSeparatorExample.java │ │ │ ├── TimeEditorExample.java │ │ │ ├── ExtendedLabelExample.java │ │ │ ├── JumpListMenuItemExample.java │ │ │ ├── WidePopupComboBoxExample.java │ │ │ ├── TriStateCheckBoxExample.java │ │ │ ├── LinkExample.java │ │ │ └── ComboButtonExample.java │ │ ├── utilities │ │ │ ├── SearchReplaceRegExExample.java │ │ │ ├── AutoScrollExample.java │ │ │ ├── SelectAllOnFocusExample.java │ │ │ ├── LayeredIconExample.java │ │ │ ├── WildcardsConversionExample.java │ │ │ ├── TableColumnAutoFitExample.java │ │ │ ├── FilterableTableHeaderExample.java │ │ │ └── RichDragAndDrop.java │ │ └── introduction │ │ │ └── SwingSuite.java │ │ ├── Example.java │ │ ├── DemoTree.java │ │ └── DemoExampleDefinitionLoader.java ├── .project ├── build.xml ├── .classpath └── pom.xml └── README.md /DJSwingSuite/DJSwingSuite/documentation/.cvsignore: -------------------------------------------------------------------------------- 1 | javadoc 2 | -------------------------------------------------------------------------------- /DJSwingSuite/DJSwingSuite/documentation/.gitignore: -------------------------------------------------------------------------------- 1 | /javadoc 2 | -------------------------------------------------------------------------------- /DJSwingSuite/DJSwingSuite/Release/.cvsignore: -------------------------------------------------------------------------------- 1 | DJSwingSuite.zip 2 | -------------------------------------------------------------------------------- /DJSwingSuite/DJSwingSuite/Release/.gitignore: -------------------------------------------------------------------------------- 1 | /DJSwingSuite.zip 2 | -------------------------------------------------------------------------------- /DJSwingSuite/.cvsignore: -------------------------------------------------------------------------------- 1 | DJSwingSuite-Demo.jar 2 | DJSwingSuite.jar 3 | -------------------------------------------------------------------------------- /DJSwingSuite-Demo/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | /target/ 3 | /.classpath 4 | /.project 5 | /.settings/ 6 | -------------------------------------------------------------------------------- /DJSwingSuite/DJSwingSuite/.gitignore: -------------------------------------------------------------------------------- 1 | /lib 2 | /DJSwingSuite.jar 3 | /DJSwingSuite-Demo.jar 4 | /bin 5 | -------------------------------------------------------------------------------- /DJSwingSuite/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | /target/ 3 | /.classpath 4 | /.project 5 | /.settings/ 6 | /DJSwingSuite.jar 7 | /DJSwingSuite-Demo.jar 8 | -------------------------------------------------------------------------------- /DJSwingSuite/src/main/resources/net/nextencia/dj/swingsuite/resource/autoscroll_h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chrriis/DJ-Swing-Suite/HEAD/DJSwingSuite/src/main/resources/net/nextencia/dj/swingsuite/resource/autoscroll_h.png -------------------------------------------------------------------------------- /DJSwingSuite/src/main/resources/net/nextencia/dj/swingsuite/resource/autoscroll_v.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chrriis/DJ-Swing-Suite/HEAD/DJSwingSuite/src/main/resources/net/nextencia/dj/swingsuite/resource/autoscroll_v.png -------------------------------------------------------------------------------- /DJSwingSuite/src/main/resources/net/nextencia/dj/swingsuite/resource/warning_obj.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chrriis/DJ-Swing-Suite/HEAD/DJSwingSuite/src/main/resources/net/nextencia/dj/swingsuite/resource/warning_obj.png -------------------------------------------------------------------------------- /DJSwingSuite/src/main/resources/net/nextencia/dj/swingsuite/resource/autoscroll_all.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chrriis/DJ-Swing-Suite/HEAD/DJSwingSuite/src/main/resources/net/nextencia/dj/swingsuite/resource/autoscroll_all.png -------------------------------------------------------------------------------- /DJSwingSuite-Demo/src/main/resources/net/nextencia/dj/swingsuite/demo/resource/brkp_obj.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chrriis/DJ-Swing-Suite/HEAD/DJSwingSuite-Demo/src/main/resources/net/nextencia/dj/swingsuite/demo/resource/brkp_obj.gif -------------------------------------------------------------------------------- /DJSwingSuite-Demo/src/main/resources/net/nextencia/dj/swingsuite/demo/resource/fldr_obj.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chrriis/DJ-Swing-Suite/HEAD/DJSwingSuite-Demo/src/main/resources/net/nextencia/dj/swingsuite/demo/resource/fldr_obj.gif -------------------------------------------------------------------------------- /DJSwingSuite-Demo/src/main/resources/net/nextencia/dj/swingsuite/demo/resource/DJIcon16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chrriis/DJ-Swing-Suite/HEAD/DJSwingSuite-Demo/src/main/resources/net/nextencia/dj/swingsuite/demo/resource/DJIcon16x16.png -------------------------------------------------------------------------------- /DJSwingSuite-Demo/src/main/resources/net/nextencia/dj/swingsuite/demo/resource/DJIcon24x24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chrriis/DJ-Swing-Suite/HEAD/DJSwingSuite-Demo/src/main/resources/net/nextencia/dj/swingsuite/demo/resource/DJIcon24x24.png -------------------------------------------------------------------------------- /DJSwingSuite-Demo/src/main/resources/net/nextencia/dj/swingsuite/demo/resource/DJIcon32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chrriis/DJ-Swing-Suite/HEAD/DJSwingSuite-Demo/src/main/resources/net/nextencia/dj/swingsuite/demo/resource/DJIcon32x32.png -------------------------------------------------------------------------------- /DJSwingSuite-Demo/src/main/resources/net/nextencia/dj/swingsuite/demo/resource/DJIcon48x48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chrriis/DJ-Swing-Suite/HEAD/DJSwingSuite-Demo/src/main/resources/net/nextencia/dj/swingsuite/demo/resource/DJIcon48x48.png -------------------------------------------------------------------------------- /DJSwingSuite/src/main/resources/net/nextencia/dj/swingsuite/resource/TableColumnFilter16x12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chrriis/DJ-Swing-Suite/HEAD/DJSwingSuite/src/main/resources/net/nextencia/dj/swingsuite/resource/TableColumnFilter16x12.png -------------------------------------------------------------------------------- /DJSwingSuite-Demo/src/main/resources/net/nextencia/dj/swingsuite/demo/resource/DJIcon256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chrriis/DJ-Swing-Suite/HEAD/DJSwingSuite-Demo/src/main/resources/net/nextencia/dj/swingsuite/demo/resource/DJIcon256x256.png -------------------------------------------------------------------------------- /DJSwingSuite/src/main/resources/net/nextencia/dj/swingsuite/resource/TableColumnFilterOn16x12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chrriis/DJ-Swing-Suite/HEAD/DJSwingSuite/src/main/resources/net/nextencia/dj/swingsuite/resource/TableColumnFilterOn16x12.png -------------------------------------------------------------------------------- /DJSwingSuite-Demo/src/main/resources/net/nextencia/dj/swingsuite/demo/resource/DJIcon32x32Plain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chrriis/DJ-Swing-Suite/HEAD/DJSwingSuite-Demo/src/main/resources/net/nextencia/dj/swingsuite/demo/resource/DJIcon32x32Plain.png -------------------------------------------------------------------------------- /DJSwingSuite-Demo/src/main/resources/net/nextencia/dj/swingsuite/demo/examples/utilities/resource/loading9.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chrriis/DJ-Swing-Suite/HEAD/DJSwingSuite-Demo/src/main/resources/net/nextencia/dj/swingsuite/demo/examples/utilities/resource/loading9.gif -------------------------------------------------------------------------------- /DJSwingSuite-Demo/src/main/resources/net/nextencia/dj/swingsuite/demo/examples/utilities/resource/package16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chrriis/DJ-Swing-Suite/HEAD/DJSwingSuite-Demo/src/main/resources/net/nextencia/dj/swingsuite/demo/examples/utilities/resource/package16.png -------------------------------------------------------------------------------- /DJSwingSuite-Demo/src/main/resources/net/nextencia/dj/swingsuite/demo/examples/basiccomponents/resource/package16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chrriis/DJ-Swing-Suite/HEAD/DJSwingSuite-Demo/src/main/resources/net/nextencia/dj/swingsuite/demo/examples/basiccomponents/resource/package16.png -------------------------------------------------------------------------------- /DJSwingSuite/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /DJSwingSuite-Demo/src/main/java/net/nextencia/dj/swingsuite/demo/common/Disposable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Christopher Deckers (chrriis@nextencia.net) 3 | * http://www.nextencia.net 4 | * 5 | * See the file "readme.txt" for information on usage and redistribution of 6 | * this file, and for a DISCLAIMER OF ALL WARRANTIES. 7 | */ 8 | package net.nextencia.dj.swingsuite.demo.common; 9 | 10 | /** 11 | * @author Christopher Deckers 12 | */ 13 | public interface Disposable { 14 | 15 | public void dispose(); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /DJSwingSuite/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | DJSwingSuite 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.m2e.core.maven2Nature 22 | 23 | 24 | -------------------------------------------------------------------------------- /DJSwingSuite-Demo/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | DJSwingSuite-Demo 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.m2e.core.maven2Nature 22 | 23 | 24 | -------------------------------------------------------------------------------- /DJSwingSuite/DJSwingSuite/documentation/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /DJSwingSuite-Demo/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /DJSwingSuite/DJSwingSuite/Release/ConfigurableProperties.txt: -------------------------------------------------------------------------------- 1 | Here are the UIManager keys to define the various messages. 2 | 3 | -------------------------------------------------------------------------------- 4 | 5 | * TextEntryField.invalidInputMessage 6 | Default: = "Invalid input" 7 | 8 | * TextEntryField.maxTextLengthMessage 9 | Default: "Max length: {0}" 10 | Params: maximumLength 11 | 12 | * NumberEntryField.invalidFormatMessage 13 | Default: = "Invalid format" 14 | 15 | * NumberEntryField.maxDecimalsMessage 16 | Default: "Max decimals: {0}" 17 | Params: decimalCount 18 | 19 | * NumberEntryField.rangeMessage 20 | Default: "Range: {0} .. {1}" 21 | Params: rangeMin, rangeMax 22 | 23 | * Link.linkActivationErrorTitle 24 | Default: "Link error" 25 | 26 | * Link.linkActivationErrorMessage 27 | Default: "Failed to open the link \"{0}\"." 28 | Params: target 29 | -------------------------------------------------------------------------------- /DJSwingSuite-Demo/src/main/java/net/nextencia/dj/swingsuite/demo/ExampleGroup.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Christopher Deckers (chrriis@nextencia.net) 3 | * http://www.nextencia.net 4 | * 5 | * See the file "readme.txt" for information on usage and redistribution of 6 | * this file, and for a DISCLAIMER OF ALL WARRANTIES. 7 | */ 8 | package net.nextencia.dj.swingsuite.demo; 9 | 10 | /** 11 | * @author Christopher Deckers 12 | */ 13 | public class ExampleGroup { 14 | 15 | protected String name; 16 | protected Example[] examples; 17 | 18 | public ExampleGroup(String name, Example[] examples) { 19 | this.name = name; 20 | this.examples = examples; 21 | } 22 | 23 | public String getName() { 24 | return name; 25 | } 26 | 27 | public Example[] getExamples() { 28 | return examples; 29 | } 30 | 31 | @Override 32 | public String toString() { 33 | return name; 34 | } 35 | 36 | } -------------------------------------------------------------------------------- /DJSwingSuite/src/main/java/net/nextencia/dj/swingsuite/TriStateCheckBoxListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Christopher Deckers (chrriis@nextencia.net) 3 | * http://www.nextencia.net 4 | * 5 | * See the file "readme.txt" for information on usage and redistribution of 6 | * this file, and for a DISCLAIMER OF ALL WARRANTIES. 7 | */ 8 | package net.nextencia.dj.swingsuite; 9 | 10 | import java.util.EventListener; 11 | 12 | import net.nextencia.dj.swingsuite.JTriStateCheckBox.CheckState; 13 | 14 | /** 15 | * A listener for tri state check boxes. 16 | * @author Christopher Deckers 17 | */ 18 | public interface TriStateCheckBoxListener extends EventListener { 19 | 20 | /** 21 | * Invoked when the tri state check box changes of state. 22 | * @param checkBox the check box that has changed state. 23 | * @param state the new state. 24 | */ 25 | public void stateChanged(JTriStateCheckBox checkBox, CheckState state); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /DJSwingSuite/src/main/java/net/nextencia/dj/swingsuite/TextEntryFieldAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Christopher Deckers (chrriis@nextencia.net) 3 | * http://www.nextencia.net 4 | * 5 | * See the file "readme.txt" for information on usage and redistribution of 6 | * this file, and for a DISCLAIMER OF ALL WARRANTIES. 7 | */ 8 | package net.nextencia.dj.swingsuite; 9 | 10 | 11 | /** 12 | * An adapter for the text entry listener interface. 13 | * @author Christopher Deckers 14 | */ 15 | public abstract class TextEntryFieldAdapter implements TextEntryFieldListener { 16 | 17 | /** 18 | * Invoked when an error message is set or cleared. 19 | */ 20 | public void errorMessageChanged(JTextEntryField validationField, String errorMessage) { 21 | } 22 | 23 | /** 24 | * Invoked when a valid text of an entry field is committed. 25 | */ 26 | public void textCommitted(JTextEntryField validationField) { 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /DJSwingSuite/src/main/java/net/nextencia/dj/swingsuite/TextEntryFormatter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Christopher Deckers (chrriis@nextencia.net) 3 | * http://www.nextencia.net 4 | * 5 | * See the file "readme.txt" for information on usage and redistribution of 6 | * this file, and for a DISCLAIMER OF ALL WARRANTIES. 7 | */ 8 | package net.nextencia.dj.swingsuite; 9 | 10 | /** 11 | * A formatter for a text entry field when it does not have the focus. 12 | * @author Christopher Deckers 13 | */ 14 | public interface TextEntryFormatter { 15 | 16 | /** 17 | * Get the text to show when the field does not have the focus. 18 | * @param textEntryField The text entry field for which to display the value. 19 | * @param validText The text for which to show a representation. 20 | * @return a specific value or null for the default. 21 | */ 22 | public String getTextForDisplay(JTextEntryField textEntryField, String validText); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /DJSwingSuite/src/main/java/net/nextencia/dj/swingsuite/LinkListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Christopher Deckers (chrriis@nextencia.net) 3 | * http://www.nextencia.net 4 | * 5 | * See the file "readme.txt" for information on usage and redistribution of 6 | * this file, and for a DISCLAIMER OF ALL WARRANTIES. 7 | */ 8 | package net.nextencia.dj.swingsuite; 9 | 10 | import java.util.EventListener; 11 | 12 | /** 13 | * A listener for links. 14 | * @author Christopher Deckers 15 | */ 16 | public interface LinkListener extends EventListener { 17 | 18 | /** 19 | * Invoked when a link is activated, it returns true if the other listeners and potentially the default handler should be invoked.
20 | * Note that the default handler is only invoked if the object is of a recognized type and the Java version supports it (Java 6+). 21 | * @param link the link which was activated. 22 | * @param target the target of the link. 23 | * @return true if the other listeners and the default handler should be invoked, false otherwise. 24 | */ 25 | public boolean linkActivated(JLink link, T target); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /DJSwingSuite/src/main/java/net/nextencia/dj/swingsuite/TextEntryFieldListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Christopher Deckers (chrriis@nextencia.net) 3 | * http://www.nextencia.net 4 | * 5 | * See the file "readme.txt" for information on usage and redistribution of 6 | * this file, and for a DISCLAIMER OF ALL WARRANTIES. 7 | */ 8 | package net.nextencia.dj.swingsuite; 9 | 10 | import java.util.EventListener; 11 | 12 | /** 13 | * The listener interface for receiving events. 14 | * @author Christopher Deckers 15 | */ 16 | public interface TextEntryFieldListener extends EventListener { 17 | 18 | /** 19 | * Invoked when an error message is set or cleared. 20 | * @param validationField The field for which the error message changed. 21 | * @param errorMessage The error message. 22 | */ 23 | public void errorMessageChanged(JTextEntryField validationField, String errorMessage); 24 | 25 | /** 26 | * Invoked when a valid text of an entry field is committed. 27 | * @param validationField The field for which the text is committed. 28 | */ 29 | public void textCommitted(JTextEntryField validationField); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /DJSwingSuite/DJSwingSuite/Release/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | DJ Swing Suite 2 | ============== 3 | 4 | The Swing Suite library provides some common components and utilities that are often needed or greatly help the creation of rich user interface. 5 | 6 | These components include text and number entry fields (with validation, notification tips, formatters and masks), combo buttons, tri-state check boxes and links. 7 | 8 | Download 9 | ======== 10 | 11 | Get the [DJ Swing Suite distribution](https://sourceforge.net/projects/djproject/files/DJ%20Swing%20Suite/) on SourceForge. 12 | 13 | Community and Support 14 | ===================== 15 | 16 | All questions should be posted to the [SourceForge Help forum](https://sourceforge.net/projects/djproject/forums/forum/671154). Issues can be submitted to the [SourceForge tracker](https://sourceforge.net/tracker/?group_id=190690). 17 | 18 | Using the Library 19 | ================= 20 | 21 | The demo application that is part of the distribution shows all the features as well as the code. 22 | 23 | The Javadoc is also part of the distribution. 24 | 25 | The [SourceForge Help forum](https://sourceforge.net/projects/djproject/forums/forum/671154) is also a good resource of help when encountering a problem. 26 | 27 | Contributing 28 | ============ 29 | 30 | You're encouraged to contribute to DJ Swing Suite. Fork the code from [github.com/Chrriis/DJ-Swing-Suite](https://github.com/Chrriis/DJ-Swing-Suite) and submit pull requests. 31 | 32 | License 33 | ======= 34 | 35 | This library is provided under the LGPL, version 2.1 or later. 36 | -------------------------------------------------------------------------------- /DJSwingSuite/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /DJSwingSuite-Demo/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /DJSwingSuite/DJSwingSuite/Release/readme.txt: -------------------------------------------------------------------------------- 1 | The DJ project - Swing Suite 2 | http://djproject.sourceforge.net 3 | Christopher Deckers (chrriis@nextencia.net) 4 | Licence terms: LGPL (see licence.txt) 5 | 6 | 7 | 1. What is the DJ Project - Swing suite? 8 | 9 | The DJ Project is a set of tools and libraries to enhance the user experience of 10 | Java on the Desktop. 11 | 12 | DJ Swing Suite provides some common components and utilities that are often 13 | needed to create rich user interfaces. 14 | 15 | 16 | 2. How to use it? 17 | 18 | Simply place the DJSwingSuite.jar library in your classpath. 19 | Java 5.0 or later is required. 20 | 21 | 22 | 3. Any tutorial or demo? 23 | 24 | The DJ Swing Suite Demo presents all the features of the Swing Suite library, 25 | along with the corresponding code. Simply launch DJSwingSuite-Demo.jar. 26 | 27 | 28 | 4. What is the development status? 29 | 30 | The library is tested on Windows and Linux, and logically works on all the 31 | platforms where Java/Swing is supported. 32 | 33 | For information about the current implementation status, visit the DJ Project's 34 | website. 35 | 36 | 37 | 5. Sources? 38 | 39 | The sources are part of the distribution. 40 | There is of course some access to the CVS tree, from the Sourceforge website. 41 | 42 | 43 | 6. Troubleshooting? 44 | 45 | The library is pretty simple. In case of a problem, contact me by e-mail or 46 | through the SourceForge forums for the project. 47 | 48 | 49 | 7. How to contribute? 50 | 51 | If you are interested in helping the project, simply send me an e-mail. Friendly 52 | e-mails are always welcome too! 53 | -------------------------------------------------------------------------------- /DJSwingSuite-Demo/src/main/java/net/nextencia/dj/swingsuite/demo/examples/basiccomponents/DragSelectTreeExample.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Christopher Deckers (chrriis@nextencia.net) 3 | * http://www.nextencia.net 4 | * 5 | * See the file "readme.txt" for information on usage and redistribution of 6 | * this file, and for a DISCLAIMER OF ALL WARRANTIES. 7 | */ 8 | package net.nextencia.dj.swingsuite.demo.examples.basiccomponents; 9 | 10 | import java.awt.BorderLayout; 11 | 12 | import javax.swing.JFrame; 13 | import javax.swing.JPanel; 14 | import javax.swing.JScrollPane; 15 | import javax.swing.SwingUtilities; 16 | 17 | import net.nextencia.dj.swingsuite.JDragSelectTree; 18 | import net.nextencia.dj.swingsuite.SwingSuiteUtilities; 19 | 20 | /** 21 | * @author Christopher Deckers 22 | */ 23 | public class DragSelectTreeExample extends JPanel { 24 | 25 | public DragSelectTreeExample() { 26 | super(new BorderLayout(0, 0)); 27 | JDragSelectTree tree = new JDragSelectTree(); 28 | add(new JScrollPane(tree), BorderLayout.CENTER); 29 | } 30 | 31 | /* Standard main method to try that test as a standalone application. */ 32 | public static void main(String[] args) { 33 | SwingSuiteUtilities.setPreferredLookAndFeel(); 34 | SwingUtilities.invokeLater(new Runnable() { 35 | public void run() { 36 | JFrame frame = new JFrame("DJ Swing Suite Test"); 37 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 38 | frame.getContentPane().add(new DragSelectTreeExample(), BorderLayout.CENTER); 39 | frame.setSize(800, 600); 40 | frame.setLocationByPlatform(true); 41 | frame.setVisible(true); 42 | } 43 | }); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /DJSwingSuite-Demo/src/main/java/net/nextencia/dj/swingsuite/demo/common/ui/source/SourcePane.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Christopher Deckers (chrriis@nextencia.net) 3 | * http://www.nextencia.net 4 | * 5 | * See the file "readme.txt" for information on usage and redistribution of 6 | * this file, and for a DISCLAIMER OF ALL WARRANTIES. 7 | */ 8 | package net.nextencia.dj.swingsuite.demo.common.ui.source; 9 | 10 | import java.awt.Font; 11 | import java.awt.Rectangle; 12 | import java.awt.Toolkit; 13 | import java.io.Reader; 14 | 15 | import javax.swing.JEditorPane; 16 | import javax.swing.JViewport; 17 | import javax.swing.SwingConstants; 18 | 19 | public class SourcePane extends JEditorPane { 20 | 21 | public SourcePane(Reader reader) throws Exception { 22 | setFont(new Font("Monospaced", Font.PLAIN, 12)); 23 | setEditorKit(RegExJavaTypes.getEditorKit()); 24 | read(new TabFilterReader(reader), null); 25 | setEditable(false); 26 | } 27 | 28 | /** 29 | * Get the viewport size so that text does not wrap but horizontal scrollbar 30 | * appears instead. 31 | */ 32 | public boolean getScrollableTracksViewportWidth() { 33 | if (getParent() instanceof JViewport) { 34 | return getParent().getWidth() > getUI().getPreferredSize(this).width; 35 | } 36 | return false; 37 | } 38 | 39 | @SuppressWarnings("deprecation") 40 | @Override 41 | public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) { 42 | if(orientation == SwingConstants.VERTICAL) { 43 | return Toolkit.getDefaultToolkit().getFontMetrics(getFont()).getHeight(); 44 | } 45 | return super.getScrollableUnitIncrement(visibleRect, orientation, direction); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /DJSwingSuite-Demo/src/main/java/net/nextencia/dj/swingsuite/demo/examples/utilities/SearchReplaceRegExExample.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Christopher Deckers (chrriis@nextencia.net) 3 | * http://www.nextencia.net 4 | * 5 | * See the file "readme.txt" for information on usage and redistribution of 6 | * this file, and for a DISCLAIMER OF ALL WARRANTIES. 7 | */ 8 | package net.nextencia.dj.swingsuite.demo.examples.utilities; 9 | 10 | import java.awt.BorderLayout; 11 | 12 | import javax.swing.BorderFactory; 13 | import javax.swing.JFrame; 14 | import javax.swing.JPanel; 15 | import javax.swing.SwingUtilities; 16 | 17 | import net.nextencia.dj.swingsuite.JSedRegExBuilder; 18 | import net.nextencia.dj.swingsuite.SwingSuiteUtilities; 19 | 20 | /** 21 | * @author Christopher Deckers 22 | */ 23 | public class SearchReplaceRegExExample extends JPanel { 24 | 25 | public SearchReplaceRegExExample() { 26 | super(new BorderLayout()); 27 | setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); 28 | add(new JSedRegExBuilder("/lorem/xxx/g", "lorem ipsum"), BorderLayout.CENTER); 29 | } 30 | 31 | /* Standard main method to try that test as a standalone application. */ 32 | public static void main(String[] args) { 33 | SwingSuiteUtilities.setPreferredLookAndFeel(); 34 | SwingUtilities.invokeLater(new Runnable() { 35 | public void run() { 36 | JFrame frame = new JFrame("DJ Swing Suite Test"); 37 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 38 | frame.getContentPane().add(new SearchReplaceRegExExample(), BorderLayout.CENTER); 39 | frame.setSize(800, 600); 40 | frame.setLocationByPlatform(true); 41 | frame.setVisible(true); 42 | } 43 | }); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /DJSwingSuite-Demo/src/main/java/net/nextencia/dj/swingsuite/demo/common/ui/source/RegExTokenizer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Christopher Deckers (chrriis@nextencia.net) 3 | * http://www.nextencia.net 4 | * 5 | * See the file "readme.txt" for information on usage and redistribution of 6 | * this file, and for a DISCLAIMER OF ALL WARRANTIES. 7 | */ 8 | package net.nextencia.dj.swingsuite.demo.common.ui.source; 9 | 10 | import java.util.regex.Matcher; 11 | 12 | public class RegExTokenizer { 13 | 14 | public static class Token { 15 | public String token; 16 | public String type; 17 | protected int position; 18 | 19 | public Token(String token, String type, int position) { 20 | this.token = token; 21 | this.type = type; 22 | this.position = position; 23 | } 24 | 25 | public String getToken() { 26 | return token; 27 | } 28 | 29 | public String getType() { 30 | return type; 31 | } 32 | 33 | public int getPosition() { 34 | return position; 35 | } 36 | } 37 | 38 | protected RegExTypes types; 39 | protected Matcher matcher; 40 | 41 | public RegExTokenizer(RegExTypes types, String text) { 42 | this.types = types; 43 | matcher = types.getMatcher(text); 44 | } 45 | 46 | protected Token getToken(int position) { 47 | int count = types.getTypeCount(); 48 | for (int i = 1; i <= count; i++) { 49 | String token = matcher.group(i); 50 | if (token != null) { 51 | String type = types.getName(i - 1); 52 | return new Token(token, type, position); 53 | } 54 | } 55 | return null; 56 | } 57 | 58 | public Token nextToken() { 59 | if (matcher.find()) { 60 | return getToken(matcher.start()); 61 | } 62 | return null; 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /DJSwingSuite-Demo/src/main/java/net/nextencia/dj/swingsuite/demo/common/ui/source/TabFilterReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Christopher Deckers (chrriis@nextencia.net) 3 | * http://www.nextencia.net 4 | * 5 | * See the file "readme.txt" for information on usage and redistribution of 6 | * this file, and for a DISCLAIMER OF ALL WARRANTIES. 7 | */ 8 | package net.nextencia.dj.swingsuite.demo.common.ui.source; 9 | 10 | import java.io.FilterReader; 11 | import java.io.IOException; 12 | import java.io.Reader; 13 | 14 | public class TabFilterReader extends FilterReader { 15 | 16 | protected Reader reader; 17 | protected StringBuffer sb = new StringBuffer(); 18 | 19 | public TabFilterReader(Reader reader) { 20 | super(reader); 21 | this.reader = reader; 22 | } 23 | public int read() throws IOException { 24 | char c = (char)super.read(); 25 | if(c == '\t') { 26 | sb.append(' '); 27 | return ' '; 28 | } 29 | if(sb.length() > 0) { 30 | c = sb.charAt(0); 31 | sb.deleteCharAt(0); 32 | } 33 | return c; 34 | } 35 | public int read(char[] cbuf, int off, int len) throws IOException { 36 | int length = sb.length(); 37 | if(length > 0) { 38 | int count = Math.min(len, length); 39 | sb.getChars(0, count, cbuf, off); 40 | sb.delete(0, count); 41 | return count; 42 | } 43 | int result = super.read(cbuf, off, len); 44 | if(result > 0) { 45 | StringBuffer sb2 = new StringBuffer(); 46 | for(int i=off; i 47 | * This method is invoked by the validation mechanism so it needs to be properly implemented.. 48 | * @param textEntryField The text entry field for which to test the value. 49 | * @return A valid default text. 50 | */ 51 | public String getDefaultValidText(JTextEntryField textEntryField) { 52 | return ""; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /DJSwingSuite-Demo/src/main/java/net/nextencia/dj/swingsuite/demo/Example.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Christopher Deckers (chrriis@nextencia.net) 3 | * http://www.nextencia.net 4 | * 5 | * See the file "readme.txt" for information on usage and redistribution of 6 | * this file, and for a DISCLAIMER OF ALL WARRANTIES. 7 | */ 8 | package net.nextencia.dj.swingsuite.demo; 9 | 10 | import javax.swing.JComponent; 11 | 12 | /** 13 | * @author Christopher Deckers 14 | */ 15 | public class Example { 16 | 17 | protected String name; 18 | protected Class componentClass; 19 | protected String description; 20 | protected boolean isShowingSources; 21 | protected boolean isAvailable; 22 | protected String notAvailableMessage; 23 | 24 | public Example(String name, Class componentClass, String description, boolean isShowingSources) { 25 | this(name, componentClass, description, isShowingSources, true, null); 26 | } 27 | 28 | public Example(String name, Class componentClass, String description, boolean isShowingSources, boolean isAvailable, String notAvailableMessage) { 29 | this.name = name; 30 | this.componentClass = componentClass; 31 | this.description = description; 32 | this.isShowingSources = isShowingSources; 33 | this.isAvailable = isAvailable; 34 | this.notAvailableMessage = notAvailableMessage; 35 | } 36 | 37 | public Class getComponentClass() { 38 | return componentClass; 39 | } 40 | 41 | public String getName() { 42 | return name; 43 | } 44 | 45 | public String getDescription() { 46 | return description; 47 | } 48 | 49 | public boolean isShowingSources() { 50 | return isShowingSources; 51 | } 52 | 53 | public boolean isAvailable() { 54 | return isAvailable; 55 | } 56 | 57 | public String getNotAvailableMessage() { 58 | return notAvailableMessage; 59 | } 60 | 61 | @Override 62 | public String toString() { 63 | return name; 64 | } 65 | 66 | } -------------------------------------------------------------------------------- /DJSwingSuite-Demo/src/main/java/net/nextencia/dj/swingsuite/demo/examples/introduction/SwingSuite.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Christopher Deckers (chrriis@nextencia.net) 3 | * http://www.nextencia.net 4 | * 5 | * See the file "readme.txt" for information on usage and redistribution of 6 | * this file, and for a DISCLAIMER OF ALL WARRANTIES. 7 | */ 8 | package net.nextencia.dj.swingsuite.demo.examples.introduction; 9 | 10 | import java.awt.BorderLayout; 11 | 12 | import javax.swing.JEditorPane; 13 | import javax.swing.JPanel; 14 | import javax.swing.JScrollPane; 15 | 16 | /** 17 | * @author Christopher Deckers 18 | */ 19 | public class SwingSuite extends JPanel { 20 | 21 | protected static final String LS = System.getProperty("line.separator"); 22 | 23 | public SwingSuite() { 24 | super(new BorderLayout(0, 0)); 25 | JEditorPane editorPane = new JEditorPane("text/html", 26 | "" + LS + 27 | " " + LS + 28 | "

Why DJ Swing Suite?

" + LS + 29 | "

Swing is a powerful user-interface toolkit. It offers many components that one can customize in various ways.

" + LS + 30 | "

The problem is that after developping Swing applications for a while, we all find certain limitations and we keep re-inventing the wheel.

" + LS + 31 | "

A better wheel?

" + LS + 32 | "

Most of the time, we end up coding some components and utilities for the immediate task at hand: the result is hundreds of variations but no general purpose API.

" + LS + 33 | "

This project aims at creating such re-usable general purpose components and utilities to simplify the development of rich Swing user interfaces.

" + LS + 34 | "

Disclaimer

" + LS + 35 | "

Look and feels do not always behave in consistent ways, thus there is no guarantee that these components or utilities work as expected under non-tested look and feels. The only way to know is to try!

" + LS + 36 | " " + LS + 37 | "=0; i--) { 51 | int codePoint = text.codePointAt(i); 52 | if(getCodePoint(text, codePoint, i) == null) { 53 | return false; 54 | } 55 | } 56 | return true; 57 | } 58 | 59 | String getDefaultText() { 60 | int[] chars = new int[getLength()]; 61 | for(int i=0; i length) { 81 | return null; 82 | } 83 | int[] codePoints = getCodePoints(text); 84 | for(int i=textToInsert.length()-1; i>=0; i--) { 85 | Integer codePointToInsert = getCodePoint(text, textToInsert.codePointAt(i), position + i); 86 | if(codePointToInsert == null) { 87 | return null; 88 | } 89 | codePoints[position + i] = codePointToInsert; 90 | } 91 | return new String(codePoints, 0, codePoints.length); 92 | } 93 | 94 | String removeText(String text, int position, int length) { 95 | int[] codePoints = getCodePoints(text); 96 | for(int i=position+length-1; i>=position; i--) { 97 | codePoints[i] = getDefaultCodePoint(i); 98 | } 99 | return new String(codePoints, 0, codePoints.length); 100 | } 101 | 102 | } 103 | -------------------------------------------------------------------------------- /DJSwingSuite-Demo/src/main/java/net/nextencia/dj/swingsuite/demo/examples/utilities/TableColumnAutoFitExample.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Christopher Deckers (chrriis@nextencia.net) 3 | * http://www.nextencia.net 4 | * 5 | * See the file "readme.txt" for information on usage and redistribution of 6 | * this file, and for a DISCLAIMER OF ALL WARRANTIES. 7 | */ 8 | package net.nextencia.dj.swingsuite.demo.examples.utilities; 9 | 10 | import java.awt.BorderLayout; 11 | import java.awt.Color; 12 | import java.awt.FlowLayout; 13 | import java.awt.event.ActionEvent; 14 | import java.awt.event.ActionListener; 15 | 16 | import javax.swing.BorderFactory; 17 | import javax.swing.JButton; 18 | import javax.swing.JFrame; 19 | import javax.swing.JLabel; 20 | import javax.swing.JPanel; 21 | import javax.swing.JScrollPane; 22 | import javax.swing.JTable; 23 | import javax.swing.SwingUtilities; 24 | 25 | import net.nextencia.dj.swingsuite.SwingSuiteUtilities; 26 | 27 | /** 28 | * @author Christopher Deckers 29 | */ 30 | public class TableColumnAutoFitExample extends JPanel { 31 | 32 | public TableColumnAutoFitExample() { 33 | super(new BorderLayout()); 34 | JPanel tableContainer = new JPanel(new BorderLayout()); 35 | tableContainer.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10)); 36 | final JTable table = new JTable(new String[][] { 37 | {"Some data for C1 with a long description", "Some data for C2", "C3"}, 38 | {"Some data for C1", "Some data for C2", "C3"}, 39 | {"Some data for C1", "Some data for C2", "C3"}, 40 | }, new String[] {"Column 1", "Column 2 with a long title", "C3"}); 41 | if(SwingSuiteUtilities.IS_JAVA_6_OR_GREATER) { 42 | table.setAutoCreateRowSorter(true); 43 | table.setFillsViewportHeight(true); 44 | } 45 | table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); 46 | JScrollPane scrollPane = new JScrollPane(table); 47 | scrollPane.getViewport().setBackground(Color.WHITE); 48 | tableContainer.add(scrollPane, BorderLayout.CENTER); 49 | tableContainer.add(new JLabel("Note: cells are editable to test with different content."), BorderLayout.SOUTH); 50 | add(tableContainer, BorderLayout.CENTER); 51 | JPanel buttonPane = new JPanel(new FlowLayout()); 52 | JButton autoFitColumnButton = new JButton("Auto-fit second column"); 53 | autoFitColumnButton.addActionListener(new ActionListener() { 54 | public void actionPerformed(ActionEvent e) { 55 | SwingSuiteUtilities.autoFitTableColumn(table, 1, Integer.MAX_VALUE); 56 | } 57 | }); 58 | buttonPane.add(autoFitColumnButton); 59 | JButton autoFitAllButton = new JButton("Auto-fit all Columns"); 60 | autoFitAllButton.addActionListener(new ActionListener() { 61 | public void actionPerformed(ActionEvent e) { 62 | SwingSuiteUtilities.autoFitTableColumns(table, Integer.MAX_VALUE); 63 | } 64 | }); 65 | buttonPane.add(autoFitAllButton); 66 | JButton autoFitAllWithMaxButton = new JButton("Auto-fit all with max 50"); 67 | autoFitAllWithMaxButton.addActionListener(new ActionListener() { 68 | public void actionPerformed(ActionEvent e) { 69 | SwingSuiteUtilities.autoFitTableColumns(table, 50); 70 | } 71 | }); 72 | buttonPane.add(autoFitAllWithMaxButton); 73 | add(buttonPane, BorderLayout.SOUTH); 74 | } 75 | 76 | /* Standard main method to try that test as a standalone application. */ 77 | public static void main(String[] args) { 78 | SwingSuiteUtilities.setPreferredLookAndFeel(); 79 | SwingUtilities.invokeLater(new Runnable() { 80 | public void run() { 81 | JFrame frame = new JFrame("DJ Swing Suite Test"); 82 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 83 | frame.getContentPane().add(new TableColumnAutoFitExample(), BorderLayout.CENTER); 84 | frame.setSize(800, 600); 85 | frame.setLocationByPlatform(true); 86 | frame.setVisible(true); 87 | } 88 | }); 89 | } 90 | 91 | } 92 | -------------------------------------------------------------------------------- /DJSwingSuite-Demo/src/main/java/net/nextencia/dj/swingsuite/demo/examples/basiccomponents/JumpListMenuItemExample.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Christopher Deckers (chrriis@nextencia.net) 3 | * http://www.nextencia.net 4 | * 5 | * See the file "readme.txt" for information on usage and redistribution of 6 | * this file, and for a DISCLAIMER OF ALL WARRANTIES. 7 | */ 8 | package net.nextencia.dj.swingsuite.demo.examples.basiccomponents; 9 | 10 | import java.awt.BorderLayout; 11 | import java.awt.GridBagLayout; 12 | import java.awt.event.ActionEvent; 13 | import java.awt.event.ActionListener; 14 | import java.awt.event.MouseAdapter; 15 | import java.awt.event.MouseEvent; 16 | 17 | import javax.swing.JFrame; 18 | import javax.swing.JLabel; 19 | import javax.swing.JMenu; 20 | import javax.swing.JMenuItem; 21 | import javax.swing.JOptionPane; 22 | import javax.swing.JPanel; 23 | import javax.swing.JPopupMenu; 24 | import javax.swing.SwingUtilities; 25 | 26 | import net.nextencia.dj.swingsuite.JJumpListMenuItem; 27 | import net.nextencia.dj.swingsuite.SwingSuiteUtilities; 28 | 29 | /** 30 | * @author Christopher Deckers 31 | */ 32 | public class JumpListMenuItemExample extends JPanel { 33 | 34 | public JumpListMenuItemExample() { 35 | super(new BorderLayout(0, 0)); 36 | JPanel centerPane = new JPanel(new GridBagLayout()); 37 | centerPane.add(new JLabel("A pane with a popup menu")); 38 | centerPane.addMouseListener(new MouseAdapter() { 39 | @Override 40 | public void mousePressed(MouseEvent e) { 41 | processMouseEvent(e); 42 | } 43 | @Override 44 | public void mouseReleased(MouseEvent e) { 45 | processMouseEvent(e); 46 | } 47 | private void processMouseEvent(MouseEvent e) { 48 | if(e.isPopupTrigger()) { 49 | JPopupMenu popupMenu = new JPopupMenu(); 50 | popupMenu.add(new JMenuItem("A regular item")); 51 | JJumpListMenuItem jumpListMenuItem = new JJumpListMenuItem("An item with a jump list"); 52 | jumpListMenuItem.addActionListener(new ActionListener() { 53 | public void actionPerformed(ActionEvent e) { 54 | JOptionPane.showMessageDialog(JumpListMenuItemExample.this, "Main item selected."); 55 | } 56 | }); 57 | JMenu jumpListMenu = new JMenu(); 58 | JMenuItem jumpListItem1 = new JMenuItem("Jump item 1"); 59 | jumpListItem1.addActionListener(new ActionListener() { 60 | public void actionPerformed(ActionEvent e) { 61 | JOptionPane.showMessageDialog(JumpListMenuItemExample.this, "Jump list item item 1 selected."); 62 | } 63 | }); 64 | jumpListMenu.add(jumpListItem1); 65 | JMenuItem jumpListItem2 = new JMenuItem("Jump item 2"); 66 | jumpListItem2.addActionListener(new ActionListener() { 67 | public void actionPerformed(ActionEvent e) { 68 | JOptionPane.showMessageDialog(JumpListMenuItemExample.this, "Jump list item item 2 selected."); 69 | } 70 | }); 71 | jumpListMenu.add(jumpListItem2); 72 | jumpListMenuItem.setJumpListMenu(jumpListMenu); 73 | popupMenu.add(jumpListMenuItem); 74 | popupMenu.show(e.getComponent(), e.getX(), e.getY()); 75 | } 76 | } 77 | }); 78 | // Rest of the initialisation 79 | add(centerPane, BorderLayout.CENTER); 80 | } 81 | 82 | /* Standard main method to try that test as a standalone application. */ 83 | public static void main(String[] args) { 84 | SwingSuiteUtilities.setPreferredLookAndFeel(); 85 | SwingUtilities.invokeLater(new Runnable() { 86 | public void run() { 87 | JFrame frame = new JFrame("DJ Swing Suite Test"); 88 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 89 | frame.getContentPane().add(new JumpListMenuItemExample(), BorderLayout.CENTER); 90 | frame.setSize(800, 600); 91 | frame.setLocationByPlatform(true); 92 | frame.setVisible(true); 93 | } 94 | }); 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /DJSwingSuite-Demo/src/main/java/net/nextencia/dj/swingsuite/demo/examples/basiccomponents/WidePopupComboBoxExample.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Christopher Deckers (chrriis@nextencia.net) 3 | * http://www.nextencia.net 4 | * 5 | * See the file "readme.txt" for information on usage and redistribution of 6 | * this file, and for a DISCLAIMER OF ALL WARRANTIES. 7 | */ 8 | package net.nextencia.dj.swingsuite.demo.examples.basiccomponents; 9 | 10 | import java.awt.BorderLayout; 11 | import java.awt.Dimension; 12 | import java.awt.GridBagConstraints; 13 | import java.awt.GridBagLayout; 14 | import java.awt.Insets; 15 | 16 | import javax.swing.JFrame; 17 | import javax.swing.JLabel; 18 | import javax.swing.JPanel; 19 | import javax.swing.JScrollPane; 20 | import javax.swing.SwingUtilities; 21 | 22 | import net.nextencia.dj.swingsuite.JWidePopupComboBox; 23 | import net.nextencia.dj.swingsuite.SwingSuiteUtilities; 24 | 25 | /** 26 | * @author Christopher Deckers 27 | */ 28 | public class WidePopupComboBoxExample extends JPanel { 29 | 30 | public WidePopupComboBoxExample() { 31 | super(new BorderLayout(0, 0)); 32 | JPanel centerPane = new JPanel(new GridBagLayout()); 33 | int y = 0; 34 | Insets insets = new Insets(0, 5, 10, 5); 35 | // A wide popup combo box without a size constraint. 36 | Object[] comboItems = new Object[] {"Item 1", "Item 2", "an item that is very long and messes up UIs when the combo box is the standard one"}; 37 | centerPane.add(new JLabel("Without width constraint: "), new GridBagConstraints(0, y, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0)); 38 | centerPane.add(new JWidePopupComboBox(comboItems), new GridBagConstraints(1, y++, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0)); 39 | // A wide popup combo box with a width constraint. 40 | centerPane.add(new JLabel("With width constraint: "), new GridBagConstraints(0, y, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0)); 41 | JWidePopupComboBox constrainedWidthComboBox = new JWidePopupComboBox(comboItems); 42 | constrainedWidthComboBox.setPreferredWidth(150, true); 43 | centerPane.add(constrainedWidthComboBox, new GridBagConstraints(1, y++, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0)); 44 | // A wide popup combo box with a preferred size. 45 | centerPane.add(new JLabel("With preferred size: "), new GridBagConstraints(0, y, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0)); 46 | JWidePopupComboBox preferredSizeComboBox = new JWidePopupComboBox(comboItems); 47 | preferredSizeComboBox.setPreferredSize(new Dimension(150, preferredSizeComboBox.getPreferredSize().height)); 48 | centerPane.add(preferredSizeComboBox, new GridBagConstraints(1, y++, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0)); 49 | // An editable wide popup combo box with a width constraint. 50 | centerPane.add(new JLabel("With width constraint, editable: "), new GridBagConstraints(0, y, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0)); 51 | JWidePopupComboBox constrainedWidthEditableComboBox = new JWidePopupComboBox(comboItems); 52 | constrainedWidthEditableComboBox.setPreferredWidth(150, true); 53 | constrainedWidthEditableComboBox.setEditable(true); 54 | centerPane.add(constrainedWidthEditableComboBox, new GridBagConstraints(1, y++, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0)); 55 | // Rest of the initialisation 56 | add(new JScrollPane(centerPane), BorderLayout.CENTER); 57 | } 58 | 59 | /* Standard main method to try that test as a standalone application. */ 60 | public static void main(String[] args) { 61 | SwingSuiteUtilities.setPreferredLookAndFeel(); 62 | SwingUtilities.invokeLater(new Runnable() { 63 | public void run() { 64 | JFrame frame = new JFrame("DJ Swing Suite Test"); 65 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 66 | frame.getContentPane().add(new WidePopupComboBoxExample(), BorderLayout.CENTER); 67 | frame.setSize(800, 600); 68 | frame.setLocationByPlatform(true); 69 | frame.setVisible(true); 70 | } 71 | }); 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /DJSwingSuite-Demo/src/main/java/net/nextencia/dj/swingsuite/demo/common/ui/source/RegExTypes.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Christopher Deckers (chrriis@nextencia.net) 3 | * http://www.nextencia.net 4 | * 5 | * See the file "readme.txt" for information on usage and redistribution of 6 | * this file, and for a DISCLAIMER OF ALL WARRANTIES. 7 | */ 8 | package net.nextencia.dj.swingsuite.demo.common.ui.source; 9 | 10 | import java.awt.Color; 11 | import java.awt.Font; 12 | import java.util.ArrayList; 13 | import java.util.HashMap; 14 | import java.util.List; 15 | import java.util.Map; 16 | import java.util.regex.Matcher; 17 | import java.util.regex.Pattern; 18 | 19 | import javax.swing.text.Style; 20 | import javax.swing.text.StyleConstants; 21 | import javax.swing.text.StyledDocument; 22 | 23 | public class RegExTypes { 24 | 25 | public static class WordStyle { 26 | protected String name; 27 | protected Color color; 28 | protected int fontstyle; 29 | 30 | public WordStyle(String name2, Color color2, int fontstyle2) { 31 | name = name2; 32 | color = color2; 33 | fontstyle = fontstyle2; 34 | } 35 | } 36 | 37 | public static class Type { 38 | protected String name; 39 | protected String expression; 40 | protected Color color; 41 | protected int fontstyle; 42 | 43 | public Type(String name, String expression, Color color, int fontstyle) { 44 | this.name = name; 45 | this.expression = expression; 46 | this.color = color; 47 | this.fontstyle = fontstyle; 48 | } 49 | } 50 | 51 | protected List typeList; 52 | protected List wordstyleList; 53 | 54 | public RegExTypes() { 55 | typeList = new ArrayList(); 56 | wordstyleList = new ArrayList(); 57 | } 58 | 59 | public void addTokenType(String name, String expr, Color color, int fontstyle) { 60 | typeList.add(new Type(name, expr, color, fontstyle)); 61 | } 62 | 63 | public void addWordStyle(String name, Color color, int fontstyle) { 64 | wordstyleList.add(new WordStyle(name, color, fontstyle)); 65 | } 66 | 67 | protected Type getType(int index) { 68 | return typeList.get(index); 69 | } 70 | 71 | public String getExpr(int index) { 72 | return getType(index).expression; 73 | } 74 | 75 | public void setStyles(StyledDocument document) { 76 | for (int i = 0; i < typeList.size(); i++) { 77 | Type type = getType(i); 78 | String name = type.name; 79 | Color color = type.color; 80 | int fontStyle = type.fontstyle; 81 | setStyle(document, name, color, fontStyle); 82 | } 83 | 84 | for (int i = 0; i < wordstyleList.size(); i++) { 85 | WordStyle wordStyle = wordstyleList.get(i); 86 | String name = wordStyle.name; 87 | Color color = wordStyle.color; 88 | int fontStyle = wordStyle.fontstyle; 89 | setStyle(document, name, color, fontStyle); 90 | } 91 | 92 | } 93 | 94 | private void setStyle(StyledDocument doc, String name, Color color, int fontStyle) { 95 | if (color != null) { 96 | Style style = doc.addStyle(name, null); 97 | StyleConstants.setForeground(style, color); 98 | if (fontStyle == Font.BOLD) 99 | StyleConstants.setBold(style, true); 100 | if (fontStyle == Font.ITALIC) 101 | StyleConstants.setItalic(style, true); 102 | } 103 | } 104 | 105 | public String getExpression() { 106 | StringBuffer buffer = new StringBuffer(); 107 | for (int i = 0; i < getTypeCount(); i++) { 108 | if (i > 0) 109 | buffer.append('|'); 110 | buffer.append('('); 111 | buffer.append(getExpr(i)); 112 | buffer.append(')'); 113 | } 114 | return buffer.toString(); 115 | } 116 | 117 | public Pattern getPattern() { 118 | return Pattern.compile(getExpression(), Pattern.DOTALL); 119 | } 120 | 121 | public Matcher getMatcher(String text) { 122 | return getPattern().matcher(text); 123 | } 124 | 125 | protected Map wordToStyleMap = new HashMap(); 126 | 127 | public String getStyleName(String word) { 128 | return wordToStyleMap.get(word); 129 | } 130 | 131 | public void putStyleName(String word, String styleName) { 132 | wordToStyleMap.put(word, styleName); 133 | } 134 | 135 | public String getName(int index) { 136 | return typeList.get(index).name; 137 | } 138 | 139 | public int getTypeCount() { 140 | return typeList.size(); 141 | } 142 | 143 | public Object getColor(int index) { 144 | return typeList.get(index).color; 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /DJSwingSuite-Demo/src/main/java/net/nextencia/dj/swingsuite/demo/common/ui/source/RegExJavaTypes.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Christopher Deckers (chrriis@nextencia.net) 3 | * http://www.nextencia.net 4 | * 5 | * See the file "readme.txt" for information on usage and redistribution of 6 | * this file, and for a DISCLAIMER OF ALL WARRANTIES. 7 | */ 8 | package net.nextencia.dj.swingsuite.demo.common.ui.source; 9 | 10 | import java.awt.Color; 11 | import java.awt.Font; 12 | 13 | import javax.swing.text.AttributeSet; 14 | import javax.swing.text.BadLocationException; 15 | import javax.swing.text.Document; 16 | import javax.swing.text.EditorKit; 17 | import javax.swing.text.StyledEditorKit; 18 | 19 | 20 | /** 21 | * A definition of tokens. 22 | * @version 1.0 2004.02.09 23 | * @author Christopher Deckers (chrriis@nextencia.net) 24 | */ 25 | public class RegExJavaTypes extends RegExTypes { 26 | public static final String CHAR = "char"; 27 | public static final String TEXT = "text"; 28 | public static final String ATOM = "atom"; 29 | // public static final String NUMBER = "number"; 30 | public static final String JAVADOC_COMMENT = "JavadocComment"; 31 | public static final String MULTI_LINE_COMMENT = "MultiLineComment"; 32 | public static final String SINGLE_LINE_COMMENT = "SingleLineComment"; 33 | 34 | protected static final String STYLE = "Style"; 35 | 36 | public RegExJavaTypes() { 37 | addTokenType(JAVADOC_COMMENT, "/\\*\\*[^/](?:(?!\\*/).)*(?:\\*/)?", new Color(63, 95, 191), Font.PLAIN); 38 | addTokenType(MULTI_LINE_COMMENT, "/\\*(?:(?!\\*/).)*(?:\\*/)?", new Color(63, 127, 95), Font.PLAIN); 39 | addTokenType(SINGLE_LINE_COMMENT, "//(?:[^\n]*)", new Color(63, 127, 95), Font.PLAIN); 40 | addTokenType(ATOM, "[a-zA-Z]\\w*", null, Font.PLAIN); 41 | addTokenType(CHAR, "'(?>(?:\\\\.)|.)'", new Color(42, 0, 255), Font.PLAIN); 42 | addTokenType(TEXT, "\"(?:(\\\\.)*(?:(?![\"\n]).))*[\"]?", new Color(42, 0, 255), Font.PLAIN); 43 | // addTokenType(CHAR, "'(?:\\\\[^']+|[^'])'", Color.blue, Font.PLAIN); 44 | // addTokenType(NUMBER, "[0-9]+(\\.[0-9]+)?", Color.magenta, Font.PLAIN); 45 | 46 | putStyleName("void", STYLE); 47 | putStyleName("null", STYLE); 48 | putStyleName("boolean", STYLE); 49 | putStyleName("byte", STYLE); 50 | putStyleName("char", STYLE); 51 | putStyleName("short", STYLE); 52 | putStyleName("int", STYLE); 53 | putStyleName("long", STYLE); 54 | putStyleName("float", STYLE); 55 | putStyleName("double", STYLE); 56 | putStyleName("import", STYLE); 57 | putStyleName("package", STYLE); 58 | putStyleName("class", STYLE); 59 | putStyleName("interface", STYLE); 60 | putStyleName("extends", STYLE); 61 | putStyleName("implements", STYLE); 62 | putStyleName("public", STYLE); 63 | putStyleName("protected", STYLE); 64 | putStyleName("private", STYLE); 65 | putStyleName("abstract", STYLE); 66 | putStyleName("static", STYLE); 67 | putStyleName("final", STYLE); 68 | putStyleName("native", STYLE); 69 | putStyleName("return", STYLE); 70 | putStyleName("volatile", STYLE); 71 | putStyleName("transient", STYLE); 72 | putStyleName("throws", STYLE); 73 | putStyleName("synchronized", STYLE); 74 | putStyleName("try", STYLE); 75 | putStyleName("catch", STYLE); 76 | putStyleName("finally", STYLE); 77 | putStyleName("throw", STYLE); 78 | putStyleName("new", STYLE); 79 | putStyleName("super", STYLE); 80 | putStyleName("this", STYLE); 81 | putStyleName("true", STYLE); 82 | putStyleName("false", STYLE); 83 | putStyleName("if", STYLE); 84 | putStyleName("else", STYLE); 85 | putStyleName("for", STYLE); 86 | putStyleName("do", STYLE); 87 | putStyleName("while", STYLE); 88 | putStyleName("switch", STYLE); 89 | putStyleName("case", STYLE); 90 | putStyleName("break", STYLE); 91 | putStyleName("continue", STYLE); 92 | putStyleName("goto", STYLE); 93 | putStyleName("instanceof", STYLE); 94 | putStyleName("strictfp", STYLE); 95 | putStyleName("const", STYLE); 96 | putStyleName("default", STYLE); 97 | addWordStyle(STYLE, new Color(120, 0, 100), Font.BOLD); 98 | } 99 | 100 | public static EditorKit getEditorKit() { 101 | return new StyledEditorKit() { 102 | public Document createDefaultDocument() { 103 | return new EditorKitDocument(new RegExJavaTypes()) { 104 | public void insertString(int offset, String text, AttributeSet style) throws BadLocationException { 105 | super.insertString(offset, text, style); 106 | } 107 | }; 108 | } 109 | }; 110 | } 111 | 112 | } 113 | -------------------------------------------------------------------------------- /DJSwingSuite/src/main/java/net/nextencia/dj/swingsuite/JWidePopupComboBox.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Christopher Deckers (chrriis@nextencia.net) 3 | * http://www.nextencia.net 4 | * 5 | * See the file "readme.txt" for information on usage and redistribution of 6 | * this file, and for a DISCLAIMER OF ALL WARRANTIES. 7 | */ 8 | package net.nextencia.dj.swingsuite; 9 | 10 | import java.awt.Dimension; 11 | import java.util.Vector; 12 | 13 | import javax.swing.ComboBoxModel; 14 | import javax.swing.JComboBox; 15 | 16 | /** 17 | * A combo box which allows a wide popup when the combo size is smaller than long items it contains. 18 | * @author Christopher Deckers 19 | */ 20 | public class JWidePopupComboBox extends JComboBox { 21 | 22 | public JWidePopupComboBox() { 23 | } 24 | 25 | public JWidePopupComboBox(final E items[]) { 26 | super(items); 27 | } 28 | 29 | public JWidePopupComboBox(Vector items) { 30 | super(items); 31 | } 32 | 33 | public JWidePopupComboBox(ComboBoxModel aModel) { 34 | super(aModel); 35 | } 36 | 37 | private boolean layingOut; 38 | 39 | @Override 40 | public void doLayout() { 41 | try { 42 | layingOut = true; 43 | super.doLayout(); 44 | } finally { 45 | layingOut = false; 46 | } 47 | } 48 | 49 | @Override 50 | public Dimension getSize() { 51 | Dimension size = super.getSize(); 52 | if(!layingOut) { 53 | size.width = Math.max(size.width, super.getPreferredSize().width); 54 | } 55 | return size; 56 | } 57 | 58 | private Integer preferredWidth; 59 | private boolean isSmallerDefaultPreferredSizeAllowed; 60 | 61 | /** 62 | * Set the preferred width of the combo, which is taken into account in the preferred size computations. 63 | * @param preferredWidth the preferred width to set, or null to clear it. 64 | * @param isSmallerDefaultPreferredSizeAllowed true to let getPreferredSize() return the default preferred size if it is smaller than this preferred width. 65 | */ 66 | public void setPreferredWidth(Integer preferredWidth, boolean isSmallerDefaultPreferredSizeAllowed) { 67 | this.preferredWidth = preferredWidth; 68 | this.isSmallerDefaultPreferredSizeAllowed = isSmallerDefaultPreferredSizeAllowed; 69 | super.setPreferredSize(null); 70 | } 71 | 72 | /** 73 | * Get the preferred width of the combo. 74 | * @return the preferred width, or null if it is not set. 75 | */ 76 | public Integer getPreferredWidth() { 77 | return preferredWidth; 78 | } 79 | 80 | public boolean isSmallerDefaultPreferredSizeAllowed() { 81 | return isSmallerDefaultPreferredSizeAllowed; 82 | } 83 | 84 | @Override 85 | public void setPreferredSize(Dimension preferredSize) { 86 | preferredWidth = null; 87 | super.setPreferredSize(preferredSize); 88 | } 89 | 90 | private Integer maximumWidth; 91 | 92 | /** 93 | * Set the maximum width of the combo, which is taken into account in the maximum size computations. 94 | * @param maximumWidth the maximum width to set, or null to clear it. 95 | */ 96 | public void setMaximumWidth(Integer maximumWidth) { 97 | this.maximumWidth = maximumWidth; 98 | super.setMaximumSize(null); 99 | } 100 | 101 | /** 102 | * Get the maximum width of the combo. 103 | * @return the maximum width, or null if it is not set. 104 | */ 105 | public Integer getMaximumWidth() { 106 | return maximumWidth; 107 | } 108 | 109 | @Override 110 | public void setMaximumSize(Dimension maximumSize) { 111 | maximumWidth = null; 112 | super.setMaximumSize(maximumSize); 113 | } 114 | 115 | @Override 116 | public Dimension getPreferredSize() { 117 | Dimension preferredSize = super.getPreferredSize(); 118 | if(isPreferredSizeSet()) { 119 | return preferredSize; 120 | } 121 | if(preferredWidth != null && (!isSmallerDefaultPreferredSizeAllowed || preferredSize.width > preferredWidth)) { 122 | preferredSize.width = preferredWidth; 123 | } 124 | return preferredSize; 125 | } 126 | 127 | @Override 128 | public Dimension getMaximumSize() { 129 | Dimension maximumSize = super.getMaximumSize(); 130 | if(isMaximumSizeSet()) { 131 | return maximumSize; 132 | } 133 | if(maximumWidth != null) { 134 | maximumSize.width = maximumWidth; 135 | } 136 | return maximumSize; 137 | } 138 | 139 | @Override 140 | public Dimension getMinimumSize() { 141 | Dimension minimumSize = super.getMinimumSize(); 142 | if(isMinimumSizeSet()) { 143 | return minimumSize; 144 | } 145 | if(preferredWidth != null && preferredWidth < minimumSize.width) { 146 | minimumSize.width = preferredWidth; 147 | } 148 | return minimumSize; 149 | } 150 | 151 | } 152 | -------------------------------------------------------------------------------- /DJSwingSuite/DJSwingSuite/documentation/javadoc-package-lists/jdk/package-list: -------------------------------------------------------------------------------- 1 | java.applet 2 | java.awt 3 | java.awt.color 4 | java.awt.datatransfer 5 | java.awt.dnd 6 | java.awt.event 7 | java.awt.font 8 | java.awt.geom 9 | java.awt.im 10 | java.awt.im.spi 11 | java.awt.image 12 | java.awt.image.renderable 13 | java.awt.print 14 | java.beans 15 | java.beans.beancontext 16 | java.io 17 | java.lang 18 | java.lang.annotation 19 | java.lang.instrument 20 | java.lang.management 21 | java.lang.ref 22 | java.lang.reflect 23 | java.math 24 | java.net 25 | java.nio 26 | java.nio.channels 27 | java.nio.channels.spi 28 | java.nio.charset 29 | java.nio.charset.spi 30 | java.rmi 31 | java.rmi.activation 32 | java.rmi.dgc 33 | java.rmi.registry 34 | java.rmi.server 35 | java.security 36 | java.security.acl 37 | java.security.cert 38 | java.security.interfaces 39 | java.security.spec 40 | java.sql 41 | java.text 42 | java.text.spi 43 | java.util 44 | java.util.concurrent 45 | java.util.concurrent.atomic 46 | java.util.concurrent.locks 47 | java.util.jar 48 | java.util.logging 49 | java.util.prefs 50 | java.util.regex 51 | java.util.spi 52 | java.util.zip 53 | javax.accessibility 54 | javax.activation 55 | javax.activity 56 | javax.annotation 57 | javax.annotation.processing 58 | javax.crypto 59 | javax.crypto.interfaces 60 | javax.crypto.spec 61 | javax.imageio 62 | javax.imageio.event 63 | javax.imageio.metadata 64 | javax.imageio.plugins.bmp 65 | javax.imageio.plugins.jpeg 66 | javax.imageio.spi 67 | javax.imageio.stream 68 | javax.jws 69 | javax.jws.soap 70 | javax.lang.model 71 | javax.lang.model.element 72 | javax.lang.model.type 73 | javax.lang.model.util 74 | javax.management 75 | javax.management.loading 76 | javax.management.modelmbean 77 | javax.management.monitor 78 | javax.management.openmbean 79 | javax.management.relation 80 | javax.management.remote 81 | javax.management.remote.rmi 82 | javax.management.timer 83 | javax.naming 84 | javax.naming.directory 85 | javax.naming.event 86 | javax.naming.ldap 87 | javax.naming.spi 88 | javax.net 89 | javax.net.ssl 90 | javax.print 91 | javax.print.attribute 92 | javax.print.attribute.standard 93 | javax.print.event 94 | javax.rmi 95 | javax.rmi.CORBA 96 | javax.rmi.ssl 97 | javax.script 98 | javax.security.auth 99 | javax.security.auth.callback 100 | javax.security.auth.kerberos 101 | javax.security.auth.login 102 | javax.security.auth.spi 103 | javax.security.auth.x500 104 | javax.security.cert 105 | javax.security.sasl 106 | javax.sound.midi 107 | javax.sound.midi.spi 108 | javax.sound.sampled 109 | javax.sound.sampled.spi 110 | javax.sql 111 | javax.sql.rowset 112 | javax.sql.rowset.serial 113 | javax.sql.rowset.spi 114 | javax.swing 115 | javax.swing.border 116 | javax.swing.colorchooser 117 | javax.swing.event 118 | javax.swing.filechooser 119 | javax.swing.plaf 120 | javax.swing.plaf.basic 121 | javax.swing.plaf.metal 122 | javax.swing.plaf.multi 123 | javax.swing.plaf.synth 124 | javax.swing.table 125 | javax.swing.text 126 | javax.swing.text.html 127 | javax.swing.text.html.parser 128 | javax.swing.text.rtf 129 | javax.swing.tree 130 | javax.swing.undo 131 | javax.tools 132 | javax.transaction 133 | javax.transaction.xa 134 | javax.xml 135 | javax.xml.bind 136 | javax.xml.bind.annotation 137 | javax.xml.bind.annotation.adapters 138 | javax.xml.bind.attachment 139 | javax.xml.bind.helpers 140 | javax.xml.bind.util 141 | javax.xml.crypto 142 | javax.xml.crypto.dom 143 | javax.xml.crypto.dsig 144 | javax.xml.crypto.dsig.dom 145 | javax.xml.crypto.dsig.keyinfo 146 | javax.xml.crypto.dsig.spec 147 | javax.xml.datatype 148 | javax.xml.namespace 149 | javax.xml.parsers 150 | javax.xml.soap 151 | javax.xml.stream 152 | javax.xml.stream.events 153 | javax.xml.stream.util 154 | javax.xml.transform 155 | javax.xml.transform.dom 156 | javax.xml.transform.sax 157 | javax.xml.transform.stax 158 | javax.xml.transform.stream 159 | javax.xml.validation 160 | javax.xml.ws 161 | javax.xml.ws.handler 162 | javax.xml.ws.handler.soap 163 | javax.xml.ws.http 164 | javax.xml.ws.soap 165 | javax.xml.ws.spi 166 | javax.xml.xpath 167 | org.ietf.jgss 168 | org.omg.CORBA 169 | org.omg.CORBA.DynAnyPackage 170 | org.omg.CORBA.ORBPackage 171 | org.omg.CORBA.TypeCodePackage 172 | org.omg.CORBA.portable 173 | org.omg.CORBA_2_3 174 | org.omg.CORBA_2_3.portable 175 | org.omg.CosNaming 176 | org.omg.CosNaming.NamingContextExtPackage 177 | org.omg.CosNaming.NamingContextPackage 178 | org.omg.Dynamic 179 | org.omg.DynamicAny 180 | org.omg.DynamicAny.DynAnyFactoryPackage 181 | org.omg.DynamicAny.DynAnyPackage 182 | org.omg.IOP 183 | org.omg.IOP.CodecFactoryPackage 184 | org.omg.IOP.CodecPackage 185 | org.omg.Messaging 186 | org.omg.PortableInterceptor 187 | org.omg.PortableInterceptor.ORBInitInfoPackage 188 | org.omg.PortableServer 189 | org.omg.PortableServer.CurrentPackage 190 | org.omg.PortableServer.POAManagerPackage 191 | org.omg.PortableServer.POAPackage 192 | org.omg.PortableServer.ServantLocatorPackage 193 | org.omg.PortableServer.portable 194 | org.omg.SendingContext 195 | org.omg.stub.java.rmi 196 | org.w3c.dom 197 | org.w3c.dom.bootstrap 198 | org.w3c.dom.events 199 | org.w3c.dom.ls 200 | org.xml.sax 201 | org.xml.sax.ext 202 | org.xml.sax.helpers 203 | -------------------------------------------------------------------------------- /DJSwingSuite/src/main/java/net/nextencia/dj/swingsuite/JTitledSeparator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Christopher Deckers (chrriis@nextencia.net) 3 | * http://www.nextencia.net 4 | * 5 | * See the file "readme.txt" for information on usage and redistribution of 6 | * this file, and for a DISCLAIMER OF ALL WARRANTIES. 7 | */ 8 | package net.nextencia.dj.swingsuite; 9 | 10 | import java.awt.AlphaComposite; 11 | import java.awt.BorderLayout; 12 | import java.awt.Color; 13 | import java.awt.Composite; 14 | import java.awt.Dimension; 15 | import java.awt.Font; 16 | import java.awt.Graphics; 17 | import java.awt.Graphics2D; 18 | import java.awt.GridBagConstraints; 19 | import java.awt.GridBagLayout; 20 | import java.awt.Insets; 21 | 22 | import javax.swing.BorderFactory; 23 | import javax.swing.JLabel; 24 | import javax.swing.JPanel; 25 | import javax.swing.JSeparator; 26 | import javax.swing.UIManager; 27 | import javax.swing.border.TitledBorder; 28 | 29 | /** 30 | * A separator with a title. 31 | * @author Christopher Deckers 32 | */ 33 | public class JTitledSeparator extends JPanel { 34 | 35 | private final class SeparatorPane extends JPanel { 36 | private SeparatorPane() { 37 | super(new GridBagLayout()); 38 | setOpaque(false); 39 | setDoubleBuffered(false); 40 | JSeparator separator = new JSeparator() { 41 | @Override 42 | protected void paintComponent(Graphics g) { 43 | Graphics2D g2d = (Graphics2D)g; 44 | Composite composite = g2d.getComposite(); 45 | g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f)); 46 | super.paintComponent(g); 47 | g2d.setComposite(composite); 48 | } 49 | }; 50 | add(separator, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); 51 | } 52 | 53 | @SuppressWarnings("deprecation") 54 | @Override 55 | public void reshape(int x, int y, int w, int h) { 56 | super.reshape(x, y, w, h); 57 | doLayout(); 58 | } 59 | } 60 | 61 | private SeparatorPane westSeparator; 62 | private JLabel label = new JLabel(); 63 | 64 | /** 65 | * Construct a separator with a title. 66 | * @param title the title to set. 67 | */ 68 | public JTitledSeparator(String title) { 69 | super(new BorderLayout()); 70 | JPanel westPanel = new JPanel(new BorderLayout()) { 71 | @SuppressWarnings("deprecation") 72 | @Override 73 | public void reshape(int x, int y, int w, int h) { 74 | super.reshape(x, y, w, h); 75 | doLayout(); 76 | } 77 | }; 78 | westPanel.setOpaque(false); 79 | westPanel.setDoubleBuffered(false); 80 | westSeparator = new SeparatorPane(); 81 | boolean isLeftToRight = getComponentOrientation().isLeftToRight(); 82 | if(isLeftToRight) { 83 | westSeparator.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 1)); 84 | westPanel.add(westSeparator, BorderLayout.WEST); 85 | } else { 86 | westSeparator.setBorder(BorderFactory.createEmptyBorder(0, 1, 0, 0)); 87 | westPanel.add(westSeparator, BorderLayout.EAST); 88 | } 89 | setOpaque(false); 90 | westPanel.add(label, BorderLayout.CENTER); 91 | if(isLeftToRight) { 92 | add(westPanel, BorderLayout.WEST); 93 | } else { 94 | add(westPanel, BorderLayout.EAST); 95 | } 96 | SeparatorPane separatorPane = new SeparatorPane(); 97 | if(isLeftToRight) { 98 | separatorPane.setBorder(BorderFactory.createEmptyBorder(0, 1, 0, 0)); 99 | } else { 100 | separatorPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 1)); 101 | } 102 | add(separatorPane, BorderLayout.CENTER); 103 | setTitle(title); 104 | adjustLook(); 105 | } 106 | 107 | /** 108 | * Get the title of this separator. 109 | * @return the title. 110 | */ 111 | public String getTitle() { 112 | return label.getText(); 113 | } 114 | 115 | /** 116 | * Set the title of the separator. 117 | * @param title the new title. 118 | */ 119 | public void setTitle(String title) { 120 | if(title == null) { 121 | title = ""; 122 | } 123 | boolean isVisible = title.length() != 0; 124 | westSeparator.setVisible(isVisible); 125 | label.setVisible(isVisible); 126 | label.setText(title); 127 | } 128 | 129 | @Override 130 | public void updateUI() { 131 | super.updateUI(); 132 | adjustLook(); 133 | } 134 | 135 | private void adjustLook() { 136 | if(westSeparator != null) { 137 | westSeparator.setPreferredSize(new Dimension(new JLabel("M").getPreferredSize().width, westSeparator.getPreferredSize().height)); 138 | } 139 | if(label != null) { 140 | Color titleColor = UIManager.getColor("TitledBorder.titleColor"); 141 | Font font = UIManager.getFont("TitledBorder.font"); 142 | if(titleColor == null || font == null) { 143 | TitledBorder titledBorder = new TitledBorder(""); 144 | titleColor = titledBorder.getTitleColor(); 145 | font = titledBorder.getTitleFont(); 146 | } 147 | label.setForeground(titleColor); 148 | label.setFont(font); 149 | } 150 | } 151 | 152 | } 153 | -------------------------------------------------------------------------------- /DJSwingSuite-Demo/src/main/java/net/nextencia/dj/swingsuite/demo/examples/utilities/FilterableTableHeaderExample.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Christopher Deckers (chrriis@nextencia.net) 3 | * http://www.nextencia.net 4 | * 5 | * See the file "readme.txt" for information on usage and redistribution of 6 | * this file, and for a DISCLAIMER OF ALL WARRANTIES. 7 | */ 8 | package net.nextencia.dj.swingsuite.demo.examples.utilities; 9 | 10 | import java.awt.BorderLayout; 11 | import java.awt.Component; 12 | import java.sql.Timestamp; 13 | import java.text.DecimalFormat; 14 | import java.util.Date; 15 | 16 | import javax.swing.JFrame; 17 | import javax.swing.JPanel; 18 | import javax.swing.JScrollPane; 19 | import javax.swing.JTable; 20 | import javax.swing.SwingUtilities; 21 | import javax.swing.table.AbstractTableModel; 22 | import javax.swing.table.DefaultTableCellRenderer; 23 | import javax.swing.table.TableModel; 24 | import javax.swing.table.TableRowSorter; 25 | 26 | import net.nextencia.dj.swingsuite.DefaultTableHeaderFilter; 27 | import net.nextencia.dj.swingsuite.FilterableTableHeader; 28 | import net.nextencia.dj.swingsuite.SwingSuiteUtilities; 29 | import net.nextencia.dj.swingsuite.FilterableTableHeader.TableHeaderFilterChangeListener; 30 | 31 | /** 32 | * @author Christopher Deckers 33 | */ 34 | public class FilterableTableHeaderExample extends JPanel { 35 | 36 | public FilterableTableHeaderExample() { 37 | super(new BorderLayout()); 38 | final Object[][] rowData = new Object[][] { 39 | {"Bruce", "Pink", 48, getDate(16, 10, 2001)}, 40 | {"John", "Blue", -87112, getDate(28, 3, 2012)}, 41 | {"Adam", "Yellow", 56871, getDate(14, 11, 1995)}, 42 | {"John", "Black", 18, getDate(1, 1, 1998)}, 43 | {"Alfred", "Black", 52, getDate(17, 2, 2001)}, 44 | {"Adam", "Green", 4004, null}, 45 | {"Michel", "Red", 48810, getDate(14, 9, 2012)}, 46 | {"Aline", "Blue", 10, getDate(25, 12, 2004)}, 47 | }; 48 | final JTable table = new JTable(new AbstractTableModel() { 49 | @Override 50 | public String getColumnName(int column) { 51 | switch(column) { 52 | case 0: return "Name"; 53 | case 1: return "Color"; 54 | case 2: return "Number"; 55 | case 3: return "Date"; 56 | } 57 | return null; 58 | } 59 | public int getRowCount() { 60 | return rowData.length; 61 | } 62 | public int getColumnCount() { 63 | return 4; 64 | } 65 | public Object getValueAt(int row, int col) { 66 | return rowData[row][col]; 67 | } 68 | @Override 69 | public Class getColumnClass(int columnIndex) { 70 | switch(columnIndex) { 71 | case 2: return Integer.class; 72 | case 3: return Date.class; 73 | default: return String.class; 74 | } 75 | } 76 | }); 77 | // The table must have a row sorter for the filter logic to work. 78 | table.setAutoCreateRowSorter(true); 79 | // Now create the filterable header. 80 | final FilterableTableHeader filterableTableHeader = new FilterableTableHeader(table); 81 | DefaultTableHeaderFilter headerFilter = new DefaultTableHeaderFilter(); 82 | filterableTableHeader.setHeaderFilter(0, headerFilter); 83 | filterableTableHeader.setHeaderFilter(1, headerFilter); 84 | filterableTableHeader.setHeaderFilter(2, headerFilter); 85 | filterableTableHeader.setHeaderFilter(3, headerFilter); 86 | filterableTableHeader.addFilterChangeListener(new TableHeaderFilterChangeListener() { 87 | public void processFilterModification(int[] columns) { 88 | // Set the row filter, which triggers recomputation. 89 | ((TableRowSorter)table.getRowSorter()).setRowFilter(filterableTableHeader.getRowFilter()); 90 | } 91 | }); 92 | table.setTableHeader(filterableTableHeader); 93 | table.setDefaultRenderer(Integer.class, new DefaultTableCellRenderer() { 94 | @Override 95 | public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { 96 | if(value != null) { 97 | DecimalFormat format = new DecimalFormat("#,##0"); 98 | value = format.format(value); 99 | } 100 | return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); 101 | } 102 | }); 103 | add(new JScrollPane(table), BorderLayout.CENTER); 104 | } 105 | 106 | private static Date getDate(int day, int month, int year) { 107 | return new Timestamp(year - 1900, month - 1, day, 1, 1, 1, 1); 108 | } 109 | 110 | /* Standard main method to try that test as a standalone application. */ 111 | public static void main(String[] args) { 112 | SwingSuiteUtilities.setPreferredLookAndFeel(); 113 | SwingUtilities.invokeLater(new Runnable() { 114 | public void run() { 115 | JFrame frame = new JFrame("DJ Swing Suite Test"); 116 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 117 | frame.getContentPane().add(new FilterableTableHeaderExample(), BorderLayout.CENTER); 118 | frame.setSize(800, 600); 119 | frame.setLocationByPlatform(true); 120 | frame.setVisible(true); 121 | } 122 | }); 123 | } 124 | 125 | } 126 | -------------------------------------------------------------------------------- /DJSwingSuite/src/main/java/net/nextencia/dj/swingsuite/PatternTextEntryMask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Christopher Deckers (chrriis@nextencia.net) 3 | * http://www.nextencia.net 4 | * 5 | * See the file "readme.txt" for information on usage and redistribution of 6 | * this file, and for a DISCLAIMER OF ALL WARRANTIES. 7 | */ 8 | package net.nextencia.dj.swingsuite; 9 | 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | 13 | 14 | /** 15 | * @author Christopher Deckers 16 | */ 17 | public class PatternTextEntryMask extends TextEntryMask { 18 | 19 | private enum CharType { 20 | DIGIT, 21 | LETTER_TO_UPPERCASE, 22 | LETTER_TO_LOWERCASE, 23 | LETTER_OR_DIGIT, 24 | HEX_CHAR, 25 | ANY_LETTER, 26 | ANY_CHAR, 27 | PREDEFINED_CHAR, 28 | } 29 | 30 | private CharType[] charTypes; 31 | private int[] chars; 32 | private int defaultChar; 33 | 34 | public PatternTextEntryMask(String pattern) { 35 | this(pattern, '_'); 36 | } 37 | 38 | public PatternTextEntryMask(String pattern, int defaultChar) { 39 | if(pattern == null || pattern.length() == 0) { 40 | throw new IllegalArgumentException("The mask cannot be empty!"); 41 | } 42 | this.defaultChar = defaultChar; 43 | List charTypeList = new ArrayList(); 44 | List charList = new ArrayList(); 45 | boolean isLastQuote = false; 46 | int predefinedCount = 0; 47 | for(int i=0; i= '0' && codePoint <= '9' || codePoint >= 'a' && codePoint <= 'f' || codePoint >= 'A' && codePoint <= 'F') { 126 | return codePoint; 127 | } 128 | return null; 129 | case ANY_LETTER: 130 | if(!Character.isLetter(codePoint)) { 131 | return null; 132 | } 133 | return codePoint; 134 | case ANY_CHAR: 135 | return codePoint; 136 | case PREDEFINED_CHAR: 137 | if(codePoint != chars[position]) { 138 | return null; 139 | } 140 | return codePoint; 141 | } 142 | // Impossible case 143 | return null; 144 | } 145 | 146 | @Override 147 | protected int getLength() { 148 | return chars.length; 149 | } 150 | 151 | @Override 152 | protected int getNextValidInputPosition(int position) { 153 | for(int i=position; i getExampleGroupList() { 39 | List exampleGroupList = new ArrayList(); 40 | exampleGroupList.add(new ExampleGroup("Introduction", new Example[] { 41 | new Example("Swing Suite", SwingSuite.class, "The motivations behind this project.", false), 42 | })); 43 | exampleGroupList.add(new ExampleGroup("Basic Components", new Example[] { 44 | new Example("Combo button", ComboButtonExample.class, "Combo buttons are generally found in tool bars, often to offer a list of choices and optionally a default action.", true), 45 | new Example("Tri-state check box", TriStateCheckBoxExample.class, "Tri-state check boxes, with advanced capabilities like rolling cycle definition.", true), 46 | new Example("Link", LinkExample.class, "Users are generally familiar with links: they are simple, intuitive and generally provide some information through tool tips.", true), 47 | new Example("Extended label", ExtendedLabelExample.class, "A label that allows text selection and is multiline.", true), 48 | new Example("Jump list menus", JumpListMenuItemExample.class, "Jump list menus allow a menu item with a default behavior to offer additional actions.", true), 49 | new Example("Wide popup combo box", WidePopupComboBoxExample.class, "Wide popup combo boxes are a solution to the problem of having content that is too long. Such content generally messes up the user interface layout.", true), 50 | new Example("Drag-select tree", DragSelectTreeExample.class, "A tree where the user can click in the empty area, and drag the mouse over some nodes to select them. Modifiers (control and shift) can add or exclude to the current selection.", true), 51 | new Example("Titled separator", TitledSeparatorExample.class, "Titled separators are generally more elegant than titled borders and do not require nesting panels.", true), 52 | new Example("Time Editor", TimeEditorExample.class, "Time Editor with different precisions.", true), 53 | })); 54 | exampleGroupList.add(new ExampleGroup("Entry Fields", new Example[] { 55 | new Example("Text and Numbers", TextAndNumberFieldsExample.class, "This is a simple example that shows text and number fields.", true), 56 | new Example("Validators, Formatters, Masks", ValidatorsFormattersAndMasksExample.class, "How to use validators, formatters and masks to control inputs and improve usability.", true), 57 | })); 58 | exampleGroupList.add(new ExampleGroup("Utilities", new Example[] { 59 | new Example("Rich drag and drop", RichDragAndDrop.class, "The rich drag and drop manager allows to create an overlay image when performing a drag and drop operation (available with Java 6+ on systems supporting window alpha transparency).", true), 60 | new Example("Layered icon", LayeredIconExample.class, "A layered icon is an icon that aggregates icons, which can be at any location within their parent icon. Layered icons even support animated images in their composition.", true), 61 | new Example("Auto scroll", AutoScrollExample.class, "Enable the auto-scroll feature to simplify scrolling: a click with the middle mouse button then moving the mouse directs scrolling (as seen in web browsers).", true), 62 | new Example("Table column auto fit", TableColumnAutoFitExample.class, "Auto fit one or all the columns of a table.", true), 63 | new Example("Table header filters", FilterableTableHeaderExample.class, "Filter content of a table from the column headers.", true), 64 | new Example("Select all on focus", SelectAllOnFocusExample.class, "Make a text component select its entire text when it receives the focus. This utility takes care of proper selection in certain cases such as inaccurate click (mouse moves during the click).", true), 65 | new Example("Wildcards conversion", WildcardsConversionExample.class, "Convert a simple text with wildcards ('*' and '?', generally entered by the user) to a regular expression that can be used to filter/search.", true), 66 | })); 67 | return exampleGroupList; 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /DJSwingSuite/src/main/java/net/nextencia/dj/swingsuite/LayeredIcon.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Christopher Deckers (chrriis@nextencia.net) 3 | * http://www.nextencia.net 4 | * 5 | * See the file "readme.txt" for information on usage and redistribution of 6 | * this file, and for a DISCLAIMER OF ALL WARRANTIES. 7 | */ 8 | package net.nextencia.dj.swingsuite; 9 | 10 | import java.awt.Component; 11 | import java.awt.Graphics; 12 | import java.awt.Image; 13 | import java.awt.Point; 14 | import java.awt.event.HierarchyEvent; 15 | import java.awt.event.HierarchyListener; 16 | import java.awt.image.BufferedImage; 17 | import java.awt.image.ImageObserver; 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | import javax.swing.Icon; 22 | import javax.swing.ImageIcon; 23 | 24 | public class LayeredIcon extends ImageIcon { 25 | 26 | private List iconList = new ArrayList(3); 27 | private List iconLocationList = new ArrayList(3); 28 | 29 | private int width; 30 | private int height; 31 | 32 | public LayeredIcon(int width, int height) { 33 | this.width = width; 34 | this.height = height; 35 | } 36 | 37 | @Override 38 | public int getIconWidth() { 39 | return width; 40 | } 41 | 42 | @Override 43 | public int getIconHeight() { 44 | return height; 45 | } 46 | 47 | private Component component; 48 | 49 | @Override 50 | public void paintIcon(Component component, Graphics g, int x, int y) { 51 | if(component != null) { 52 | setComponent(component); 53 | } 54 | for(int i=0; i= 0) { 91 | iconList.remove(index); 92 | iconLocationList.remove(index); 93 | } 94 | } 95 | 96 | /** 97 | * Remove all icons. 98 | */ 99 | public void removeAllIcons() { 100 | iconList.clear(); 101 | iconLocationList.clear(); 102 | } 103 | 104 | /** 105 | * Add an icon starting at the top left corner. 106 | * @param icon the icon to add. 107 | */ 108 | public void addIcon(Icon icon) { 109 | addIcon(icon, new Point(0, 0)); 110 | } 111 | 112 | /** 113 | * Add an icon starting at a specific location. 114 | * @param icon the icon to add. 115 | * @param x the x coordinate. 116 | * @param y the y coordinate. 117 | */ 118 | public void addIcon(Icon icon, int x, int y) { 119 | addIcon(icon, new Point(x, y)); 120 | } 121 | 122 | private ImageObserver observer; 123 | private Image currentImage; 124 | 125 | /** 126 | * Add an icon starting at a specific location. 127 | * @param icon the icon to add. 128 | * @param location the location. 129 | */ 130 | public void addIcon(Icon icon, Point location) { 131 | addIcon(icon, location, getIconCount()); 132 | } 133 | 134 | /** 135 | * Add an icon starting at a specific location. 136 | * @param icon the icon to add. 137 | * @param location the location. 138 | * @param zOrder the zOrder of this icon, where 0 means at the back. 139 | */ 140 | public void addIcon(Icon icon, Point location, int zOrder) { 141 | iconList.add(zOrder, icon); 142 | iconLocationList.add(zOrder, location); 143 | if(icon instanceof ImageIcon) { 144 | if(observer == null) { 145 | observer = new ImageObserver() { 146 | public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) { 147 | if(component != null) { 148 | currentImage = img; 149 | boolean result = component.imageUpdate(img, infoflags, x, y, width, height); 150 | currentImage = null; 151 | return result; 152 | } 153 | return false; 154 | } 155 | }; 156 | } 157 | ((ImageIcon)icon).setImageObserver(observer); 158 | } 159 | } 160 | 161 | @Override 162 | public Image getImage() { 163 | if(currentImage == null) { 164 | // If an external API wants to get the image, we have to provide it on the fly. 165 | BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); 166 | paintIcon(component, img.getGraphics(), 0, 0); 167 | return img; 168 | } 169 | return currentImage; 170 | } 171 | 172 | public Component getComponent() { 173 | return component; 174 | } 175 | 176 | private HierarchyListener hierarchyListener = new HierarchyListener() { 177 | public void hierarchyChanged(HierarchyEvent e) { 178 | if(!component.isDisplayable()) { 179 | setComponent(null); 180 | } 181 | } 182 | }; 183 | 184 | /** 185 | * Set the component to which this icon is attached. 186 | * It is automatically set when paintComponent is called, but if that did not happen, it sometimes is needed to set it explicitely. 187 | * @param component The component to attach. 188 | */ 189 | public void setComponent(Component component) { 190 | if(component == this.component) { 191 | return; 192 | } 193 | if(this.component != null) { 194 | this.component.removeHierarchyListener(hierarchyListener); 195 | } 196 | if(component != null) { 197 | component.addHierarchyListener(hierarchyListener); 198 | } 199 | this.component = component; 200 | } 201 | 202 | } 203 | -------------------------------------------------------------------------------- /DJSwingSuite/src/main/java/net/nextencia/dj/swingsuite/SedRegExpPattern.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Christopher Deckers (chrriis@nextencia.net) 3 | * http://www.nextencia.net 4 | * 5 | * See the file "readme.txt" for information on usage and redistribution of 6 | * this file, and for a DISCLAIMER OF ALL WARRANTIES. 7 | */ 8 | package net.nextencia.dj.swingsuite; 9 | 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | import java.util.regex.Matcher; 13 | import java.util.regex.Pattern; 14 | 15 | /** 16 | * A "sed -e" like reg exp. 17 | * @author Christopher Deckers 18 | */ 19 | public class SedRegExpPattern { 20 | 21 | private static class SedRegExp { 22 | private Pattern pattern; 23 | private String replacement; 24 | private boolean isGlobal; 25 | public SedRegExp(String regExp, int index1, int index2, String originalRegExp) { 26 | String toFind = regExp.substring(0, index1); 27 | replacement = index2 == -1? null: regExp.substring(index1, index2); 28 | String modifiers = index2 == -1? regExp.substring(index1): regExp.substring(index2); 29 | isGlobal = false; 30 | int flags = 0; 31 | for(int i=0; i sedRegExpList; 59 | 60 | /** 61 | * A "sed -e" like reg exp, of the form:
62 | * - /regexp/flags: find and output the matches.
63 | * - /regexp/replacement/flags: replace the matches and output the resulting string.
64 | * Flags can be left empty or any combinations of the characters 'gidmsux' (g performs a replace all instead of just the first match. For other flags, refer to the Javadoc of Pattern). 65 | * It is also possible to chain the output using ';' to perform multiple replacements.
66 | * If the regexp contains capturing groups, a find operation would only retain those; for a replace operation, the replacement string can refer to capturing groups with a syntax like '$1'. 67 | * @param regExp The regular expression. 68 | */ 69 | public SedRegExpPattern(String regExp) { 70 | String originalRegExp = regExp; 71 | if(!regExp.startsWith("/")) { 72 | throw new IllegalArgumentException("Invalid expression format: " + originalRegExp); 73 | } 74 | regExp = regExp.substring(1); 75 | StringBuilder sb = new StringBuilder(); 76 | char[] chars = regExp.toCharArray(); 77 | int index1 = -1; 78 | int index2 = -1; 79 | sedRegExpList = new ArrayList(3); 80 | for(int i=0; i= chars.length || chars[i] != '/') { 90 | throw new IllegalArgumentException("Invalid expression format: " + originalRegExp); 91 | } 92 | break; 93 | case '\\': 94 | i++; 95 | if(i >= chars.length) { 96 | throw new IllegalArgumentException("Invalid expression format: " + originalRegExp); 97 | } 98 | switch(chars[i]) { 99 | case '/': sb.append('/'); break; 100 | case ';': sb.append(';'); break; 101 | default: sb.append('\\').append(chars[i]); break; 102 | } 103 | break; 104 | case '/': 105 | if(index1 == -1) { 106 | index1 = sb.length(); 107 | } else if(index2 == -1) { 108 | index2 = sb.length(); 109 | } else { 110 | throw new IllegalArgumentException("Invalid expression format: " + originalRegExp); 111 | } 112 | break; 113 | default: sb.append(c); break; 114 | } 115 | } 116 | if(index1 == -1) { 117 | throw new IllegalArgumentException("Invalid expression format: " + originalRegExp); 118 | } 119 | sedRegExpList.add(new SedRegExp(sb.toString(), index1, index2, originalRegExp)); 120 | } 121 | 122 | public String apply(String text) { 123 | for(SedRegExp sedRegExp: sedRegExpList) { 124 | text = applySedRegularExpression(sedRegExp, text); 125 | } 126 | return text; 127 | } 128 | 129 | private static String applySedRegularExpression(SedRegExp sedRegExp, String text) { 130 | Pattern pattern = sedRegExp.getPattern(); 131 | String replacement = sedRegExp.getReplacement(); 132 | boolean isGlobal = sedRegExp.isGlobal(); 133 | Matcher matcher = pattern.matcher(text); 134 | if(replacement == null) { 135 | // Just returning the matches, no replacement 136 | int groupCount = matcher.groupCount(); 137 | StringBuilder sb = new StringBuilder(); 138 | while(matcher.find()) { 139 | if(groupCount > 0) { 140 | for(int i=0; i("Google", "http://www.google.com"), new GridBagConstraints(1, y++, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0)); 52 | // A local link (URL-based). 53 | try { 54 | centerPane.add(new JLabel("Local file system (URL-based):"), new GridBagConstraints(0, y, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0)); 55 | centerPane.add(new JLink("Root folder", new URL("file:///")), new GridBagConstraints(1, y++, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0)); 56 | } catch(Exception e) { 57 | e.printStackTrace(); 58 | } 59 | // An e-mail (URI-based). 60 | try { 61 | centerPane.add(new JLabel("E-mail (URI-based):"), new GridBagConstraints(0, y, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0)); 62 | centerPane.add(new JLink("chrriis@nextencia.net", new URI("mailto:chrriis@nextencia.net")), new GridBagConstraints(1, y++, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0)); 63 | } catch(Exception e) { 64 | e.printStackTrace(); 65 | } 66 | // A local file (File-based). 67 | try { 68 | centerPane.add(new JLabel("Local file (File-based):"), new GridBagConstraints(0, y, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0)); 69 | JPanel localFileLinkPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); 70 | final JLink fileLink = new JLink("