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


Java JComponent.getWidth方法代码示例

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


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

示例1: paint

import javax.swing.JComponent; //导入方法依赖的package包/类
@Override
public void paint( Graphics g, JComponent c ) {
    super.paint( g, c ); //To change body of generated methods, choose Tools | Templates.
    if( null != lastLocation && isDragging ) {
        Rectangle rect = new Rectangle();
        if( horizontalSplit ) {
            rect.width = splitterWidth;
            rect.height = c.getHeight();
            rect.x = lastLocation.x;
        } else {
            rect.width = c.getWidth();
            rect.height = splitterWidth;
            rect.y = lastLocation.y;
        }
        g.setColor( FILL_COLOR );
        g.fillRect( rect.x, rect.y, rect.width, rect.height );
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:SplitLayerUI.java

示例2: paintDisplayerBackground

import javax.swing.JComponent; //导入方法依赖的package包/类
/**
 * Paint the background when using non-stretching tabs.
 * @param g
 * @param c 
 * @since 1.27
 */
protected void paintDisplayerBackground( Graphics g, JComponent c ) {
    int x;
    int width;
    if( !isUseStretchingTabs() ) {
        x = 0;
        width = c.getWidth();
        if( dataModel.size() > 0 ) {
            x += layoutModel.getX( dataModel.size()-1 );
            x += layoutModel.getW( dataModel.size()-1 )-1;
            width -= x;
        }
        paintTabBackground( g, -1, x, 0, width, c.getHeight());
        paintTabBorder( g, -1, x, 0, width, c.getHeight());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:AbstractViewTabDisplayerUI.java

示例3: actionPerformed

import javax.swing.JComponent; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent ae) {
    if ("pressed".equals(ae.getActionCommand())) { //NOI18N
        JComponent jc = (JComponent) ae.getSource();
        Point p = new Point(jc.getWidth(), jc.getHeight());
        SwingUtilities.convertPointToScreen(p, jc);
        if (!ButtonPopupSwitcher.isShown()) {
            ButtonPopupSwitcher.showPopup(jc, displayer, p.x, p.y);
        } else {
            ButtonPopupSwitcher.hidePopup();
        }
        //Other portion of issue 37487, looks funny if the
        //button becomes pressed
        if (jc instanceof AbstractButton) {
            AbstractButton jb = (AbstractButton) jc;
            jb.getModel().setPressed(false);
            jb.getModel().setRollover(false);
            jb.getModel().setArmed(false);
            jb.repaint();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:TabListPopupAction.java

示例4: actionPerformed

import javax.swing.JComponent; //导入方法依赖的package包/类
@Override
public void actionPerformed( ActionEvent ae ) {
    if ("pressed".equals(ae.getActionCommand())) { //NOI18N
        JComponent jc = (JComponent) ae.getSource();
        Point p = new Point(jc.getWidth(), jc.getHeight());
        SwingUtilities.convertPointToScreen(p, jc);
        if (!ButtonPopupSwitcher.isShown()) {
            ButtonPopupSwitcher.showPopup(jc, controller, p.x, p.y);
        } else {
            ButtonPopupSwitcher.hidePopup();
        }
        //Other portion of issue 37487, looks funny if the
        //button becomes pressed
        if (jc instanceof AbstractButton) {
            AbstractButton jb = (AbstractButton) jc;
            jb.getModel().setPressed(false);
            jb.getModel().setRollover(false);
            jb.getModel().setArmed(false);
            jb.repaint();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:TabListPopupAction.java

示例5: paint

import javax.swing.JComponent; //导入方法依赖的package包/类
@Override
public void paint(Graphics g, JComponent c) {
	AbstractButton b = (AbstractButton) c;
	if (RapidLookTools.isToolbarButton(b)) {
		RapidLookTools.drawToolbarButton(g, b);
		super.paint(g, c);
		return;
	}

	int w = c.getWidth();
	int h = c.getHeight();
	if (w <= 0 || h <= 0) {
		return;
	}

	if (b.isContentAreaFilled()) {
		RapidLookTools.drawButton(b, g, RapidLookTools.createShapeForButton(b));
	}
	if (b.isBorderPainted()) {
		RapidLookTools.drawButtonBorder(b, g, RapidLookTools.createBorderShapeForButton(b));
	}
	super.paint(g, c);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:24,代码来源:ButtonUI.java

示例6: paintBorder

import javax.swing.JComponent; //导入方法依赖的package包/类
/**
 * Draws the border of the combobox.
 */
private void paintBorder(Graphics g, JComponent c) {
	int w = c.getWidth();
	int h = c.getHeight();
	if (w <= 0 || h <= 0) {
		return;
	}

	Graphics2D g2 = (Graphics2D) g;
	g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
	boolean hasFocus = comboBox.isEditable() ? c.isFocusOwner()
			|| ((JComboBox) c).getEditor().getEditorComponent().isFocusOwner() : c.isFocusOwner();
			if (c.isEnabled()) {
				if (hasFocus) {
					g2.setColor(Colors.COMBOBOX_BORDER_FOCUS);
				} else {
					g2.setColor(Colors.COMBOBOX_BORDER);
				}
			} else {
				g2.setColor(Colors.COMBOBOX_BORDER_DISABLED);
			}

			g2.drawRoundRect(0, 0, w - 1, h - 1, RapidLookAndFeel.CORNER_DEFAULT_RADIUS, RapidLookAndFeel.CORNER_DEFAULT_RADIUS);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:27,代码来源:ComboBoxUI.java

示例7: getPages

import javax.swing.JComponent; //导入方法依赖的package包/类
public PrintPage[][] getPages(int pageWidth, int pageHeight, double pageZoom) {
    List<ComponentPage> pages = new ArrayList<ComponentPage>();
    JComponent component = getComponent();

    if (component == null) {
        return new PrintPage[0][0];
    }
    int componentWidth = component.getWidth();
    int componentHeight = component.getHeight();

    double zoom = getZoom(pageZoom, pageWidth, pageHeight, componentWidth, componentHeight);

    componentWidth = (int) Math.floor(componentWidth * zoom);
    componentHeight = (int) Math.floor(componentHeight * zoom);

    int row = 0;
    int column = 0;

    for (int h = 0; h < componentHeight; h += pageHeight) {
        row++;
        column = 0;

        for (int w = 0; w < componentWidth; w += pageWidth) {
            column++;
            Rectangle piece = new Rectangle((column - 1) * pageWidth, (row - 1) * pageHeight, pageWidth, pageHeight);
            pages.add(new ComponentPage(component, piece, zoom, row - 1, column - 1));
        }
    }
    PrintPage[][] printPages = new PrintPage[row][column];

    for (ComponentPage page : pages) {
        printPages[page.getRow()][page.getColumn()] = page;
    }
    return printPages;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:ComponentProvider.java

示例8: paintBackground

import javax.swing.JComponent; //导入方法依赖的package包/类
@Override
void paintBackground(SynthContext context, Graphics g, JComponent c) {
    if (((AbstractButton) c).isContentAreaFilled()) {
        int x = 0, y = 0, w = c.getWidth(), h = c.getHeight();
        SynthPainter painter = context.getPainter();
        painter.paintToggleButtonBackground(context, g, x, y, w, h);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:SynthToggleButtonUI.java

示例9: paintCloseButton

import javax.swing.JComponent; //导入方法依赖的package包/类
private void paintCloseButton(Graphics g, JComponent c) {
    if (((AbstractTabCellRenderer) c).isShowCloseButton()) {
        
        Rectangle r = new Rectangle(0, 0, c.getWidth(), c.getHeight());
        Rectangle cbRect = new Rectangle();
        getCloseButtonRectangle((JComponent) c, cbRect, r);
        
        //paint close button
        String iconPath = findIconPath( (NimbusEditorTabCellRenderer)c  );
        Icon icon = TabControlButtonFactory.getIcon( iconPath );
        icon.paintIcon(c, g, cbRect.x, cbRect.y);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:NimbusEditorTabCellRenderer.java

示例10: getInsertTabIndication

import javax.swing.JComponent; //导入方法依赖的package包/类
@Override
public Polygon getInsertTabIndication(int index) {
    EqualPolygon indication = new EqualPolygon();
    JComponent control = getDisplayer();
    int height = control.getHeight();
    int width = control.getWidth();
    TabLayoutModel tlm = getLayoutModel();

    int tabXStart;
    int tabXEnd;
    if (index == 0) {
        tabXStart = 0;
        tabXEnd = tlm.getW(0) / 2;
    } else if (index >= getDataModel().size()) {
        tabXStart = tlm.getX(index - 1) + tlm.getW(index - 1) / 2;
        tabXEnd = tabXStart + tlm.getW(index - 1);
        if (tabXEnd > width) {
            tabXEnd = width;
        }
    } else {
        tabXStart = tlm.getX(index - 1) + tlm.getW(index - 1) / 2;
        tabXEnd = tlm.getX(index) + tlm.getW(index) / 2;
    }

    indication.moveTo(tabXStart, 0);
    indication.lineTo(tabXEnd, 0);
    indication.lineTo(tabXEnd, height - 1);
    indication.lineTo(tabXStart, height - 1);
    return indication;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:AbstractViewTabDisplayerUI.java

示例11: ButtonPopupSwitcher

import javax.swing.JComponent; //导入方法依赖的package包/类
/** Creates a new instance of TabListPanel */
private ButtonPopupSwitcher(JComponent owner, SwitcherTableItem items[], int x, int y) {
    int ownerWidth = owner.getWidth();
    int ownerHeight = owner.getHeight();
    int cornerX, cornerY;
    int xOrient, yOrient;
    Rectangle screenRect = Utilities.getUsableScreenBounds();

    // get rid of the effect when popup seems to be higher that screen height
    int gap = (y == 0 ? 10 : 5);
    int height = 0;
    int width = 0;

    int leftD = x - screenRect.x;
    int rightD = screenRect.x + screenRect.width - x;
    if (leftD < rightD / 2) {
        xOrient = 1;
        width = rightD;
        cornerX = x + 1;
    } else {
        xOrient = -1;
        width = leftD + ownerWidth;
        cornerX = x + ownerWidth;
    }
    int topD = y - screenRect.y;
    int bottomD = screenRect.y + screenRect.height - y;
    if (bottomD < topD / 4) {
        yOrient = -1;
        height = topD - gap;
        cornerY = y;
    } else {
        yOrient = 1;
        cornerY = y + ownerHeight;
        height = screenRect.height - cornerY - gap;
    }

    this.pTable = new SwitcherTable(items, height, width);
    this.x = cornerX - (xOrient == -1 ? (int) pTable.getPreferredSize().getWidth() : 0);
    this.y = cornerY - (yOrient == -1 ? (int) pTable.getPreferredSize().getHeight() : 0);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:41,代码来源:ButtonPopupSwitcher.java

示例12: drawTiledImage

import javax.swing.JComponent; //导入方法依赖的package包/类
/**
 * Draw a (usually small) background image into a (usually larger)
 * space specified by a component, tiling the image to fill up the
 * space.  If the image is not available, just fill with the background
 * colour.
 *
 * @param resource The name of the {@code ImageResource} to tile with.
 * @param g The {@code Graphics} to draw to.
 * @param c The {@code JComponent} that defines the space.
 * @param insets Optional {@code Insets} to apply.
 */
public static void drawTiledImage(String resource, Graphics g,
                                  JComponent c, Insets insets) {
    int width = c.getWidth();
    int height = c.getHeight();
    int xmin, ymin;
    if (insets == null) {
        xmin = 0;
        ymin = 0;
    } else {
        xmin = insets.left;
        ymin = insets.top;
        width -= insets.left + insets.right;
        height -= insets.top + insets.bottom;
    }

    if (ResourceManager.hasImageResource(resource)) {
        BufferedImage image = ResourceManager.getImage(resource);
        // FIXME: Test and profile if calling fillTexture is better.
        int dx = image.getWidth();
        int dy = image.getHeight();
        int xmax = xmin + width;
        int ymax = ymin + height;
        for (int x = xmin; x < xmax; x += dx) {
            for (int y = ymin; y < ymax; y += dy) {
                g.drawImage(image, x, y, null);
            }
        }
    } else {
        g.setColor(c.getBackground());
        g.fillRect(xmin, ymin, width, height);
    }
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:44,代码来源:ImageLibrary.java

示例13: isMenuRightEdge

import javax.swing.JComponent; //导入方法依赖的package包/类
public static boolean isMenuRightEdge(Point pt, JComponent menu) {
    return pt.x > menu.getWidth()-8;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:DropTargetLayer.java

示例14: isSubMenuRightEdge

import javax.swing.JComponent; //导入方法依赖的package包/类
public static boolean isSubMenuRightEdge(Point pt, JComponent menu) {
    return pt.x > menu.getWidth()-30;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:DropTargetLayer.java

示例15: paintThumb

import javax.swing.JComponent; //导入方法依赖的package包/类
@Override
protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) {

	boolean isVertical=c.getWidth()<c.getHeight();
	
	int barwidth=isVertical ? thumbBounds.width/2 : thumbBounds.height/2;
	
	Graphics2D g2=(Graphics2D) g;
	
 g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
 g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
 g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
 
	g2.setColor(fore);
	
	if(isVertical)
		g2.fillRoundRect(thumbBounds.x+barwidth/2, thumbBounds.y, barwidth, thumbBounds.height, barwidth,barwidth);
	else
		g2.fillRoundRect(thumbBounds.x, thumbBounds.y+barwidth/2, thumbBounds.width, barwidth, barwidth,barwidth);
	
}
 
开发者ID:davovoid,项目名称:faitic-checker,代码行数:22,代码来源:CustomScrollBarUI.java


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