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


Java JComponent.getHeight方法代码示例

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


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

示例1: paintDisplayerBackground

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

    int x = 0;
    int y = 0;
    int width = c.getWidth();
    int height = c.getHeight();
    
    Object o = null;
    o = UIManager.get("TabbedPane:TabbedPaneTab[Enabled].backgroundPainter");

    if ((o != null) && (o instanceof javax.swing.Painter)) {
        javax.swing.Painter painter = (javax.swing.Painter) o;
        BufferedImage bufIm = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        Graphics2D g2d = bufIm.createGraphics();
        g2d.setBackground(UIManager.getColor("Panel.background"));
        g2d.clearRect(0, 0, width, height);
        painter.paint(g2d, null, width, height);
        g.drawImage(bufIm, x, y, null);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:NimbusViewTabDisplayerUI.java

示例2: 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

示例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, 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

示例4: 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

示例5: 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

示例6: 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

示例7: getHeight

import javax.swing.JComponent; //导入方法依赖的package包/类
private int getHeight(JComponent component) {
    Dimension size = getSize(component);

    if (size == null) {
        return component.getHeight();
    }
    return size.height;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:ComponentPanel.java

示例8: 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

示例9: getExactTabIndication

import javax.swing.JComponent; //导入方法依赖的package包/类
@Override
    public Polygon getExactTabIndication(int index) {
        // TBD - the same code is copied in ScrollableTabsUI, should be shared
        // if will not differ
//        GeneralPath indication = new GeneralPath();
        JComponent control = getDisplayer();
        int height = control.getHeight();

        TabLayoutModel tlm = getLayoutModel();

        int tabXStart = tlm.getX(index);

        int tabXEnd = tabXStart + tlm.getW(index);

        int[] xpoints = new int[4];
        int[] ypoints = new int[4];
        xpoints[0] = tabXStart;
        ypoints[0] = 0;
        xpoints[1] = tabXEnd;
        ypoints[1] = 0;
        xpoints[2] = tabXEnd;
        ypoints[2] = height - 1;
        xpoints[3] = tabXStart;
        ypoints[3] = height - 1;

        return new EqualPolygon(xpoints, ypoints);
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:AbstractViewTabDisplayerUI.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: 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:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:SynthToggleButtonUI.java

示例12: 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

示例13: dragGestureRecognized

import javax.swing.JComponent; //导入方法依赖的package包/类
@Override
public final void dragGestureRecognized(DragGestureEvent dge) {
	TreePath path = tree.getSelectionPath();
	if (path != null) {
		draggedNode = path.getLastPathComponent();
		if (drawImage) {
			Rectangle pathBounds = tree.getPathBounds(path); // getpathbounds
																// of
																// selectionpath
			JComponent lbl = (JComponent) tree.getCellRenderer().getTreeCellRendererComponent(tree, draggedNode,
					false, tree.isExpanded(path), tree.getModel().isLeaf(path.getLastPathComponent()), 0,
					false);// returning the label
			lbl.setBounds(pathBounds);// setting bounds to lbl
			image = new BufferedImage(lbl.getWidth(), lbl.getHeight(),
					java.awt.image.BufferedImage.TYPE_INT_ARGB_PRE);// buffered
																	// image
																	// reference
																	// passing
																	// the
																	// label's
																	// ht
																	// and
																	// width
			Graphics2D graphics = image.createGraphics();// creating
															// the
															// graphics
															// for
															// buffered
															// image
			graphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f)); // Sets
																								// the
																								// Composite
																								// for
																								// the
																								// Graphics2D
																								// context
			lbl.setOpaque(false);
			lbl.paint(graphics); // painting the graphics to label
			graphics.dispose();
		}
		dragSource.startDrag(dge, DragSource.DefaultMoveNoDrop, image, new Point(0, 0),
				new TransferableNode(draggedNode), this);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:45,代码来源:JTreeUtil.java

示例14: isBelowItem

import javax.swing.JComponent; //导入方法依赖的package包/类
public static boolean isBelowItem(Point pt, JComponent tcomp) {
    return pt.y > tcomp.getHeight()/2;
}
 
开发者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.getHeight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。