rtabbedpaneui.java

来自「具有不同语法高亮的编辑器实例」· Java 代码 · 共 86 行

JAVA
86
字号
/*
 * 11/14/2003
 *
 * RTabbedPaneUI.java - Tabbed Pane UI for displaying an icon to the right of
 *                      the tab text.
 * Copyright (C) 2003 Robert Futrell
 * email@address.com
 * www.website.com
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
package org.fife;

import java.awt.FontMetrics;
import java.awt.Rectangle;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.SwingUtilities;
import javax.swing.plaf.basic.BasicTabbedPaneUI;

/**
 * Tabbed pane UI for displaying the icon to the right of the
 * text on the tab.
 *
 * @author Robert Futrell
 * @version 1.0
 */
public class RTabbedPaneUI
    extends BasicTabbedPaneUI {

  private Rectangle selectedIconRectangle;

      /*****************************************************************************/

  /**
   * Constructor.
   */
  public RTabbedPaneUI() {
  }

      /*****************************************************************************/

  public Rectangle getSelectedIconRectangle() {
    return selectedIconRectangle;
  }

      /*****************************************************************************/

  protected void layoutLabel(int tabPlacement, FontMetrics metrics,
                             int tabIndex,
                             String title, Icon icon, Rectangle tabRect,
                             Rectangle iconRect, Rectangle textRect,
                             boolean isSelected) {

    textRect.x = 0;
    textRect.y = 0;
    iconRect.x = 0;
    iconRect.y = 0;
    SwingUtilities.layoutCompoundLabel( (JComponent) tabPane, metrics, title,
                                       icon,
                                       SwingUtilities.CENTER,
                                       SwingUtilities.CENTER,
                                       SwingUtilities.CENTER,
                                       SwingUtilities.LEFT,
                                       tabRect, iconRect, textRect,
                                       textIconGap + 2);

    selectedIconRectangle = iconRect;

  }

      /*****************************************************************************/

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?