Package eu.bandm.tools.graficUtils
Class SwingTools
java.lang.Object
eu.bandm.tools.graficUtils.SwingTools
Collection of small static utility functions.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classJComboBox data model which prohibits the selection of disabled items.static classJComboBox with optically disabled entries.static classSwingTools.EnumComboBox<E extends Enum<E>>static classstatic classstatic classDistributes tool tip text to all sub-components. -
Method Summary
Modifier and TypeMethodDescriptionstatic intappendFileToTextArea(File file, JTextArea ta) static <D extends Message>
booleanask(JFrame frame, @Opt String windowtitle, int messageType, MessageStore<D> text, String cancelbutton, String okbutton) static booleanask(JFrame frame, @Opt String windowtitle, int messageType, Object[] text, String cancelbutton, String okbutton) static ItemListeneritemSelectedListener(Consumer<Object> consumer) Create a listener which only reacts on set events, not on clear evants.static intloadPngsToButtons(JPanel container, File directory, String fileStem, int numStart, String numberFormat) Load one or more ".png" files to JButtons and append them to the end of the container.static <C extends Container>
CnearestContainer(@Opt Component c, Class<C> cl) static <E> JComboBox<E> setEnabling(JComboBox<E> comboBox) Adds disabling/enabling to the items of a JComboBox.static <E> JComboBox<E> setEnabling(JComboBox<E> comboBox, @Opt Predicate<E> enabled) static voidstatic <E> JComboBox<E> setPredicate(JComboBox<E> comboBox, @Opt Predicate<E> enabled) Changes the predicate for a JComboBox with disabling/enabling.static <D extends Message>
voidshow(JFrame frame, @Opt String windowtitle, int messageType, MessageStore<D> text, String buttonText) static voidATTENTION: when calling "showXXDialog()", the conversion to "Object[]" must be done explicitly, because only then "vertical stacking" is applied to the results of "toString()" separately!
-
Method Details
-
setMaximumToPreferred
-
nearestContainer
-
show
-
show
public static void show(JFrame frame, @Opt @Opt String windowtitle, int messageType, Object[] text, String buttonText) ATTENTION: when calling "showXXDialog()", the conversion to "Object[]" must be done explicitly, because only then "vertical stacking" is applied to the results of "toString()" separately! -
ask
-
ask
-
appendFileToTextArea
- Throws:
IOException
-
loadPngsToButtons
public static int loadPngsToButtons(JPanel container, File directory, String fileStem, int numStart, String numberFormat) Load one or more ".png" files to JButtons and append them to the end of the container. In case of lilypond use "-page%d" as the numberFormat.- Returns:
- -1 if ONE page without numeric extension has been loaded; otherwise the first number which could NOT be loaded (e.g. "3" if pages "1" and "2" have been successfully loaded)
-
setEnabling
Adds disabling/enabling to the items of a JComboBox. Changes the data model, so it must be called before filling this. -
setEnabling
-
setPredicate
Changes the predicate for a JComboBox with disabling/enabling. Assumes thatsetEnabling(JComboBox,Predicate)has been called before. Or some other means have changed the renderer and the data model to a class which has "setPredicate()".- Parameters:
enabled- the enabling predicate, or null for all items enabled.- Throws:
ClassCastException- ifsetEnabling(JComboBox,Predicate)has not been called before.
-
itemSelectedListener
Create a listener which only reacts on set events, not on clear evants. An ItemEvent is more selective than an Action event, e.g. with JComboBox, because it is not fired if nothing changes. But when the selection changes, two events are fired, for the de-selected and the selected value. This class propages only the latter.
-