javax.swing.JTabbedPane.getBackgroundAt()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(10.1k)|赞(0)|评价(0)|浏览(111)

本文整理了Java中javax.swing.JTabbedPane.getBackgroundAt()方法的一些代码示例,展示了JTabbedPane.getBackgroundAt()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTabbedPane.getBackgroundAt()方法的具体详情如下:
包路径:javax.swing.JTabbedPane
类名称:JTabbedPane
方法名:getBackgroundAt

JTabbedPane.getBackgroundAt介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

g.setColor(Color.BLACK);
BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex, textRect.x, textRect.y + metrics.getAscent());
g.setColor(tabPane.getBackgroundAt(tabIndex).darker());
BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex, textRect.x - 1, textRect.y + metrics.getAscent() - 1);

代码示例来源:origin: com.jtattoo/JTattoo

protected Color getGapColor(int tabIndex) {
  if (tabIndex == tabPane.getSelectedIndex()) {
    return tabPane.getBackgroundAt(tabIndex);
  }
  return super.getGapColor(tabIndex);
}

代码示例来源:origin: com.jtattoo/JTattoo

protected Color[] getTabColors(int tabIndex, boolean isSelected, boolean isRollover) {
  if (isSelected && (tabPane.getBackgroundAt(tabIndex) instanceof UIResource)) {
    return selectedTabColors;
  } else {
    return super.getTabColors(tabIndex, isSelected, isRollover);
  }
}

代码示例来源:origin: com.incors/kunstoff-laf

protected void paintTabBackground(Graphics g, int tabPlacement, int tabIndex,
                  int x, int y, int w, int h, boolean isSelected ) {
 if ( isSelected ) {
  g.setColor(UIManager.getColor("TabbedPane.selected"));
 } else {
  g.setColor(tabPane.getBackgroundAt(tabIndex));
 }
 switch(tabPlacement) {
  case LEFT:  g.fillRect(x+1, y+1, w-2, h-3);
  break;
  case RIGHT: g.fillRect(x, y+1, w-2, h-3);
  break;
  case BOTTOM: g.fillRect(x+1, y, w-3, h-1);
  break;
  case TOP: default: g.fillRect(x+1, y+1, w-3, h-1);
 }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/toniclf

!isSelected
    || selectedColor == null
      ? tabPane.getBackgroundAt(tabIndex)
      : selectedColor);
switch (tabPlacement)

代码示例来源:origin: com.jtattoo/JTattoo

protected Color getLoBorderColor(int tabIndex) {
  if ((tabIndex == tabPane.getSelectedIndex()) && tabPane.getBackgroundAt(tabIndex) instanceof ColorUIResource) {
    return AbstractLookAndFeel.getControlColorDark();
  }
  return AbstractLookAndFeel.getControlShadow();
}

代码示例来源:origin: net.sf.taverna.t2.ui-impl/zaria

public void actionPerformed(ActionEvent arg0) {
  int i = tabs.getSelectedIndex();
  Color c = tabs.getBackgroundAt(i);
  Color newColour = JColorChooser.showDialog(ZTabbedPane.this,
      "Pick tab colour", c);
  if (newColour != null) {
    tabs.setBackgroundAt(i, newColour);
  }
}

代码示例来源:origin: com.jtattoo/JTattoo

protected Color[] getTabColors(int tabIndex, boolean isSelected, boolean isRollover) {
  Color backColor = tabPane.getBackgroundAt(tabIndex);
  if ((backColor instanceof UIResource) && isSelected) {
    if (tabPane.getTabPlacement() == BOTTOM) {
      return BOTTOM_SELECTED_TAB_COLORS;
    } else {
      return TOP_SELECTED_TAB_COLORS;
    }
  }
  return super.getTabColors(tabIndex, isSelected, isRollover);
}

代码示例来源:origin: com.jtattoo/JTattoo

protected Color getLoBorderColor(int tabIndex) {
  if (tabIndex == tabPane.getSelectedIndex() && tabPane.getBackgroundAt(tabIndex) instanceof ColorUIResource) {
    return ColorHelper.brighter(AbstractLookAndFeel.getFrameColor(), 10);
  }
  return super.getLoBorderColor(tabIndex);
}

代码示例来源:origin: com.jtattoo/JTattoo

