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


Java Component.validate方法代码示例

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


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

示例1: addImpl

import java.awt.Component; //导入方法依赖的package包/类
protected void addImpl(Component comp, Object constraints, int index) {
    int layer;
    int pos;

    if(constraints instanceof Integer) {
        layer = ((Integer)constraints).intValue();
        setLayer(comp, layer);
    } else
        layer = getLayer(comp);

    pos = insertIndexForLayer(layer, index);
    super.addImpl(comp, constraints, pos);
    comp.validate();
    comp.repaint();
    validateOptimizedDrawing();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:JLayeredPane.java

示例2: paintComponent

import java.awt.Component; //导入方法依赖的package包/类
/**
 * Paints the current state (i.e. the state corresponding to the current
 * phase) of the given component.
 *
 * @param g graphics context.
 * @param comp component to paint.
 */
private void paintComponent(Graphics g, Component comp) {
    Rectangle bounds = currentBounds(comp);
    float alpha = currentAlpha(comp);
    Graphics gg = g.create(bounds.x, bounds.y, bounds.width, bounds.height);
    if (alpha != 1f) {
        AlphaComposite alphaComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha);
        ((Graphics2D)gg).setComposite(alphaComposite);
    }
    comp.setBounds(bounds);
    comp.validate();
    // Intentionally using print instead of paint.
    // Print doesn't use double buffering and it solves some mysterious
    // problems with modified clip during painting of containers.
    // BTW: animated transitions library also uses print()
    if (comp instanceof JComponent) {
        comp.print(gg);
    } else {
        java.awt.peer.ComponentPeer peer = FakePeerSupport.getPeer(comp);
        if (peer != null) {
            peer.paint(gg);
        }
    }
    gg.dispose();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:AnimationLayer.java

示例3: addPanel

import java.awt.Component; //导入方法依赖的package包/类
void addPanel(JPanel panel) {
    RefactoringPanel.checkEventThread();
    if (getComponentCount() == 0) {
        add(panel, BorderLayout.CENTER);
    } else {
        Component comp = getComponent(0);
        if (comp instanceof JTabbedPane) {
            ((JTabbedPane) comp).addTab(panel.getName(), null, panel, panel.getToolTipText());
            ((JTabbedPane) comp).setSelectedComponent(panel);
            comp.validate();
        } else if (comp instanceof JLabel) {
            remove(comp);
            add(panel, BorderLayout.CENTER);
        } else {
            remove(comp);
            JTabbedPane pane = TabbedPaneFactory.createCloseButtonTabbedPane();
            pane.addMouseListener(listener);
            pane.addPropertyChangeListener(closeL);
            add(pane, BorderLayout.CENTER);
            pane.addTab(comp.getName(), null, comp, ((JPanel) comp).getToolTipText());
            pane.addTab(panel.getName(), null, panel, panel.getToolTipText());
            pane.setSelectedComponent(panel);
            pane.validate();
        }
    }
    if (!isVisible) {
        isVisible = true;
        open();
    }
    validate();
    requestActive();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:RefactoringPanelContainer.java

示例4: setValue

import java.awt.Component; //导入方法依赖的package包/类
/**
 * Called whenever any of the controls on the panel gets an event
 */
private void setValue(String errorMsg) {

    boolean sizeChanged;
    boolean styleChanged;

    int oldSize = size;
    size = 12;
    try {
        size = Integer.parseInt(tfSize.getText());
        if (size <= 0) {
            IllegalArgumentException iae = new IllegalArgumentException();
            /* LATER
            UIExceptions.annotateUser (iae, null,
            size == 0 ? "CTL_InvalidValueWithParam", tfSize.getText () : // NOI18N
            "CTL_NegativeSize", // NOI18N
            null, null);
            tfSize.setText (String.valueOf (font.getSize ()));
             */
            throw iae;
        }
        updateSizeList(size);
    } catch (NumberFormatException e) {
        /* LATER
        UIExceptions.annotateUser (e, null,
        "CTL_InvalidValueWithExc", // NOI18N
        null, null);
        tfSize.setText (String.valueOf (font.getSize ()));
         */
        throw e;
    }
    sizeChanged = size != oldSize;

    int oldStyle = style;
    int i = lStyle.getSelectedIndex();
    style = Font.PLAIN;
    switch (i) {
        case 0:
            style = Font.PLAIN;
            break;
        case 1:
            style = Font.BOLD;
            break;
        case 2:
            style = Font.ITALIC;
            break;
        case 3:
            style = Font.BOLD | Font.ITALIC;
            break;
    }
    styleChanged = style != oldStyle;


    fontFamily = tfFont.getText();
    if (sizeChanged || styleChanged) {
        this.errorMsg = errorMsg;
        updateFontList();
    } else {
        this.errorMsg = errorMsg;
    }
    // TMP FontEditor.this.setValue (new Font (tfFont.getText (), ii, size));
    font = new Font(fontFamily, style, size);
    invalidate();
    Component p = getParent();
    if (p != null) {
        p.validate();
    }
    repaint();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:72,代码来源:FontPanel.java


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