javax.swing.LookAndFeel Java Examples

The following examples show how to use javax.swing.LookAndFeel. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SeaGlassScrollPaneUI.java    From seaglass with Apache License 2.0 6 votes vote down vote up
protected void installDefaults(JScrollPane scrollpane) {
    LookAndFeel.installBorder(scrollpane, "ScrollPane.border");
    LookAndFeel.installColorsAndFont(scrollpane, "ScrollPane.background", "ScrollPane.foreground", "ScrollPane.font");

    Border vpBorder = scrollpane.getViewportBorder();
    if ((vpBorder == null) || (vpBorder instanceof UIResource)) {
        vpBorder = UIManager.getBorder("ScrollPane.viewportBorder");
        scrollpane.setViewportBorder(vpBorder);
    }

    Object obj = UIManager.get("ScrollPane.cornerPainter");
    if (obj != null && obj instanceof SeaGlassPainter) {
        cornerPainter = (SeaGlassPainter) obj;
    }

    LookAndFeel.installProperty(scrollpane, "opaque", Boolean.TRUE);
    updateStyle(scrollpane);
}
 
Example #2
Source File: JTreeTable.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Overridden to message super and forward the method to the tree.
 * Since the tree is not actually in the component hieachy it will
 * never receive this unless we forward it in this manner.
 **/
@Override
public void updateUI()
{
	super.updateUI();

	if (tree != null)
	{
		tree.updateUI();
	}

	// Use the tree's default foreground and background
	// colors in the table
	LookAndFeel.installColorsAndFont(this, "Tree.background", //$NON-NLS-1$
		"Tree.foreground", //$NON-NLS-1$
		"Tree.font"); //$NON-NLS-1$
}
 
Example #3
Source File: Utilities.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static int getLFHeightAdjustment() {
    LookAndFeel lf = UIManager.getLookAndFeel();
    String lfID = lf.getID();
    logger.fine("createSingleLineEditor(): current L&F = '"+lfID+"'");
    if ("Metal".equals(lfID)) {
        return 0;
    }
    if ("GTK".equals(lfID)) {
        return 2;
    }
    if ("Motif".equals(lfID)) {
        return 3;
    }
    if ("Nimbus".equals(lfID)) {
        return 0;
    }
    if ("Aqua".equals(lfID)) {
        return -2;
    }
    return 0;
}
 
Example #4
Source File: JTipOfTheDayAddon.java    From orbit-image-analysis with GNU General Public License v3.0 6 votes vote down vote up
protected void addBasicDefaults(LookAndFeelAddons addon, List defaults) {
  defaults.add(JTipOfTheDay.uiClassID);
  defaults.add(BasicTipOfTheDayUI.class.getName());

  defaults.add("TipOfTheDay.font");
  defaults.add(UIManager.getFont("TextPane.font"));

  defaults.add("TipOfTheDay.tipFont");
  defaults.add(UIManager.getFont("Label.font").deriveFont(Font.BOLD, 13f));

  defaults.add("TipOfTheDay.background");
  defaults.add(new ColorUIResource(Color.white));

  defaults.add("TipOfTheDay.icon");
  defaults.add(LookAndFeel.makeIcon(BasicTipOfTheDayUI.class,
    "TipOfTheDay24.gif"));

  defaults.add("TipOfTheDay.border");
  defaults.add(new BorderUIResource(BorderFactory.createLineBorder(new Color(
    117, 117, 117))));

  addResource(defaults,
    "com.l2fprod.common.swing.plaf.basic.resources.TipOfTheDay");
}
 
Example #5
Source File: ResourceReferenceChooser.java    From gate-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
  JLabel renderer = (JLabel)super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
  if(value instanceof PluginTreeNode) {
    renderer.setEnabled(true);
    renderer.setIcon(pluginIcon);
  } else if(value instanceof PluginResourceTreeNode) {
    PluginResourceTreeNode node = (PluginResourceTreeNode)value;
    if(!node.isLeaf() || ((PluginFileFilter)pluginFileFilterBox.getSelectedItem()).pattern.matcher(node.fullPath).find()) {
      renderer.setEnabled(true);
    } else {
      // trick lifted from DefaultTreeCellRenderer to get the right disabled icon
      Icon icon = renderer.getIcon();
      LookAndFeel laf = UIManager.getLookAndFeel();
      Icon disabledIcon = laf.getDisabledIcon(tree, icon);
      if (disabledIcon != null) icon = disabledIcon;
      renderer.setDisabledIcon(icon);
      renderer.setEnabled(false);
    }
  }
  return renderer;
}
 
Example #6
Source File: BasicTaskPaneGroupUI.java    From orbit-image-analysis with GNU General Public License v3.0 6 votes vote down vote up
protected void installDefaults() {
  group.setOpaque(true);
  group.setBorder(createPaneBorder());
  ((JComponent)group.getContentPane()).setBorder(createContentPaneBorder());

  LookAndFeel.installColorsAndFont(
    group,
    "TaskPaneGroup.background",
    "TaskPaneGroup.foreground",
    "TaskPaneGroup.font");

  LookAndFeel.installColorsAndFont(
    (JComponent)group.getContentPane(),
    "TaskPaneGroup.background",
    "TaskPaneGroup.foreground",
    "TaskPaneGroup.font");    
}
 
Example #7
Source File: JTreeTable.java    From libreveris with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Overridden to message super and forward the method to the tree. Since
 * the tree is not actually in the component hierarchy it will never receive
 * this unless we forward it in this manner.
 */
//----------//
// updateUI //
//----------//
@Override
public void updateUI ()
{
    super.updateUI();

    if (tree != null) {
        tree.updateUI();
    }

    // Use the tree's default foreground and background colors in the
    // table.
    LookAndFeel.installColorsAndFont(
            this,
            "Tree.background",
            "Tree.foreground",
            "Tree.font");
}
 
Example #8
Source File: JTipOfTheDayAddon.java    From orbit-image-analysis with GNU General Public License v3.0 6 votes vote down vote up
protected void addWindowsDefaults(LookAndFeelAddons addon, List defaults) {
  super.addWindowsDefaults(addon, defaults);

  defaults.add(JTipOfTheDay.uiClassID);
  defaults.add(WindowsTipOfTheDayUI.class.getName());

  defaults.add("TipOfTheDay.background");
  defaults.add(new ColorUIResource(128, 128, 128));

  defaults.add("TipOfTheDay.font");
  defaults.add(UIManager.getFont("Label.font").deriveFont(13f));

  defaults.add("TipOfTheDay.icon");
  defaults.add(LookAndFeel.makeIcon(WindowsTipOfTheDayUI.class,
    "tipoftheday.png"));

  defaults.add("TipOfTheDay.border");
  defaults
    .add(new BorderUIResource(new WindowsTipOfTheDayUI.TipAreaBorder()));

  addResource(defaults,
    "com.l2fprod.common.swing.plaf.windows.resources.TipOfTheDay");
}
 
Example #9
Source File: SeaGlassLookAndFeel.java    From seaglass with Apache License 2.0 6 votes vote down vote up
/**
 * Use Aqua settings for some properties if we're on a Mac.
 *
 * @param d the UI defaults map.
 */
private void defineAquaSettings(UIDefaults d) {
    try {

        // Instantiate Aqua but don't install it.
        Class<?>    lnfClass     = Class.forName(UIManager.getSystemLookAndFeelClassName(), true,
                                                 Thread.currentThread().getContextClassLoader());
        LookAndFeel aqua         = (LookAndFeel) lnfClass.newInstance();
        UIDefaults  aquaDefaults = aqua.getDefaults();

        // Use Aqua for any menu UI classes.
        d.put("MenuBarUI", aquaDefaults.get("MenuBarUI"));
        d.put("MenuUI", aquaDefaults.get("MenuUI"));
    } catch (Exception e) {

        // TODO Should we do something with this exception?
        e.printStackTrace();
    }
}
 
Example #10
Source File: FlatSpinnerUI.java    From FlatLaf with Apache License 2.0 6 votes vote down vote up
@Override
protected void installDefaults() {
	super.installDefaults();

	LookAndFeel.installProperty( spinner, "opaque", false );

	minimumWidth = UIManager.getInt( "Component.minimumWidth" );
	buttonStyle = UIManager.getString( "Spinner.buttonStyle" );
	arrowType = UIManager.getString( "Component.arrowType" );
	isIntelliJTheme = UIManager.getBoolean( "Component.isIntelliJTheme" );
	borderColor = UIManager.getColor( "Component.borderColor" );
	disabledBorderColor = UIManager.getColor( "Component.disabledBorderColor" );
	disabledBackground = UIManager.getColor( "Spinner.disabledBackground" );
	disabledForeground = UIManager.getColor( "Spinner.disabledForeground" );
	buttonBackground = UIManager.getColor( "Spinner.buttonBackground" );
	buttonArrowColor = UIManager.getColor( "Spinner.buttonArrowColor" );
	buttonDisabledArrowColor = UIManager.getColor( "Spinner.buttonDisabledArrowColor" );
	buttonHoverArrowColor = UIManager.getColor( "Spinner.buttonHoverArrowColor" );
	padding = UIManager.getInsets( "Spinner.padding" );

	// scale
	padding = scale( padding );

	MigLayoutVisualPadding.install( spinner );
}
 
Example #11
Source File: FlatRootPaneUI.java    From FlatLaf with Apache License 2.0 6 votes vote down vote up
protected void uninstallClientDecorations() {
	LookAndFeel.uninstallBorder( rootPane );
	setTitlePane( null );

	if( windowResizer != null ) {
		windowResizer.uninstall();
		windowResizer = null;
	}

	if( oldLayout != null ) {
		rootPane.setLayout( oldLayout );
		oldLayout = null;
	}

	if( rootPane.getWindowDecorationStyle() == JRootPane.NONE ) {
		rootPane.revalidate();
		rootPane.repaint();
	}
}
 
Example #12
Source File: KnopflerfishLookAndFeel.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
protected void initComponentDefaults(UIDefaults table) {
  super.initComponentDefaults( table );

  // I'll have to copy some of the resource definitions here, since the
  // original code in BasicLookAndFeel (from which we inherit) uses
  // getClass() to find its resources. That will fail since my
  // classloader does not have these resources.
  //
  // So, the trick is to replace getClass() with MetalLookAndFeel.class

  Object[] defaults = {
    "OptionPane.errorIcon",       LookAndFeel.makeIcon(MetalLookAndFeel.class, "icons/Error.gif"),
    "OptionPane.informationIcon", LookAndFeel.makeIcon(MetalLookAndFeel.class, "icons/Inform.gif"),
    "OptionPane.warningIcon",     LookAndFeel.makeIcon(MetalLookAndFeel.class, "icons/Warn.gif"),
    "OptionPane.questionIcon",    LookAndFeel.makeIcon(MetalLookAndFeel.class, "icons/Question.gif"),

    "InternalFrame.icon",         LookAndFeel.makeIcon(BasicLookAndFeel.class, "icons/JavaCup.gif"),


    // Button margin slightly smaller than metal to save space
    "Button.margin", new InsetsUIResource(1, 11, 1, 11),


  };
  table.putDefaults(defaults);
}
 
Example #13
Source File: FlatTreeUI.java    From FlatLaf with Apache License 2.0 6 votes vote down vote up
@Override
protected void installDefaults() {
	super.installDefaults();

	LookAndFeel.installBorder( tree, "Tree.border" );

	selectionBackground = UIManager.getColor( "Tree.selectionBackground" );
	selectionForeground = UIManager.getColor( "Tree.selectionForeground" );
	selectionInactiveBackground = UIManager.getColor( "Tree.selectionInactiveBackground" );
	selectionInactiveForeground = UIManager.getColor( "Tree.selectionInactiveForeground" );
	selectionBorderColor = UIManager.getColor( "Tree.selectionBorderColor" );
	wideSelection = UIManager.getBoolean( "Tree.wideSelection" );
	showCellFocusIndicator = UIManager.getBoolean( "Tree.showCellFocusIndicator" );

	// scale
	int rowHeight = FlatUIUtils.getUIInt( "Tree.rowHeight", 16 );
	if( rowHeight > 0 )
		LookAndFeel.installProperty( tree, "rowHeight", UIScale.scale( rowHeight ) );
	setLeftChildIndent( UIScale.scale( getLeftChildIndent() ) );
	setRightChildIndent( UIScale.scale( getRightChildIndent() ) );
}
 