protected void paintTabBackground(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected) {
  if (isSelected) {
    g.setColor(tabPane.getBackgroundAt(tabIndex));
    if (tabPlacement == TOP) {
      g.fillRect(x + 1, y + 1, w - 1, h + 2);
    } else if (tabPlacement == LEFT) {
      g.fillRect(x + 1, y + 1, w + 2, h - 1);
    } else if (tabPlacement == BOTTOM) {
      g.fillRect(x + 1, y - 2, w - 1, h + 1);
    } else {
      g.fillRect(x - 2, y + 1, w + 2, h - 1);
    }
  } else {
    super.paintTabBackground(g, tabPlacement, tabIndex, x, y, w, h, isSelected);
    if (!isSelected && tabIndex == rolloverIndex && tabPane.isEnabledAt(tabIndex)) {
      g.setColor(AbstractLookAndFeel.getFocusColor());
      if (tabPlacement == TOP) {
        g.fillRect(x + 2, y + 1, w - 3, 2);
      } else if (tabPlacement == LEFT) {
        g.fillRect(x, y + 1, w - 1, 2);
      } else if (tabPlacement == BOTTOM) {
        g.fillRect(x + 2, y + h - 3, w - 3, 2);
      } else {
        g.fillRect(x, y + 1, w - 1, 2);
      }
    }
  }
}

代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

@Override
protected void paintTabBackground(Graphics gr, int tabPlacement,
    int tabIndex,
    int x, int y, int w, int h,
    boolean isSelected) {
  Graphics2D g = (Graphics2D) gr;
  g.setColor(!isSelected || selectedColor == null
      ? tabPane.getBackgroundAt(tabIndex) : selectedColor);
  switch (tabPlacement) {
    case LEFT:
      g.fillRect(x + 1, y + 1, w - 1, h - 3);
      break;
    case RIGHT:
      g.fillRect(x, y + 1, w - 2, h - 3);
      break;
    case BOTTOM:
      if (!isSelected) {
        LinearGradientPaint lgp = new LinearGradientPaint(
            new Point2D.Float(x, y), new Point2D.Float(x, y + h - 1),
            enabledStops, enabledStopColors,
            MultipleGradientPaint.CycleMethod.REPEAT);
        g.setPaint(lgp);
      }
      g.fillRect(x + 1, y, w - 3, h - 1);
      break;
    case TOP:
    default:
      g.fillRect(x + 1, y + 1, w - 3, h - 1);
  }
}

代码示例来源:origin: com.jtattoo/JTattoo

protected Color getLoBorderColor(int tabIndex) {
  if (tabIndex == tabPane.getSelectedIndex() 
      && tabPane.getBackgroundAt(tabIndex) instanceof ColorUIResource
      && AbstractLookAndFeel.getTheme().isDarkTexture()) {
    return ColorHelper.darker(super.getLoBorderColor(tabIndex), 20);
  }
  return AbstractLookAndFeel.getFrameColor();
}

代码示例来源:origin: com.jtattoo/JTattoo

protected void paintText(Graphics g, int tabPlacement, Font font, FontMetrics metrics, int tabIndex, String title, Rectangle textRect, boolean isSelected) {
  if (isSelected && tabPane.isEnabledAt(tabIndex) && (tabPane.getBackgroundAt(tabIndex) instanceof ColorUIResource) && (getTextViewForTab(tabIndex) == null)) {
    g.setFont(font);
    Color selColor = AbstractLookAndFeel.getTabSelectionForegroundColor();
    if (ColorHelper.getGrayValue(selColor) > 164) {
      g.setColor(Color.black);
    } else {
      g.setColor(Color.white);
    }
    int mnemIndex = -1;
    if (JTattooUtilities.getJavaVersion() >= 1.4) {
      mnemIndex = tabPane.getDisplayedMnemonicIndexAt(tabIndex);
    }
    JTattooUtilities.drawStringUnderlineCharAt(tabPane, g, title, mnemIndex, textRect.x, textRect.y + 1 + metrics.getAscent());
  }
  super.paintText(g, tabPlacement, font, metrics, tabIndex, title, textRect, isSelected);
}

代码示例来源:origin: com.jtattoo/JTattoo

protected Color getGapColor(int tabIndex) {
  if (isTabOpaque() || tabIndex == tabPane.getSelectedIndex()) {
    if ((tabIndex >= 0) && (tabIndex < tabCount)) {
      Color tabColors[] = getTabColors(tabIndex, tabIndex == tabPane.getSelectedIndex(), false);
      if (tabColors != null && tabColors.length > 0) {
        return tabColors[tabColors.length - 1];
      } else {
        return tabPane.getBackgroundAt(tabIndex);
      }
    }
  }
  if (!tabPane.isOpaque()) {
    Container parent = tabPane.getParent();
    while (parent != null) {
      if (parent.isOpaque()) {
        return parent.getBackground();
      }
      parent = parent.getParent();
    }
  }
  return tabAreaBackground;
}

代码示例来源:origin: com.jtattoo/JTattoo

protected Color getHiBorderColor(int tabIndex) {
  Color backColor = tabPane.getBackgroundAt(tabIndex);
  if (tabIndex == tabPane.getSelectedIndex()) {
    if (backColor instanceof UIResource) {
      return AbstractLookAndFeel.getControlHighlight();
    } else {
      return ColorHelper.brighter(backColor, 40);
    }
  }
  if (tabIndex >= 0 && tabIndex <= tabCount) {
    if (!isTabOpaque() || backColor instanceof UIResource) {
      return AbstractLookAndFeel.getControlHighlight();
    } else {
      return ColorHelper.brighter(backColor, 40);
    }
  }
  return AbstractLookAndFeel.getControlHighlight();
}

代码示例来源:origin: com.github.insubstantial/substance

SubstanceColorScheme colorized = getColorizedScheme(component,
    nonColorized, jtp.getForegroundAt(tabIndex), jtp
        .getBackgroundAt(tabIndex), !componentState
        .isDisabled());
return colorized;

代码示例来源:origin: org.java.net.substance/substance

SubstanceColorScheme colorized = getColorizedScheme(component,
    nonColorized, jtp.getForegroundAt(tabIndex), jtp
        .getBackgroundAt(tabIndex), !componentState
        .isDisabled());
return colorized;

代码示例来源:origin: com.jtattoo/JTattoo

protected Color[] getTabColors(int tabIndex, boolean isSelected, boolean isRollover) {
  Color colorArr[] = AbstractLookAndFeel.getTheme().getTabColors();
  if ((tabIndex >= 0) && (tabIndex < tabPane.getTabCount())) {
    Color backColor = tabPane.getBackgroundAt(tabIndex);
    if ((backColor instanceof UIResource)) {
      if (isSelected) {
        colorArr = AbstractLookAndFeel.getTheme().getSelectedColors();
      } else {
        if (JTattooUtilities.isFrameActive(tabPane)) {
          colorArr = AbstractLookAndFeel.getTheme().getTabColors();
        } else {
          colorArr = AbstractLookAndFeel.getTheme().getInActiveColors();
        }
      }
    } else if (backColor != null) {
      colorArr = ColorHelper.createColorArr(backColor, backColor, 2);
    }
  }
  return colorArr;
}

代码示例来源:origin: com.jtattoo/JTattoo

protected Color[] getTabColors(int tabIndex, boolean isSelected, boolean isRollover) {
  if ((tabIndex >= 0) && (tabIndex < tabPane.getTabCount())) {
    boolean isEnabled = tabPane.isEnabledAt(tabIndex);
    Color backColor = tabPane.getBackgroundAt(tabIndex);
    Color colorArr[];
    if ((backColor instanceof UIResource)) {
      if (isSelected) {
        colorArr = AbstractLookAndFeel.getTheme().getDefaultColors();
      } else if (isRollover && isEnabled) {
        colorArr = AbstractLookAndFeel.getTheme().getRolloverColors();
      } else {
        colorArr = AbstractLookAndFeel.getTheme().getTabColors();
      }
    } else {
      if (isSelected) {
        colorArr = ColorHelper.createColorArr(ColorHelper.brighter(backColor, 60), backColor, 20);
      } else if (isRollover && isEnabled) {
        colorArr = ColorHelper.createColorArr(ColorHelper.brighter(backColor, 80), ColorHelper.brighter(backColor, 20), 20);
      } else {
        colorArr = ColorHelper.createColorArr(ColorHelper.brighter(backColor, 40), ColorHelper.darker(backColor, 10), 20);
      }
    }
    return colorArr;
  }
  return AbstractLookAndFeel.getTheme().getTabColors();
}

代码示例来源:origin: com.jtattoo/JTattoo

protected Color[] getTabColors(int tabIndex, boolean isSelected, boolean isRollover) {
  Color colorArr[] = AbstractLookAndFeel.getTheme().getTabColors();
  if ((tabIndex >= 0) && (tabIndex < tabPane.getTabCount())) {
    boolean isEnabled = tabPane.isEnabledAt(tabIndex);
    Color backColor = tabPane.getBackgroundAt(tabIndex);
    if (backColor instanceof UIResource) {
      if (isSelected) {
        colorArr = AbstractLookAndFeel.getTheme().getSelectedColors();
      } else if (isRollover && isEnabled) {
        colorArr = AbstractLookAndFeel.getTheme().getRolloverColors();
      } else {
        if (JTattooUtilities.isFrameActive(tabPane)) {
          colorArr = AbstractLookAndFeel.getTheme().getTabColors();
        } else {
          colorArr = AbstractLookAndFeel.getTheme().getInActiveColors();
        }
      }
    } else if (backColor != null) {
      if (isSelected) {
        colorArr = ColorHelper.createColorArr(ColorHelper.brighter(backColor, 60), backColor, 20);
      } else if (isRollover && isEnabled) {
        colorArr = ColorHelper.createColorArr(ColorHelper.brighter(backColor, 80), ColorHelper.brighter(backColor, 20), 20);
      } else {
        colorArr = ColorHelper.createColorArr(ColorHelper.brighter(backColor, 40), ColorHelper.darker(backColor, 10), 20);
      }
    }
  }
  return colorArr;
}

相关文章

JTabbedPane类方法