javax.swing.JToolBar.getOrientation()方法的使用及代码示例

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

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

JToolBar.getOrientation介绍

暂无

代码示例

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

private int mapConstraintToOrientation(Object constraint) {
  int orientation = toolBar.getOrientation();
  if (constraint != null) {
    if (constraint.equals(BorderLayout.EAST) || constraint.equals(BorderLayout.WEST)) {
      orientation = JToolBar.VERTICAL;
    } else if (constraint.equals(BorderLayout.NORTH) || constraint.equals(BorderLayout.SOUTH)) {
      orientation = JToolBar.HORIZONTAL;
    }
  }
  return orientation;
}

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

private int mapConstraintToOrientation(String constraint)
{
  int orientation= toolBar.getOrientation();
  if (constraint != null)
  {
    if (constraint.equals(BorderLayout.EAST)
      || constraint.equals(BorderLayout.WEST))
      orientation= JToolBar.VERTICAL;
    else if (
      constraint.equals(BorderLayout.NORTH)
        || constraint.equals(BorderLayout.SOUTH))
      orientation= JToolBar.HORIZONTAL;
  }
  return orientation;
}

代码示例来源:origin: joel-costigliola/assertj-swing

@RunsInCurrentThread
private boolean isHorizontal(@Nonnull JToolBar toolBar) {
 return toolBar.getOrientation() == HORIZONTAL;
}

代码示例来源:origin: com.github.arnabk/pgslookandfeel

public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
  g.translate(x, y);
  if (((JToolBar) c).isFloatable()) {
    if (((JToolBar) c).getOrientation() == HORIZONTAL) {
      PgsUtils.drawVerticalBumps(g, 2, 4, c.getHeight() - 6);
    } else {
      PgsUtils.drawHorizontalBumps(g, 4, 2, c.getWidth() - 6);
    }
  }
  if (((JToolBar) c).getOrientation() == HORIZONTAL) {
    g.setColor(MetalLookAndFeel.getControlShadow());
    //g.drawLine(0, h - 2, w, h - 2);
    g.setColor(UIManager.getColor("ToolBar.borderColor"));
    g.drawLine(0, h - 1, w, h - 1);
  }
  g.translate(-x, -y);
}

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

protected void setOrientedBorder()
{
  if(toolBar.getOrientation()==JToolBar.HORIZONTAL)
    LookAndFeel.installBorder(toolBar, "ToolBar.border");
  else
    LookAndFeel.installBorder(toolBar, "ToolBar.verticalBorder");
}

代码示例来源:origin: net.sf.tinylaf/tinylaf

public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
  if(!(c instanceof JToolBar)) return;
  
  drawXPBorder(c, g, x, y, w, h);
  if(((JToolBar)c).getOrientation() == HORIZONTAL) {
    g.setColor(Theme.toolBarLightColor.getColor());
    g.drawLine(x, y, w - 1, y);				// top
    g.setColor(Theme.toolBarDarkColor.getColor());
    g.drawLine(x, h - 1, w - 1, h - 1);		// bottom
  }
  else {
    g.setColor(Theme.toolBarLightColor.getColor());
    g.drawLine(x, y, x, h - 1);				// left
    g.setColor(Theme.toolBarDarkColor.getColor());
    g.drawLine(w - 1, y, w - 1, h - 1);		// right
  }
}

代码示例来源:origin: khuxtable/seaglass

public void paintBorder(SynthContext context, Graphics g, int x, int y, int w, int h) {
  ((SeaGlassContext) context).getPainter().paintToolBarBorder(context, g, x, y, w, h, toolBar.getOrientation());
}

代码示例来源:origin: net.sf.nimrod/nimrod-laf

public void paintBorder( Component c, Graphics g, int x, int y, int width, int height) {
 Icon icon = null;
 int desp = 0;
 
 if ( ((JToolBar)c).isFloatable() ) {
  if ( ((JToolBar)c).getOrientation() == HORIZONTAL ) {
   icon = UIManager.getIcon( "ScrollBar.verticalThumbIconImage");
   desp = icon.getIconHeight();
   
   for ( int i = 0; i < 5; i++) {
    icon.paintIcon( c, g, x+1, y+1+(desp*i));
   }
  }
  else {
   icon = UIManager.getIcon( "ScrollBar.horizontalThumbIconImage");
   desp = icon.getIconWidth();
   
   for ( int i = 0; i < 5; i++) {
    icon.paintIcon( c, g, x+1+(desp*i), y+1);
   }
  }
 }
}

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

public void paint(Graphics g, JComponent c) {
    int w = c.getWidth();
    int h = c.getHeight();
    JTattooUtilities.fillHorGradient(g, AbstractLookAndFeel.getTheme().getToolBarColors(), 0, 0, w, h - 2);
    if ((toolBar.getOrientation() == JToolBar.HORIZONTAL) && isToolbarDecorated() && isToolBarUnderMenubar()) {
      g.setColor(Color.white);
      g.drawLine(0, 0, w, 0);
      g.drawLine(0, h - 2, w, h - 2);
      g.setColor(ColorHelper.darker(AbstractLookAndFeel.getToolbarColorDark(), 10));
      g.drawLine(0, 1, w, 1);
      g.drawLine(0, h - 1, w, h - 1);
    }
  }
}

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

public void paint(Graphics g, JComponent c) {
    int w = c.getWidth();
    int h = c.getHeight();
    JTattooUtilities.fillHorGradient(g, AbstractLookAndFeel.getTheme().getToolBarColors(), 0, 0, w, h - 2);
    if ((toolBar.getOrientation() == JToolBar.HORIZONTAL) && isToolbarDecorated() && isToolBarUnderMenubar()) {
      g.setColor(Color.white);
      g.drawLine(0, 0, w, 0);
      g.drawLine(0, h - 2, w, h - 2);
      g.setColor(ColorHelper.darker(AbstractLookAndFeel.getToolbarColorDark(), 10));
      g.drawLine(0, 1, w, 1);
      g.drawLine(0, h - 1, w, h - 1);
    }
  }
}

代码示例来源:origin: khuxtable/seaglass

public void paintContent(SeaGlassContext context, Graphics g, Rectangle bounds) {
  SeaGlassLookAndFeel.updateSubregion(context, g, bounds);
  context.getPainter().paintToolBarContentBackground(context, g, bounds.x, bounds.y, bounds.width, bounds.height,
    toolBar.getOrientation());
  context.getPainter().paintToolBarContentBorder(context, g, bounds.x, bounds.y, bounds.width, bounds.height,
    toolBar.getOrientation());
}

代码示例来源:origin: net.sf.tinylaf/tinylaf

/**
 * Returns true if the passed in JMenuBar is above a horizontal JToolBar.
 */
public static boolean doesMenuBarBorderToolBar(JMenuBar c) {
  JToolBar tb = (JToolBar)TinyToolBarUI.findRegisteredComponentOfType(c, JToolBar.class);
  
  if(tb != null && tb.getOrientation() == JToolBar.HORIZONTAL) {
    JRootPane rp = SwingUtilities.getRootPane(c);
    Point point = new Point(0, 0);
    point = SwingUtilities.convertPoint(c, point, rp);
    int menuX = point.x;
    int menuY = point.y;
    point.x = point.y = 0;
    point = SwingUtilities.convertPoint(tb, point, rp);
    
    return (point.x == menuX && menuY + c.getHeight() == point.y && c.getWidth() == tb.getWidth());
  }
  
  return false;
}

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

protected boolean isToolBarUnderMenubar() {
  if (toolBar != null && toolBar.getOrientation() == JToolBar.HORIZONTAL) {
    JRootPane rp = SwingUtilities.getRootPane(toolBar);
    JMenuBar mb = rp.getJMenuBar();
    if (mb != null) {
      Point mbPoint = new Point(0, 0);
      mbPoint = SwingUtilities.convertPoint(mb, mbPoint, rp);
      Point tbPoint = new Point(0, 0);
      tbPoint = SwingUtilities.convertPoint(toolBar, tbPoint, rp);
      tbPoint.y -= mb.getHeight() - 1;
      Rectangle rect = new Rectangle(mbPoint, mb.getSize());
      return rect.contains(tbPoint);
    }
  }
  return false;
}

代码示例来源:origin: net.sourceforge.jadex/jadex-tools-base-swing

/**
   */
  public Dimension getPreferredSize()
  {
    int orient = tb.getOrientation();
    if(orient!=last_orient)
    {
      switch(tb.getOrientation())
      {
        case JToolBar.HORIZONTAL:
          setIcon(icons.getIcon("JadexLogo"));
          break;
        case JToolBar.VERTICAL:
          setIcon(icons.getIcon("JadexLogoV"));
      }
      last_orient = orient;
    }

    return super.getPreferredSize();
  }
}

代码示例来源:origin: khuxtable/seaglass

@Override
public void update(Graphics g, JComponent c) {
  SeaGlassContext context = getContext(c);
  SeaGlassLookAndFeel.update(context, g);
  context.getPainter().paintToolBarBackground(context, g, 0, 0, c.getWidth(), c.getHeight(), toolBar.getOrientation());
  paint(context, g);
  context.dispose();
}

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

public void setOrientation(int orientation)
{
  toolBar.setOrientation(orientation);
  if(toolBar.getOrientation()==JToolBar.HORIZONTAL)
    toolBar.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
  else
    toolBar.setLayout(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 0));
  
  if (dragWindow != null)
    dragWindow.setOrientation(orientation);
}

代码示例来源:origin: com.github.arnabk/pgslookandfeel

public void paint(Graphics g, JComponent b) {
  if (b.isOpaque()) {
    if (PlafOptions.getStyle(PlafOptions.TOOLBAR) == PlafOptions.FLAT_STYLE) {
      g.setColor(b.getBackground());
      g.drawRect(0, 0, b.getWidth(), b.getHeight());
    } else {
      int orient = ((JToolBar) b).getOrientation();
      if (orient == JToolBar.HORIZONTAL) {
        PgsUtils.drawGradient(g, b);
      } else {
        PgsUtils.drawGradient(
            g, 0, 0, b.getWidth(), b.getHeight(),
            (Color) b.getClientProperty("gradientStart"),
            (Color) b.getClientProperty("gradientEnd"));
      }
    }
  }
  super.paint(g, b);
}

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

public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
  if (((JToolBar) c).isFloatable()) {
    if (((JToolBar) c).getOrientation() == HORIZONTAL) {
      int x1 = 4;
      int y1 = (h - HOR_RUBBER_ICON.getIconHeight()) / 2;
      HOR_RUBBER_ICON.paintIcon(c, g, x1, y1);
    } else {
      int x1 = (w - VER_RUBBER_ICON.getIconWidth()) / 2 + 2;
      int y1 = 4;
      VER_RUBBER_ICON.paintIcon(c, g, x1, y1);
    }
  }
}

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

public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
  if (((JToolBar) c).isFloatable()) {
    if (((JToolBar) c).getOrientation() == HORIZONTAL) {
      int x1 = 4;
      int y1 = (h - HOR_RUBBER_ICON.getIconHeight()) / 2;
      HOR_RUBBER_ICON.paintIcon(c, g, x1, y1);
    } else {
      int x1 = (w - VER_RUBBER_ICON.getIconWidth()) / 2 + 2;
      int y1 = 4;
      VER_RUBBER_ICON.paintIcon(c, g, x1, y1);
    }
  }
}

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

@Override
public void installUI(JComponent c) {
  toolBar = (JToolBar) c;
  // Set defaults
  installDefaults();
  installComponents();
  installListeners();
  installKeyboardActions();
  // Initialize instance vars
  dockingSensitivity = 0;
  floating = false;
  floatingX = floatingY = 0;
  floatingToolBar = null;
  setOrientation(toolBar.getOrientation());
  LookAndFeel.installProperty(c, "opaque", Boolean.TRUE);
  if (c.getClientProperty(FOCUSED_COMP_INDEX) != null) {
    focusedCompIndex = ((Integer) (c.getClientProperty(FOCUSED_COMP_INDEX))).intValue();
  }
}

相关文章

JToolBar类方法