Example #14
Source File: BasicLookAndFeel.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the parent of the passed in ActionMap to be the audio action
 * map.
 */
static void installAudioActionMap(ActionMap map) {
    LookAndFeel laf = UIManager.getLookAndFeel();
    if (laf instanceof BasicLookAndFeel) {
        map.setParent(((BasicLookAndFeel)laf).getAudioActionMap());
    }
}
 
Example #15
Source File: FlatMenuItemUI.java    From FlatLaf with Apache License 2.0 5 votes vote down vote up
@Override
protected void installDefaults() {
	super.installDefaults();

	LookAndFeel.installProperty( menuItem, "iconTextGap", FlatUIUtils.getUIInt( "MenuItem.iconTextGap", 4 ) );

	renderer = createRenderer();
}
 
Example #16
Source File: BasicLookAndFeel.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the parent of the passed in ActionMap to be the audio action
 * map.
 */
static void installAudioActionMap(ActionMap map) {
    LookAndFeel laf = UIManager.getLookAndFeel();
    if (laf instanceof BasicLookAndFeel) {
        map.setParent(((BasicLookAndFeel)laf).getAudioActionMap());
    }
}
 
Example #17
Source File: FlatTextFieldUI.java    From FlatLaf with Apache License 2.0 5 votes vote down vote up
@Override
protected void installDefaults() {
	super.installDefaults();

	String prefix = getPropertyPrefix();
	minimumWidth = UIManager.getInt( "Component.minimumWidth" );
	isIntelliJTheme = UIManager.getBoolean( "Component.isIntelliJTheme" );
	placeholderForeground = UIManager.getColor( prefix + ".placeholderForeground" );

	LookAndFeel.installProperty( getComponent(), "opaque", false );

	MigLayoutVisualPadding.install( getComponent() );
}
 
Example #18
Source File: FlatProgressBarUI.java    From FlatLaf with Apache License 2.0 5 votes vote down vote up
@Override
protected void installDefaults() {
	super.installDefaults();

	LookAndFeel.installProperty( progressBar, "opaque", false );

	arc = UIManager.getInt( "ProgressBar.arc" );
	horizontalSize = UIManager.getDimension( "ProgressBar.horizontalSize" );
	verticalSize = UIManager.getDimension( "ProgressBar.verticalSize" );
}
 
Example #19
Source File: BasicLookAndFeel.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Helper method to play a named sound.
 *
 * @param c JComponent to play the sound for.
 * @param actionKey Key for the sound.
 */
static void playSound(JComponent c, Object actionKey) {
    LookAndFeel laf = UIManager.getLookAndFeel();
    if (laf instanceof BasicLookAndFeel) {
        ActionMap map = c.getActionMap();
        if (map != null) {
            Action audioAction = map.get(actionKey);
            if (audioAction != null) {
                // pass off firing the Action to a utility method
                ((BasicLookAndFeel)laf).playSound(audioAction);
            }
        }
    }
}
 
Example #20
Source File: LuckInternalFrameUI.java    From littleluck with Apache License 2.0 5 votes vote down vote up
@Override
public void installUI(JComponent c)
{
    super.installUI(c);

    LookAndFeel.installProperty(frame, "opaque", Boolean.FALSE);
}
 
Example #21
Source File: FlatLaf.java    From FlatLaf with Apache License 2.0 5 votes vote down vote up
public static boolean install( LookAndFeel newLookAndFeel ) {
	try {
		UIManager.setLookAndFeel( newLookAndFeel );
		return true;
	} catch( Exception ex ) {
		LOG.log( Level.SEVERE, "FlatLaf: Failed to initialize look and feel '" + newLookAndFeel.getClass().getName() + "'.", ex );
		return false;
	}
}
 
