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

com.incors.plaf.kunststoff.KunststoffTreeUI Maven / Gradle / Ivy

Go to download

The Kunststoff Look and Feel is an extension to the the Java ™ Metal Look and Feel. This makes it very compact in size (approx. 43 kBytes) and ensures that all the great features provided by the Metal Look and Feel do not get lost. It is our little contribution for making the Java ™ platform even better and we hope that it will help you make some wonderful GUIs.

The newest version!
package com.incors.plaf.kunststoff;

/*
 * This code was developed by INCORS GmbH (www.incors.com)
 * based on a contribution by Timo Haberkern.
 * It is published under the terms of the Lesser GNU Public License.
 */

import java.awt.*;
import javax.swing.*;
import javax.swing.tree.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.*;

public class KunststoffTreeUI extends BasicTreeUI {
  protected static ImageIcon m_iconExpanded;
  protected static ImageIcon m_iconCollapsed;


  public KunststoffTreeUI(JComponent c) {
    try {
      m_iconExpanded = new ImageIcon(getClass().getResource("icons/treeex.gif"));
      m_iconCollapsed = new ImageIcon(getClass().getResource("icons/treecol.gif"));
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

  public static ComponentUI createUI(JComponent tree) {
    return new KunststoffTreeUI(tree);
  }

  // This method replaces the metal expand-/collaps-icons with some nicer ones.
  protected void paintExpandControl(Graphics g, Rectangle clipBounds,
                                Insets insets, Rectangle bounds,
                                TreePath path, int row, boolean isExpanded,
                                boolean hasBeenExpanded, boolean isLeaf) {
    if (isExpanded == true) {
      if (null != m_iconExpanded) {
        g.drawImage(m_iconExpanded.getImage(), bounds.x-17, bounds.y+4, null);
      }
    } else {
      if (null != m_iconCollapsed) {
        g.drawImage(m_iconCollapsed.getImage(), bounds.x-17, bounds.y+4, null);
      }
    }
  }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy