All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jidesoft.swing.JideLabel Maven / Gradle / Ivy

There is a newer version: 3.6.18
Show newest version
package com.jidesoft.swing;

import com.jidesoft.plaf.LookAndFeelFactory;
import com.jidesoft.plaf.UIDefaultsLookup;

import javax.swing.*;

/**
 * Just like JideButton comparing to JButton, JideLabel is like
 * JLabel except it is used on JToolBar or CommandBar. However it doesn't look
 * any different from a regular JLabel unless you override "JideLabel.foreground", "JideLabel.background",
 * or "JideLabel.font" etc UIDefaults.
 * 

* JideLabel also can be used in a vertical layout. If you call {@link #setOrientation(int)} and set it to * {@link javax.swing.SwingConstants#VERTICAL}, the text and icon on the label will be laid out vertically. As * CommandBar supports vertical layout, this is perfect for it. You can also control the rotating direction * by calling {@link #setClockwise(boolean)}. By default, it rotates clockwise. */ public class JideLabel extends JLabel implements Alignable, AlignmentSupport { private static final String uiClassID = "JideLabelUI"; public static final String PROPERTY_CLOCKWISE = "clockwise"; private boolean _clockwise = true; private int _orientation; public JideLabel() { } public JideLabel(String text) { super(text); } public JideLabel(Icon image, int horizontalAlignment) { super(image, horizontalAlignment); } public JideLabel(Icon image) { super(image); } public JideLabel(String text, int horizontalAlignment) { super(text, horizontalAlignment); } public JideLabel(String text, Icon icon, int horizontalAlignment) { super(text, icon, horizontalAlignment); } /** * Resets the UI property to a value from the current look and feel. * * @see JComponent#updateUI */ @Override public void updateUI() { if (UIDefaultsLookup.get(uiClassID) == null) { LookAndFeelFactory.installJideExtension(); } setUI(UIManager.getUI(this)); } /** * Returns a string that specifies the name of the L&F class that renders this component. * * @return the string "ButtonUI" * * @see JComponent#getUIClassID * @see UIDefaults#getUI */ @Override public String getUIClassID() { return uiClassID; } /** * The button orientation. * * @return the orientation. */ public int getOrientation() { return _orientation; } public void setOrientation(int orientation) { int old = _orientation; if (old != orientation) { _orientation = orientation; firePropertyChange(PROPERTY_ORIENTATION, old, orientation); } } /** * return true if it supports vertical orientation. * * @return true if it supports vertical orientation */ public boolean supportVerticalOrientation() { return true; } /** * return true if it supports horizontal orientation. * * @return true if it supports horizontal orientation */ public boolean supportHorizontalOrientation() { return true; } /** * Checks if the rotation is clockwise. * * @return true or false. */ public boolean isClockwise() { return _clockwise; } /** * Sets the rotation direction. * * @param clockwise true or false. */ public void setClockwise(boolean clockwise) { boolean old = _clockwise; if (clockwise != _clockwise) { _clockwise = clockwise; firePropertyChange(PROPERTY_CLOCKWISE, old, _clockwise); } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy