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


Java Component.getHeight方法代码示例

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


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

示例1: exportVectorGraphics

import java.awt.Component; //导入方法依赖的package包/类
private void exportVectorGraphics(String formatName, File outputFile) throws ImageExportException {
	Component component = printableComponent.getExportComponent();
	int width = component.getWidth();
	int height = component.getHeight();
	try (FileOutputStream fs = new FileOutputStream(outputFile)) {
		switch (formatName) {
			case PDF:
				// create pdf document with slightly increased width and height
				// (otherwise the image gets cut off)
				Document document = new Document(new Rectangle(width + 5, height + 5));
				PdfWriter writer = PdfWriter.getInstance(document, fs);
				document.open();
				PdfContentByte cb = writer.getDirectContent();
				PdfTemplate tp = cb.createTemplate(width, height);
				Graphics2D g2 = tp.createGraphics(width, height, new DefaultFontMapper());
				component.print(g2);
				g2.dispose();
				cb.addTemplate(tp, 0, 0);
				document.close();
				break;
			case SVG:
				exportFreeHep(component, fs, new SVGGraphics2D(fs, new Dimension(width, height)));
				break;
			case EPS:
				exportFreeHep(component, fs, new PSGraphics2D(fs, new Dimension(width, height)));
				break;
			default:
				// cannot happen
				break;
		}
	} catch (Exception e) {
		throw new ImageExportException(I18N.getMessage(I18N.getUserErrorMessagesBundle(),
				"error.image_export.export_failed"), e);
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:36,代码来源:ImageExporter.java

示例2: isButtonOnScreen

import java.awt.Component; //导入方法依赖的package包/类
/**
 * method to get to know whether the AbstractButton with the given key is on Screen
 *
 * @param dockableKey
 *            i18nKey of the wanted AbstractButton
 * @return returns 0 if the AbstractButton is on the Screen, 1 if the AbstractButton is on
 *         Screen but the user can not see it with the current settings of the perspective and
 *         -1 if the AbstractButton is not on the Screen.
 */
public static int isButtonOnScreen(final String buttonKey) {
	// find the Button and return -1 if we can not find it
	Component onScreen;
	try {
		onScreen = BubbleWindow.findButton(buttonKey, RapidMinerGUI.getMainFrame());
	} catch (NullPointerException e) {
		return OBJECT_NOT_ON_SCREEN;
	}
	if (onScreen == null) {
		return OBJECT_NOT_ON_SCREEN;
	}
	// detect whether the Button is viewable
	int xposition = onScreen.getLocationOnScreen().x;
	int yposition = onScreen.getLocationOnScreen().y;
	int otherXposition = xposition + onScreen.getWidth();
	int otherYposition = yposition + onScreen.getHeight();
	Window frame = RapidMinerGUI.getMainFrame();
	if (otherXposition <= frame.getWidth() && otherYposition <= frame.getHeight() && xposition > 0 && yposition > 0) {
		return OBJECT_SHOWING_ON_SCREEN;
	} else {
		return OBJECT_NOT_SHOWING;
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:33,代码来源:BubbleWindow.java

示例3: componentShown

import java.awt.Component; //导入方法依赖的package包/类
/**
 * May be called for either component or horizontal scrollbar.
 */
public @Override void componentShown(ComponentEvent e) {
    // Called when horizontal scrollbar gets visible
    // (but the same listener added to component as well so must check first)
    // Check whether present caret position will not get hidden
    // under horizontal scrollbar and if so scroll the view
    Component hScrollBar = e.getComponent();
    if (hScrollBar != component) { // really called for horizontal scrollbar
        Component scrollPane = hScrollBar.getParent();
        if (caretBounds != null && scrollPane instanceof JScrollPane) {
            Rectangle viewRect = ((JScrollPane)scrollPane).getViewport().getViewRect();
            Rectangle hScrollBarRect = new Rectangle(
                    viewRect.x,
                    viewRect.y + viewRect.height,
                    hScrollBar.getWidth(),
                    hScrollBar.getHeight()
                    );
            if (hScrollBarRect.intersects(caretBounds)) {
                // Update caret's position
                dispatchUpdate(true); // should be visible so scroll the view
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:BaseCaret.java

示例4: getInteriorPolygon

import java.awt.Component; //导入方法依赖的package包/类
public Polygon getInteriorPolygon(Component c) {
    NimbusEditorTabCellRenderer ren = (NimbusEditorTabCellRenderer) c;

    Insets ins = getBorderInsets(c);
    Polygon p = new Polygon();
    int x = -3;
    int y = 0;

    int width = c.getWidth() + 3;
    int height = c.getHeight() - 4;

    //Modified to return rectangle
    p.addPoint(x, y);
    p.addPoint(x + width, y);
    p.addPoint(x + width, y + height);
    p.addPoint(x, y + height);
    return p;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:NimbusEditorTabCellRenderer.java

示例5: testDragNDropToolbar

import java.awt.Component; //导入方法依赖的package包/类
/** Test of dragNDropToolbar method. Tries to move toolbar down and checks
 * whether main window is enlarged. */
public void testDragNDropToolbar() throws InterruptedException {
    // need toolbar container to check drag and drop operation
    Component toolbarPool = mainWindowOper.findSubComponent(new ComponentChooser() {

        @Override
        public boolean checkComponent(Component comp) {
            return comp.getClass().getName().equals("org.openide.awt.ToolbarPool");
        }

        @Override
        public String getDescription() {
            return "org.openide.awt.ToolbarPool";
        }
    });
    ContainerOperator toolbarOper = mainWindowOper.getToolbar(0);
    int heightOrig = toolbarPool.getHeight();
    mainWindowOper.dragNDropToolbar(toolbarOper, 0, heightOrig);
    assertTrue("Toolbar not moved down - main window height the same.",
            heightOrig != toolbarPool.getHeight());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:MainWindowOperatorTest.java

示例6: showPopup

import java.awt.Component; //导入方法依赖的package包/类
public void showPopup(KeyEvent keyEvent) {
    if (isContextMenuOn()) {
        return;
    }
    Component component = keyEvent.getComponent();
    if (component instanceof JMenuItem && (!(component instanceof JMenu) || ((JMenu) component).isSelected())) {
        return;
    }
    Point point = new Point(component.getX() + component.getWidth() / 2, component.getY() + component.getHeight() / 2);
    showPopup(component, point);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:12,代码来源:ContextMenuHandler.java

示例7: moveComponents

import java.awt.Component; //导入方法依赖的package包/类
/**
 * Centers the elements in the specified row, if there is any slack.
 * @param target the component which needs to be moved
 * @param x the x coordinate
 * @param y the y coordinate
 * @param width the width dimensions
 * @param height the height dimensions
 * @param rowStart the beginning of the row
 * @param rowEnd the the ending of the row
 * @param ltr 
 * @param ruler 
 */
protected void moveComponents(Container target, int x, int y, int width,
		int height, int rowStart, int rowEnd, boolean ltr, Ruler ruler) {
	synchronized (target.getTreeLock()) {
		switch (getAlignment()) {
		case FlowLayout.LEFT:
			x += ltr ? 0 : width;
			break;
		case FlowLayout.CENTER:
			x += width / 2;
			break;
		case FlowLayout.RIGHT:
			x += ltr ? width : 0;
			break;
		case LEADING:
			break;
		case TRAILING:
			x += width;
			break;
		}
		int tabIndex = 0;
		for (int i = rowStart; i < rowEnd; i++) {
			Component m = target.getComponent(i);
			//          if (m.isVisible()) {
			if (hasConstraint(m, TAB_STOP))
				x = getInsets(target).left + ruler.getTab(tabIndex++);
			int dy = (valign == VTOP) ? 0 : (height - m.getHeight()) / 2;
			if (ltr) {
				m.setLocation(x, y + dy);
			} else {
				m.setLocation(target.getWidth() - x - m.getWidth(), y + dy);
			}
			x += m.getWidth() + hgap;
			//            }
		}
	}
}
 
开发者ID:CLARIN-PL,项目名称:WordnetLoom,代码行数:49,代码来源:RiverLayout.java

示例8: get

import java.awt.Component; //导入方法依赖的package包/类
/**
 * Retorna a image do container
 *
 * @param component objeto container
 * @return imagem do container
 */
public static ImageIcon get(Component component) {
    int width = component.getWidth();
    int height = component.getHeight();
    BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
    Graphics graphics = image.getGraphics();
    component.paintAll(graphics);
    graphics.dispose();
    return new ImageIcon(image);
}
 
开发者ID:limagiran,项目名称:hearthstone,代码行数:16,代码来源:Img.java

示例9: paintBorder

import java.awt.Component; //导入方法依赖的package包/类
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
    int h = c.getHeight();
    Color col = g.getColor();
    g.setColor (UIManager.getColor("controlShadow")); //NOI18N
    if (left) {
        g.drawLine (x + 3, y, x + 3, y + h - 1);
    }
    if (right) {
        g.drawLine (x + width - 3, y, x + width - 3, y + h - 1);
    }
    g.drawLine (x, y, x + width - 1, y);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:InsetBorder.java

示例10: readPositionFromComponent

import java.awt.Component; //导入方法依赖的package包/类
private void readPositionFromComponent(Component component) {
	isFullScreen = false;
	windowWidth = component.getWidth();
	windowHeight = component.getHeight();
	windowX = component.getX();
	windowY = component.getY();
}
 
开发者ID:KevinPriv,项目名称:Luyten4Forge,代码行数:8,代码来源:WindowPosition.java

示例11: drawMenuItemFading

import java.awt.Component; //导入方法依赖的package包/类
public static boolean drawMenuItemFading(Component c, Graphics g) {
	int w = c.getWidth();
	int h = c.getHeight();
	if (h < 0 || w < 0) {
		return true;
	}

	g.setColor(Colors.MENU_ITEM_BACKGROUND);
	g.fillRect(0, 0, c.getWidth(), c.getHeight());
	return true;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:12,代码来源:RapidLookTools.java

示例12: createBackBufferImage

import java.awt.Component; //导入方法依赖的package包/类
/**
 * Creates a VolatileImage that essentially wraps the target Component's
 * backbuffer, using the provided backbuffer handle.
 */
public VolatileImage createBackBufferImage(Component target,
                                           long backBuffer)
{
    return new SunVolatileImage(target,
                                target.getWidth(), target.getHeight(),
                                Long.valueOf(backBuffer));
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:12,代码来源:X11GraphicsConfig.java

示例13: createBackBufferImage

import java.awt.Component; //导入方法依赖的package包/类
/**
 * Creates a VolatileImage that essentially wraps the target Component's
 * backbuffer (the provided backbuffer handle is essentially ignored).
 */
@Override
public VolatileImage createBackBufferImage(Component target,
                                           long backBuffer)
{
    return new SunVolatileImage(target,
                                target.getWidth(), target.getHeight(),
                                Boolean.TRUE);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:GLXGraphicsConfig.java

示例14: getControlButtonsRectangle

import java.awt.Component; //导入方法依赖的package包/类
protected Rectangle getControlButtonsRectangle( Container parent ) {
    Component c = getControlButtons();
    return new Rectangle( parent.getWidth()-c.getWidth()-4, 2, c.getWidth(), c.getHeight() );
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:NimbusEditorTabDisplayerUI.java

示例15: doTest

import java.awt.Component; //导入方法依赖的package包/类
private void doTest() throws Exception {

        ArrayList<Component> components = new ArrayList();
        components.add(button);
        components.add(buttonLW);
        components.add(textField);
        components.add(textArea);
        components.add(list);
        components.add(listLW);

        String OS = System.getProperty("os.name").toLowerCase();
        System.out.println(OS);

        for (Component c : components) {

            String className = c.getClass().getName();
            System.out.println("component class : " + className);

            Point origin = c.getLocationOnScreen();
            int xc = origin.x + c.getWidth() / 2;
            int yc = origin.y + c.getHeight() / 2;
            Point center = new Point(xc, yc);

            robot.waitForIdle();
            robot.glide(origin, center);
            robot.click();
            robot.waitForIdle();

            // 1. shift + control
            runScenario(new int[]{KeyEvent.VK_SHIFT, KeyEvent.VK_CONTROL},
                    InputEvent.SHIFT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK);

            // 2. alt + shift + control
            runScenario(new int[]{KeyEvent.VK_ALT, KeyEvent.VK_SHIFT,
                KeyEvent.VK_CONTROL}, InputEvent.ALT_DOWN_MASK
                    | InputEvent.SHIFT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK);

            // 3. shift
            runScenario(new int[]{KeyEvent.VK_SHIFT},
                    InputEvent.SHIFT_DOWN_MASK);

            // 4. alt + control
            runScenario(new int[]{KeyEvent.VK_ALT, KeyEvent.VK_CONTROL},
                    InputEvent.ALT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK);

            // 5. shift + alt
            runScenario(new int[]{KeyEvent.VK_SHIFT, KeyEvent.VK_ALT},
                    InputEvent.SHIFT_DOWN_MASK | InputEvent.ALT_DOWN_MASK);

            if (OS.contains("os x") || OS.contains("sunos")) {
                // 6. meta
                runScenario(new int[]{KeyEvent.VK_META},
                        InputEvent.META_DOWN_MASK);

                // 7. shift + ctrl + alt + meta
                runScenario(new int[]{KeyEvent.VK_SHIFT, KeyEvent.VK_CONTROL,
                    KeyEvent.VK_ALT, KeyEvent.VK_META},
                        InputEvent.SHIFT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK
                        | InputEvent.ALT_DOWN_MASK | InputEvent.META_DOWN_MASK);

                // 8. meta + shift + ctrl
                runScenario(new int[]{KeyEvent.VK_META, KeyEvent.VK_SHIFT,
                    KeyEvent.VK_CONTROL}, InputEvent.META_DOWN_MASK
                      | InputEvent.SHIFT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK);

                // 9. meta + shift + alt
                runScenario(new int[]{KeyEvent.VK_META, KeyEvent.VK_SHIFT,
                    KeyEvent.VK_ALT}, InputEvent.META_DOWN_MASK
                      | InputEvent.SHIFT_DOWN_MASK | InputEvent.ALT_DOWN_MASK);

                // 10. meta + ctrl + alt
                runScenario(new int[]{KeyEvent.VK_META, KeyEvent.VK_CONTROL,
                    KeyEvent.VK_ALT}, InputEvent.META_DOWN_MASK
                      | InputEvent.CTRL_DOWN_MASK | InputEvent.ALT_DOWN_MASK);
            }
        }

        robot.waitForIdle();
        frame.dispose();
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:81,代码来源:ExtendedModifiersTest.java


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