looks-2.2.0

.get(getPropertyPrefix() + ".textIconGap");
    
    defaultTextIconGap = (gap != null ? gap.intValue() : 2);
  }
  
  protected void uninstallDefaults()
  {
    super.uninstallDefaults();
    renderer = null;
  }
  
  protected String getPropertyPrefix()
  {
    return propertyPrefix;
  }
  
  protected Dimension getPreferredMenuItemSize(JComponent c, Icon aCheckIcon, Icon anArrowIcon, int textIconGap)
  {
    if (isSubMenu(menuItem))
    {
      ensureSubMenuInstalled();
      return renderer.getPreferredMenuItemSize(c, aCheckIcon, anArrowIcon, textIconGap);
    }
    Dimension size = super.getPreferredMenuItemSize(c, aCheckIcon, anArrowIcon, textIconGap);
    
    int width = width;
    int height = height;
    if (height % 2 == 1) {
      height--;
    }
    return new Dimension(width, height);
  }
  
  protected void paintMenuItem(Graphics g, JComponent c, Icon aCheckIcon, Icon anArrowIcon, Color background, Color foreground, int textIconGap)
  {
    if (isSubMenu(menuItem)) {
      renderer.paintMenuItem(g, c, aCheckIcon, anArrowIcon, background, foreground, textIconGap);
    } else {
      super.paintMenuItem(g, c, aCheckIcon, anArrowIcon, background, foreground, textIconGap);
    }
  }
  
  private void ensureSubMenuInstalled()
  {
    if (propertyPrefix.equals("MenuItem")) {
      return;
    }
    ButtonModel model = menuItem.getModel();
    
    boolean oldArmed = model.isArmed();
    boolean oldSelected = model.isSelected();
    
    uninstallDefaults();
    propertyPrefix = "MenuItem";
    installDefaults();
    
    model.setArmed(oldArmed);
    model.setSelected(oldSelected);
  }
  
  private boolean isSubMenu(JMenuItem aMenuItem)
  {
    return !((JMenu)aMenuItem).isTopLevelMenu();
  }
}

