Java Code Examples for javax.swing.JComponent#paintImmediately()

The following examples show how to use javax.swing.JComponent#paintImmediately() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: marathonv5   File: TransparentFrame.java    License: Apache License 2.0 5 votes vote down vote up
protected void paintTransparentFrame() {
    Dimension size = component.getComponent().getSize();
    if (component.getComponent() instanceof JComponent) {
        JComponent jc = (JComponent) component.getComponent();
        jc.paintImmediately(0, 0, size.width, size.height);
    }
    if (disposed) {
        return;
    }
    size = component.getSize();
    Point location = component.getLocation();
    graphics.setColor(BG);
    graphics.fillRect(0 + location.x, 0 + location.y, size.width, size.height);
    String name = component.getRComponentName();
    graphics.setColor(Color.WHITE);
    Font font = new Font(graphics.getFont().getName(), Font.ITALIC | Font.BOLD, 12);
    FontMetrics metrics = graphics.getFontMetrics(font);
    int stringWidth = metrics.stringWidth(name);
    int stringHeight = metrics.getHeight() / 2;
    if (stringWidth < size.width && stringHeight < size.height) {
        graphics.setFont(font);
        graphics.drawString(name, (size.width - stringWidth) / 2 + location.x, (size.height + stringHeight) / 2 + location.y);
    } else if (stringWidth >= size.width || stringHeight >= size.height) {
        graphics.setFont(new Font(graphics.getFont().getName(), Font.ITALIC, 9));
        graphics.drawString(name, 0 + location.x, (size.height + stringHeight) / 2 + location.y);
    } else {
        logger.warning("Not drawing");
    }
}
 
Example 2
Source Project: ApkToolPlus   File: BrowserMDIFrame.java    License: Apache License 2.0 5 votes vote down vote up
private void repaintNow() {

		JComponent contentPane = (JComponent) getContentPane();
		contentPane.paintImmediately(0, 0, contentPane.getWidth(), contentPane
				.getHeight());
		JMenuBar menuBar = getJMenuBar();
		menuBar.paintImmediately(0, 0, menuBar.getWidth(), menuBar.getHeight());
	}
 
Example 3
Source Project: FancyBing   File: GuiUtil.java    License: GNU General Public License v3.0 4 votes vote down vote up
public static void paintImmediately(JComponent component)
{
    component.paintImmediately(component.getVisibleRect());
}