Example #22
Source File: UIScale.java    From FlatLaf with Apache License 2.0 5 votes vote down vote up
private static void initialize() {
	if( initialized )
		return;
	initialized = true;

	if( !isUserScalingEnabled() )
		return;

	// listener to update scale factor if LaF changed, "defaultFont" or "Label.font" changed
	PropertyChangeListener listener = new PropertyChangeListener() {
		@Override
		public void propertyChange( PropertyChangeEvent e ) {
			switch( e.getPropertyName() ) {
				case "lookAndFeel":
					// it is not necessary (and possible) to remove listener of old LaF defaults
					if( e.getNewValue() instanceof LookAndFeel )
						UIManager.getLookAndFeelDefaults().addPropertyChangeListener( this );
					updateScaleFactor();
					break;

				case "defaultFont":
				case "Label.font":
					updateScaleFactor();
					break;
			}
		}
	};
	UIManager.addPropertyChangeListener( listener );
	UIManager.getDefaults().addPropertyChangeListener( listener );
	UIManager.getLookAndFeelDefaults().addPropertyChangeListener( listener );

	updateScaleFactor();
}
 
Example #23
Source File: LuckComboBoxUI.java    From littleluck with Apache License 2.0 5 votes vote down vote up
@Override
public void installUI(JComponent c)
{
    super.installUI(c);

    LookAndFeel.installProperty(c, "opaque", Boolean.FALSE);

    if(c.getBorder() instanceof LuckShapeBorder)
    {
        installFocusListener(c);
    }
}
 
Example #24
Source File: BasicLookAndFeel.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the parent of the passed in ActionMap to be the audio action
 * map.
 */
static void installAudioActionMap(ActionMap map) {
    LookAndFeel laf = UIManager.getLookAndFeel();
    if (laf instanceof BasicLookAndFeel) {
        map.setParent(((BasicLookAndFeel)laf).getAudioActionMap());
    }
}
 
Example #25
Source File: NbBrowsers.java    From netbeans with Apache License 2.0 5 votes vote down vote up
static void applyNbSkin() {
    LookAndFeel lookAndFeel = UIManager.getLookAndFeel();
    String name = findLafName(lookAndFeel.getName());
    if (name == null) {
        return;
    }
    String resource = "nbres:/org/netbeans/modules/htmlui/css/wizard-" + name + ".css";
    loadCss(resource);
}
 
Example #26
Source File: FlatSlidingButtonUI.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
protected void installDefaults(AbstractButton b) {
    super.installDefaults(b);

    if(!defaults_initialized) {
        hoverBackground = UIManager.getColor("SlidingButton.hoverBackground");
        selectedBackground = UIManager.getColor("SlidingButton.selectedBackground");
        attentionBackground = UIManager.getColor("SlidingButton.attentionBackground");
        attentionForeground = UIManager.getColor("SlidingButton.attentionForeground");
        defaults_initialized = true;
    }

    LookAndFeel.installProperty(b, "opaque", false);
}
 
Example #27
Source File: BasicLookAndFeel.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the parent of the passed in ActionMap to be the audio action
 * map.
 */
static void installAudioActionMap(ActionMap map) {
    LookAndFeel laf = UIManager.getLookAndFeel();
    if (laf instanceof BasicLookAndFeel) {
        map.setParent(((BasicLookAndFeel)laf).getAudioActionMap());
    }
}
 
Example #28
Source File: XToolkit.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
static void initUIDefaults() {
    try {
        // Load Defaults from MotifLookAndFeel

        // This dummy load is necessary to get SystemColor initialized. !!!!!!
        Color c = SystemColor.text;

        LookAndFeel lnf = new XAWTLookAndFeel();
        uidefaults = lnf.getDefaults();
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
}
 
Example #29
Source File: XToolkit.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static void initUIDefaults() {
    try {
        // Load Defaults from MotifLookAndFeel

        // This dummy load is necessary to get SystemColor initialized. !!!!!!
        Color c = SystemColor.text;

        LookAndFeel lnf = new XAWTLookAndFeel();
        uidefaults = lnf.getDefaults();
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
}
 
Example #30
Source File: SeaGlassPanelUI.java    From seaglass with Apache License 2.0 5 votes vote down vote up
/**
 * Update the Synth style if a property changes.
 *
 * @param c the panel.
 */
private void updateStyle(JPanel c) {
    SeaGlassContext context = getContext(c, ENABLED);

    style = SeaGlassLookAndFeel.updateStyle(context, this);
    context.dispose();

    // Set the opacity according to whether the background has been set.
    // Don't set it if the user has already set it.
    LookAndFeel.installProperty(c, "opaque", !(c.getBackground() instanceof UIResource));
}