/* Location:
 * Qualified Name:     com.jgoodies.looks.windows.WindowsXPMenuUI
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package com.jgoodies.looks.windows;

import com.sun.java.swing.plaf.windows.WindowsTableHeaderUI;
import java.awt.Component;
import java.awt.ComponentOrientation;
import java.awt.Container;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Rectangle;
import javax.swing.CellRendererPane;
import javax.swing.JComponent;
import javax.swing.JTable;
import javax.swing.plaf.ComponentUI;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;

public final class WindowsXPTableHeaderUI
  extends WindowsTableHeaderUI
{
  private TableCellRenderer xpRenderer;
  
  public static ComponentUI createUI(JComponent h)
  {
    return new WindowsXPTableHeaderUI();
  }
  
  public void installUI(JComponent c)
  {
    super.installUI(c);
    xpRenderer = header.getDefaultRenderer();
  }
  
  public void uninstallUI(JComponent c)
  {
    xpRenderer = null;
    super.uninstallUI(c);
  }
  
  public void paint(Graphics g, JComponent c)
  {
    TableColumnModel cm = header.getColumnModel();
    if (cm.getColumnCount() <= 0) {
      return;
    }
    boolean ltr = header.getComponentOrientation().isLeftToRight();
    
    Rectangle clip = g.getClipBounds();
    Point left = clip.getLocation();
    Point right = new Point(x + width - 1, y);
    int cMin = header.columnAtPoint(ltr ? left : right);
    int cMax = header.columnAtPoint(ltr ? right : left);
    if (cMin == -1) {
      cMin = 0;
    }
    if (cMax == -1) {
      cMax = cm.getColumnCount() - 1;
    }
    TableColumn draggedColumn = header.getDraggedColumn();
    
    Rectangle cellRect = header.getHeaderRect(cMin);
    if (ltr) {
      for (int column = cMin; column <= cMax; column++)
      {
        TableColumn aColumn = cm.getColumn(column);
        int columnWidth = aColumn.getWidth();
        width = columnWidth;
        if (aColumn != draggedColumn) {
          paintCell(g, cellRect, column);
        }
        x += columnWidth;
      }
    } else {
      for (int column = cMax; column >= cMin; column--)
      {
        TableColumn aColumn = cm.getColumn(column);
        int columnWidth = aColumn.getWidth();
        width = columnWidth;
        if (aColumn != draggedColumn) {
          paintCell(g, cellRect, column);
        }
        x += columnWidth;
      }
    }
    if (draggedColumn != null)
    {
      int draggedColumnIndex = viewIndexForColumn(draggedColumn);
      Rectangle draggedCellRect = header.getHeaderRect(draggedColumnIndex);
      
      g.setColor(header.getParent().getBackground());
      g.fillRect(x, y, width, height);
      
      x += header.getDraggedDistance();
      
      g.setColor(header.getBackground());
      g.fillRect(x, y, width, height);
      
      paintCell(g, draggedCellRect, draggedColumnIndex);
    }
    rendererPane.removeAll();
  }
  
  private void paintCell(Graphics g, Rectangle cellRect, int columnIndex)
  {
    TableColumn aColumn = header.getColumnModel().getColumn(columnIndex);
    TableCellRenderer renderer = aColumn.getHeaderRenderer();
    if (renderer == null) {
      renderer = header.getDefaultRenderer();
    }
    JTable table = header.getTable();
    Component background = xpRenderer.getTableCellRendererComponent(table, null, false, false, -1, columnIndex);
    
    Component c = renderer.getTableCellRendererComponent(table, aColumn.getHeaderValue(), false, false, -1, columnIndex);
    if (c != background)
    {
      rendererPane.add(c);
      if (!c.isOpaque())
      {
        rendererPane.paintComponent(g, background, header, x, y, width, height, true);
        if (((c instanceof JComponent)) && ((background instanceof JComponent))) {
          ((JComponent)c).setBorder(((JComponent)background).getBorder());
        }
      }
    }
    rendererPane.paintComponent(g, c, header, x, y, width, height, true);
  }
  
  private int viewIndexForColumn(TableColumn aColumn)
  {
    TableColumnModel cm = header.getColumnModel();
    for (int column = cm.getColumnCount() - 1; column >= 0; column--) {
      if (cm.getColumn(column) == aColumn) {
        return column;
      }
    }
    return -1;
  }
}

/* Location:
 * Qualified Name:     com.jgoodies.looks.windows.WindowsXPTableHeaderUI
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package com.jgoodies.looks.windows;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;

final class WindowsXPToolBarUI$1
  implements PropertyChangeListener
{
  private final WindowsXPToolBarUI this$0;
  
  WindowsXPToolBarUI$1(WindowsXPToolBarUI paramWindowsXPToolBarUI) {}
  
  public void propertyChange(PropertyChangeEvent e)
  {
    String prop = e.getPropertyName();
    if ((prop.equals("jgoodies.headerStyle")) || (prop.equals("jgoodies.windows.borderStyle"))) {
      WindowsXPToolBarUI.access$000(this$0);
    }
  }
}

/* Location:
 * Qualified Name:     com.jgoodies.looks.windows.WindowsXPToolBarUI.1
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package com.jgoodies.looks.windows;

import com.jgoodies.looks.BorderStyle;
import com.jgoodies.looks.HeaderStyle;
import com.sun.java.swing.plaf.windows.WindowsToolBarUI;
import java.awt.Component;
import java.awt.Container;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.AbstractButton;
import javax.swing.JComponent;
import javax.swing.JToolBar;
import javax.swing.LookAndFeel;
import javax.swing.plaf.ComponentUI;

public final class WindowsXPToolBarUI
  extends WindowsToolBarUI
{
  private PropertyChangeListener listener;
  
  public static ComponentUI createUI(JComponent b)
  {
    return new WindowsXPToolBarUI();
  }
  
  protected void installDefaults()
  {
    super.installDefaults();
    installSpecialBorder();
  }
  
  protected void installListeners()
  {
    super.installListeners();
    listener = createBorderStyleListener();
    toolBar.addPropertyChangeListener(listener);
  }
  
  protected void uninstallListeners()
  {
    toolBar.removePropertyChangeListener(listener);
    super.uninstallListeners();
  }
  
  private PropertyChangeListener createBorderStyleListener()
  {
    new PropertyChangeListener()
    {
      public void propertyChange(PropertyChangeEvent e)
      {
        String prop = e.getPropertyName();
        if ((prop.equals("jgoodies.headerStyle")) || (prop.equals("jgoodies.windows.borderStyle"))) {
          WindowsXPToolBarUI.this.installSpecialBorder();
        }
      }
    };
  }
  
  private void installSpecialBorder()
  {
    BorderStyle borderStyle = BorderStyle.from(toolBar, "jgoodies.windows.borderStyle");
    String suffix;
    String suffix;
    if (borderStyle == BorderStyle.EMPTY)
    {
      suffix = "emptyBorder";
    }
    else
    {
      String suffix;
      if (borderStyle == BorderStyle.SEPARATOR)
      {
        suffix = "separatorBorder";
      }
      else
      {
        String suffix;
        if (borderStyle == BorderStyle.ETCHED)
        {
          suffix = "etchedBorder";
        }
        else
        {
          String suffix;
          if (HeaderStyle.from(toolBar) == HeaderStyle.BOTH) {
            suffix = "headerBorder";
          } else {
            suffix = "border";
          }
        }
      }
    }
    LookAndFeel.installBorder(toolBar, "ToolBar." + suffix);
  }
  
  protected void setBorderToRollover(Component c)
  {
    if ((c instanceof AbstractButton))
    {
      super.setBorderToRollover(c);
    }
    else if ((c instanceof Container))
    {
      Container cont = (Container)c;
      for (int i = 0; i < cont.getComponentCount(); i++) {
        super.setBorderToRollover(cont.getComponent(i));
      }
    }
  }
}

/* Location:
 * Qualified Name:     com.jgoodies.looks.windows.WindowsXPToolBarUI
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd