当前位置: 首页>>代码示例>>Java>>正文


Java Border类代码示例

本文整理汇总了Java中javax.swing.border.Border的典型用法代码示例。如果您正苦于以下问题:Java Border类的具体用法?Java Border怎么用?Java Border使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Border类属于javax.swing.border包,在下文中一共展示了Border类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: TabsComponent

import javax.swing.border.Border; //导入依赖的package包/类
/** Creates a new instance of TabsComponent */
public TabsComponent(boolean toolVis) {
    super();
    bar = new JToolBar();
    Border b = (Border)UIManager.get("Nb.Editor.Toolbar.border"); //NOI18N
    bar.setBorder(b);
    bar.setFloatable(false);
    bar.setFocusable(true);
    if( "Windows".equals( UIManager.getLookAndFeel().getID())
            && !isXPTheme()) {
        bar.setRollover(true);
    } else if( AQUA ) {
        bar.setBackground(UIManager.getColor("NbExplorerView.background"));
    }

    setLayout(new BorderLayout());
    add(bar, BorderLayout.NORTH);
    startToggling();
    setToolbarBarVisible(toolVis);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:TabsComponent.java

示例2: repaintBorder

import javax.swing.border.Border; //导入依赖的package包/类
public static void repaintBorder(final JComponent c) {
    JComponent borderedComponent = c;
    Border border = c.getBorder();
    if (border == null) {
        // See if it's inside a JScrollpane or something
        final Container p = c.getParent();
        if (p instanceof JViewport) {
            borderedComponent = (JComponent)p.getParent();
            if (borderedComponent != null) border = borderedComponent.getBorder();
        }
    }

    // If we really don't have a border, then bail
    // It might be a compound border with a ThemeBorder inside
    // The check for that case is tricky, so we just go ahead and repaint any border
    if (border == null || borderedComponent == null) return;

    final int width = borderedComponent.getWidth();
    final int height = borderedComponent.getHeight();
    final Insets i = borderedComponent.getInsets();

    borderedComponent.repaint(0, 0, width, i.top); // Top edge
    borderedComponent.repaint(0, 0, i.left, height); // Left edge
    borderedComponent.repaint(0, height - i.bottom, width, i.bottom); // Bottom edge
    borderedComponent.repaint(width - i.right, 0, i.right, height); // Right edge
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:27,代码来源:AquaBorder.java

示例3: createButtonArea

import javax.swing.border.Border; //导入依赖的package包/类
/**
 * Creates and returns a Container containing the buttons. The buttons
 * are created by calling <code>getButtons</code>.
 */
protected Container createButtonArea() {
    JPanel bottom = new JPanel();
    Border border = (Border)DefaultLookup.get(optionPane, this,
                                      "OptionPane.buttonAreaBorder");
    bottom.setName("OptionPane.buttonArea");
    if (border != null) {
        bottom.setBorder(border);
    }
    bottom.setLayout(new ButtonAreaLayout(
       DefaultLookup.getBoolean(optionPane, this,
                                "OptionPane.sameSizeButtons", true),
       DefaultLookup.getInt(optionPane, this, "OptionPane.buttonPadding",
                            6),
       DefaultLookup.getInt(optionPane, this,
                    "OptionPane.buttonOrientation", SwingConstants.CENTER),
       DefaultLookup.getBoolean(optionPane, this, "OptionPane.isYesLast",
                                false)));
    addButtonComponents(bottom, getButtons(), getInitialValueIndex());
    return bottom;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:BasicOptionPaneUI.java

示例4: test

import javax.swing.border.Border; //导入依赖的package包/类
private static void test(Border border) {
    Insets actual = border.getBorderInsets(null);
    if (NEGATIVE.equals(actual)) {
        throw new Error("unexpected insets in " + border.getClass());
    }
    Insets expected = (Insets) actual.clone();
    // modify
    actual.top++;
    actual.left++;
    actual.right++;
    actual.bottom++;
    // validate
    if (!expected.equals(border.getBorderInsets(null))) {
        throw new Error("shared insets in " + border.getClass());
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:Test6657026.java

示例5: paint

import javax.swing.border.Border; //导入依赖的package包/类
@Override
public void paint(Graphics g) {
    if (!(component instanceof TranslatedTableCellRenderer)) {
        g.translate(-outline.getTreePositionX(), 0);
    }
    try {
        component.paint(g);
    } catch (NullPointerException npe) {
        // http://netbeans.org/bugzilla/show_bug.cgi?id=194055
        javax.swing.border.Border border = null;
        Exceptions.printStackTrace(Exceptions.attachMessage(npe,
                "Failed painting of component "+component+
                " with border "+((component instanceof JComponent) ? (border = ((JComponent) component).getBorder()) : null)+
                ((border instanceof javax.swing.border.CompoundBorder) ?
                    ", with outsideBorder = "+((javax.swing.border.CompoundBorder) border).getOutsideBorder()+
                    " and insideBorder = "+((javax.swing.border.CompoundBorder) border).getInsideBorder() : "")
        ));
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:OutlineView.java

示例6: uninstallDefaults

import javax.swing.border.Border; //导入依赖的package包/类
/**
 * Uninstalls any state that this style installed on
 * the <code>JComponent</code> from <code>context</code>.
 * <p>
 * Styles should NOT depend upon this being called, in certain cases
 * it may never be called.
 *
 * @param context SynthContext identifying component to install properties
 *        to.
 */
public void uninstallDefaults(SynthContext context) {
    if (!context.isSubregion()) {
        // NOTE: because getForeground, getBackground and getFont will look
        // at the parent Container, if we set them to null it may
        // mean we they return a non-null and non-UIResource value
        // preventing install from correctly settings its colors/font. For
        // this reason we do not uninstall the fg/bg/font.

        JComponent c = context.getComponent();
        Border border = c.getBorder();

        if (border instanceof UIResource) {
            c.setBorder(null);
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:SynthStyle.java

示例7: createInstanceImpl

import javax.swing.border.Border; //导入依赖的package包/类
protected Border createInstanceImpl() {
    if (highlight == null && shadow == null) {
        return BorderFactory.createEtchedBorder(etchType);
    } else {
        return BorderFactory.createEtchedBorder(etchType,
                highlight == null ? null : highlight.createInstance(),
                shadow == null ? null : shadow.createInstance());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:BorderBuilders.java

示例8: FooterBar

import javax.swing.border.Border; //导入依赖的package包/类
public FooterBar() {
	
	setPreferredSize(new Dimension(640, 16));
	setLayout(new GridLayout());
	setBorder(new BevelBorder(BevelBorder.LOWERED));
	
	Border margin = new EmptyBorder(0, 5, 0, 5);
	
	label = new JLabel("Ready", SwingConstants.LEFT);
	label.setBorder(margin);
	add(label);
	
	progress = new JProgressBar();
	progress.setMaximum(6);
	progress.setStringPainted(true);
	progress.setPreferredSize(new Dimension(10, 16));
	progress.setValue(0);
	add(progress);
	
}
 
开发者ID:condolent,项目名称:USB3Installer,代码行数:21,代码来源:FooterBar.java

示例9: configure

import javax.swing.border.Border; //导入依赖的package包/类
public void configure( Color foreground, Color background, boolean isSelected, boolean hasFocus, int rowHeight, int rowWidth ) {
    removeAll();
    int maxWidth = rowWidth - SelectionList.INSETS_LEFT - SelectionList.INSETS_RIGHT;
    JComponent inner = node.getComponent( foreground, background, isSelected, hasFocus, maxWidth > 0 ? maxWidth : 0);
    add( inner, BorderLayout.CENTER );

    setBackground( background );
    setForeground( foreground );

    Border border = null;
    if( hasFocus ) {
        if( isSelected ) {
            border = UIManager.getBorder( "List.focusSelectedCellHighlightBorder" ); // NOI18N
        }
        if( border == null ) {
            border = UIManager.getBorder( "List.focusCellHighlightBorder" ); // NOI18N
        }
    }
    if( null != border ) {
        border = BorderFactory.createCompoundBorder( border,
                BorderFactory.createEmptyBorder( SelectionList.INSETS_TOP, SelectionList.INSETS_LEFT,
                SelectionList.INSETS_BOTTOM, SelectionList.INSETS_RIGHT ) );
    } else {
        border = BorderFactory.createEmptyBorder( SelectionList.INSETS_TOP, SelectionList.INSETS_LEFT,
                SelectionList.INSETS_BOTTOM, SelectionList.INSETS_RIGHT );
    }

    try {
        setBorder( border );
    } catch( NullPointerException npe ) {
        //workaround for 175940
        Logger.getLogger( ListRendererPanel.class.getName() ).log( Level.INFO, "Bug #175940", npe );
    }

    RendererPanel.configureAccessibility(this, false);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:37,代码来源:ListRendererPanel.java

示例10: make

import javax.swing.border.Border; //导入依赖的package包/类
/** Assign the given attributes to the given JComponent, then return the JComponent again.
 * <p> If <b>Font</b>      x is given in the list, we call obj.setFont(x)
 * <p> If <b>String</b>    x is given in the list, we call obj.setToolTipText(x)
 * <p> If <b>Border</b>    x is given in the list, we call obj.setBorder(x)
 * <p> If <b>Dimension</b> x is given in the list, we call obj.setPreferredSize(x)
 * <p> If <b>Color</b> x is given in the list, and it's the first color, we call obj.setForeground(x)
 * <p> If <b>Color</b> x is given in the list, and it's not the first color, we call obj.setBackground(x) then obj.setOpaque(true)
 * <p> (If no Font is given, then after all these changes have been applied, we will call obj.setFont() will a default font)
 */
public static<X extends JComponent> X make(X obj, Object... attributes) {
   boolean hasFont = false, hasForeground = false;
   if (attributes!=null) for(Object x: attributes) {
      if (x instanceof Font) { obj.setFont((Font)x); hasFont=true; }
      if (x instanceof String) { obj.setToolTipText((String)x); }
      if (x instanceof Border) { obj.setBorder((Border)x); }
      if (x instanceof Dimension) { obj.setPreferredSize((Dimension)x); }
      if (x instanceof Color && !hasForeground) { obj.setForeground((Color)x); hasForeground=true; continue; }
      if (x instanceof Color) { obj.setBackground((Color)x); obj.setOpaque(true); }
   }
   if (!hasFont) obj.setFont(getVizFont());
   return obj;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:23,代码来源:OurUtil.java

示例11: testGetter

import javax.swing.border.Border; //导入依赖的package包/类
public void testGetter () {
    Scene scene = new Scene ();
    BevelBorder originalBorder = new BevelBorder (BevelBorder.RAISED);
    scene.setBorder (originalBorder);
    Border foundBorder = BorderSupport.getSwingBorder (scene.getBorder ());
    assertEquals (originalBorder, foundBorder);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:SwingBorderGetterTest.java

示例12: main

import javax.swing.border.Border; //导入依赖的package包/类
public static void main(String[] args) {
    for (Border border : BORDERS) {
        System.out.println(border.getClass());
        test(border, border.getBorderInsets(getComponent(border)));
        if (border instanceof AbstractBorder) {
            test((AbstractBorder) border);
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:10,代码来源:Test4856008.java

示例13: getInsets

import javax.swing.border.Border; //导入依赖的package包/类
/**
 * If a border has been set on this component, returns the
 * border's insets, else calls super.getInsets.
 *
 * @return the value of the insets property.
 * @see #setBorder
 */
public Insets getInsets() {
    Border    border = getBorder();

    if (border != null) {
        return border.getBorderInsets(this);
    }
    return super.getInsets();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:BasicSplitPaneDivider.java

示例14: installDefaults

import javax.swing.border.Border; //导入依赖的package包/类
protected void installDefaults(final AbstractButton b) {
    // load shared instance defaults
    final String pp = getPropertyPrefix();

    if (!defaults_initialized) {
        defaultDisabledTextColor = UIManager.getColor(pp + "disabledText");
        defaults_initialized = true;
    }

    setButtonMarginIfNeeded(b, UIManager.getInsets(pp + "margin"));

    LookAndFeel.installColorsAndFont(b, pp + "background", pp + "foreground", pp + "font");
    LookAndFeel.installProperty(b, "opaque", UIManager.getBoolean(pp + "opaque"));

    final Object borderProp = b.getClientProperty(BUTTON_TYPE);
    boolean hasBorder = false;

    if (borderProp != null) {
        hasBorder = setButtonType(b, borderProp);
    }
    if (!hasBorder) setThemeBorder(b);

    final Object segmentProp = b.getClientProperty(SEGMENTED_BUTTON_POSITION);
    if (segmentProp != null) {
        final Border border = b.getBorder();
        if (!(border instanceof AquaBorder)) return;

        b.setBorder(AquaButtonExtendedTypes.getBorderForPosition(b, b.getClientProperty(BUTTON_TYPE), segmentProp));
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:31,代码来源:AquaButtonUI.java

示例15: getComponent

import javax.swing.border.Border; //导入依赖的package包/类
private static JComponent getComponent(Border border) {
    Class type = border.getClass();
    if (type.equals(MotifBorders.MotifPopupMenuBorder.class)) {
        return POPUP;
    }
    if (type.equals(WindowsBorders.ToolBarBorder.class)) {
        return TOOLBAR;
    }
    if (type.equals(MetalBorders.ToolBarBorder.class)) {
        return TOOLBAR;
    }
    return LABEL;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:Test4856008.java


注:本文中的javax.swing.border.Border类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。