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


Java JWindow.setVisible方法代码示例

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


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

示例1: testSetNodesSurvivesMultipleAdd_RemoveNotifyCalls

import javax.swing.JWindow; //导入方法依赖的package包/类
public void testSetNodesSurvivesMultipleAdd_RemoveNotifyCalls() throws Exception {
    final PropertySheet ps = new PropertySheet();
    Node n = new AbstractNode( Children.LEAF );
    JWindow window = new JWindow();
    ps.setNodes( new Node[] {n} );
    window.add( ps );
    window.remove( ps );
    window.add( ps );
    window.remove( ps );
    window.add( ps );
    window.remove( ps );
    window.setVisible(true);
    assertNotNull(ps.helperNodes);
    assertEquals("Helper nodes are still available even after several addNotify()/removeNotify() calls",
            ps.helperNodes[0], n);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:MorePropertySheetTest.java

示例2: show

import javax.swing.JWindow; //导入方法依赖的package包/类
public void show(Point location) {
    Rectangle screenBounds = null;
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    for (GraphicsDevice device : gds) {
        GraphicsConfiguration gc = device.getDefaultConfiguration();
        screenBounds = gc.getBounds();
        if (screenBounds.contains(location)) {
            break;
        }
    }

    // showing the popup tooltip
    cp = new TooltipContentPanel(master.getTextComponent());

    Window w = SwingUtilities.windowForComponent(master.getTextComponent());
    contentWindow = new JWindow(w);
    contentWindow.add(cp);
    contentWindow.pack();
    Dimension dim = contentWindow.getSize();

    if (location.y + dim.height + SCREEN_BORDER > screenBounds.y + screenBounds.height) {
        dim.height = (screenBounds.y + screenBounds.height) - (location.y + SCREEN_BORDER);
    }
    if (location.x + dim.width + SCREEN_BORDER > screenBounds.x + screenBounds.width) {
        dim.width = (screenBounds.x + screenBounds.width) - (location.x + SCREEN_BORDER);
    }

    contentWindow.setSize(dim);

    contentWindow.setLocation(location.x, location.y - 1);  // slight visual adjustment
    contentWindow.setVisible(true);

    Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.KEY_EVENT_MASK);
    w.addWindowFocusListener(this);
    contentWindow.addWindowFocusListener(this);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:TooltipWindow.java

示例3: show

import javax.swing.JWindow; //导入方法依赖的package包/类
public void show(Point location) {
    Rectangle screenBounds = null;
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    for (GraphicsDevice device : gds) {
        GraphicsConfiguration gc = device.getDefaultConfiguration();
        screenBounds = gc.getBounds();
        if (screenBounds.contains(location)) {
            break;
        }
    }

    // showing the popup tooltip
    cp = new TooltipContentPanel(master.getTextComponent());
    Window w = SwingUtilities.windowForComponent(master.getTextComponent());
    contentWindow = new JWindow(w);
    contentWindow.add(cp);
    contentWindow.pack();
    Dimension dim = contentWindow.getSize();

    if (location.y + dim.height + SCREEN_BORDER > screenBounds.y + screenBounds.height) {
        dim.height = (screenBounds.y + screenBounds.height) - (location.y + SCREEN_BORDER);
    }
    if (location.x + dim.width + SCREEN_BORDER > screenBounds.x + screenBounds.width) {
        dim.width = (screenBounds.x + screenBounds.width) - (location.x + SCREEN_BORDER);
    }

    contentWindow.setSize(dim);

    contentWindow.setLocation(location.x, location.y - 1);  // slight visual adjustment
    contentWindow.setVisible(true);
    Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.KEY_EVENT_MASK);
    w.addWindowFocusListener(this);
    contentWindow.addWindowFocusListener(this);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:TooltipWindow.java

示例4: show

import javax.swing.JWindow; //导入方法依赖的package包/类
public static JWindow show( Frame parent ) {
    final JWindow window = new KSUCreditsWindow( parent );
    SwingUtils.centerInParent( window );
    window.setVisible( true );

    /*
    *  Dispose of ksuCreditsWindow after N seconds.
    *  Take care to call dispose in the Swing thread.
    */
    Timer timer = new Timer( 4000, new ActionListener() {
        public void actionPerformed( ActionEvent e ) {
            if ( window.isDisplayable() ) {
                window.dispose();
            }
        }
    } );
    timer.setRepeats( false );
    timer.start();

    return window;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:22,代码来源:KSUCreditsWindow.java

示例5: init

import javax.swing.JWindow; //导入方法依赖的package包/类
public static void init( Window applicationWindow ) {


        if ( inited ) {
            throw new RuntimeException( "Multiple inits." );
        }

//        System.out.println( "Setting repaintManagerPhet." );
        RepaintManager.setCurrentManager( repaintManagerPhet );

        offscreen = new JWindow( applicationWindow ) {
            public void invalidate() {
            }

            public void paint( Graphics g ) {
            }
        };       //this seems to work.  I thought you might have needed a visible component, though (maybe for some JVM implementations?)
//        System.out.println( "offscreen.getOwner() = " + offscreen.getOwner() );

//        offscreen.getOwner().setVisible( true );
        offscreen.setSize( 0, 0 );
        offscreen.setVisible( true );
        offscreenContentPane.setOpaque( false );
        offscreen.setContentPane( offscreenContentPane );
        inited = true;
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:27,代码来源:PhetJComponent.java

示例6: nextWindow

import javax.swing.JWindow; //导入方法依赖的package包/类
/**
 * shows the next window on the stack
 */
private static void nextWindow() {
	try {
		sLock.lock();
		if(!sWindowOpen && sWindows.size() > 0) {
			sWindowOpen = true;
			final JWindow window = sWindows.removeFirst();
			Timer delayVisibleTimer = new Timer(DELAY, new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					final Timer t = (Timer) e.getSource();
					t.stop();
					window.setVisible(true);
					window.getGlassPane().setVisible(true);

				}
			});
			delayVisibleTimer.start();
		}
	} finally {
		sLock.unlock();
	}
}
 
开发者ID:cowthan,项目名称:JavaAyo,代码行数:25,代码来源:SequentialNotificationManager.java

示例7: createJWindow

import javax.swing.JWindow; //导入方法依赖的package包/类
/**
 * 创建JWindow,该Window用于作为Jfx组件的容器,这个window始终覆盖在frame上。
 * @param ms
 * @param mainFrame
 * @param jfxRoot
 * @return 
 */
private static JWindow createJWindow(JFrame parent, final Pane jfxRoot) {
    JWindow jwin = new JWindow(parent);
    jwin.setLocationRelativeTo(null);
    jwin.setVisible(true);
    
    jfxPanel = new JFXPanel();
    jwin.getContentPane().add(jfxPanel);

    Platform.runLater(() -> {
        // 设置JFX主场景,并让JFX主界面变得透明,这样不会覆盖整个Canvas.
        jfxRoot.setBackground(Background.EMPTY);
        jfxPanel.setScene(new Scene(jfxRoot, Color.TRANSPARENT));
    });
    return jwin;
}
 
开发者ID:huliqing,项目名称:LuoYing,代码行数:23,代码来源:Jfx.java

示例8: showSplash

import javax.swing.JWindow; //导入方法依赖的package包/类
public static void showSplash() {
	screen = new JWindow();
	final URL resource = MainFrame.class.getResource("mpcmaidlogo400_400.png");
	final JLabel label = new JLabel(new ImageIcon(resource));
	screen.getContentPane().add(label);
	screen.setLocationRelativeTo(null);
	Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
	Dimension labelSize = screen.getPreferredSize();
	screen
			.setLocation(screenSize.width / 2 - (labelSize.width / 2), screenSize.height / 2
					- (labelSize.height / 2));
	screen.pack();
	screen.setVisible(true);
	label.repaint();
	screen.repaint();
}
 
开发者ID:cyriux,项目名称:mpcmaid,代码行数:17,代码来源:MPCMaid.java

示例9: showSplashScreen

import javax.swing.JWindow; //导入方法依赖的package包/类
/** Construct a splash screen. */
public void showSplashScreen() {
	// create window, apply image
	JWindow window = new JWindow();
	ImageIcon icon = new ImageIcon("img/SQLizard.jpg");
	JLabel label = new JLabel(icon);

	window.add(label);

	Toolkit tk = Toolkit.getDefaultToolkit();
	int width = ((int) tk.getScreenSize().getWidth());
	int height = ((int) tk.getScreenSize().getHeight());

	window.setBounds((width / 2) - 440, (height / 2) - 245, 880, 495);
	window.setVisible(true);

	// provide splash screen loading effect
	try {
		Thread.sleep(2000);
	} catch (InterruptedException e) {
		e.printStackTrace();
	}

	window.setVisible(false);
}
 
开发者ID:rsanchez-wsu,项目名称:sp16-ceg3120,代码行数:26,代码来源:SplashScreen.java

示例10: SwingSplashScreen

import javax.swing.JWindow; //导入方法依赖的package包/类
SwingSplashScreen(BufferedImage image, int width, int height) {
        window = new JWindow((Window) null);
        window.setBackground(new Color(0, 0, 0, 0));
        window.setSize(width, height);
        window.setLocationRelativeTo(null);

        // alwaysOnTop keeps the LWJGL2 Display window from popping up and it can't be triggered manually
//        window.setAlwaysOnTop(true);

        window.add(new Component() {

            private static final long serialVersionUID = 1717818903226627606L;

            @Override
            public void paint(Graphics g) {
                if (image != null) {
                    g.drawImage(image, 0, 0, width, height, null);
                }
                for (Overlay overlay : getOverlays()) {
                    overlay.render((Graphics2D) g);
                }
            }
        });

        window.setVisible(true);
    }
 
开发者ID:MovingBlocks,项目名称:SplashScreen,代码行数:27,代码来源:SwingSplashScreen.java

示例11: splashInit

import javax.swing.JWindow; //导入方法依赖的package包/类
public static void splashInit() {
    JWindow window = new JWindow();
    java.net.URL imgURL = SplashScreen.class.getResource("resources/images/SplashScreen.png");
    window.getContentPane().add(
            new JLabel("", new ImageIcon(imgURL), SwingConstants.CENTER));
    window.setBounds(500, 150, 300, 200);
    window.setSize(500, 400);
    
    java.awt.Dimension dim = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); 
    window.setLocation(dim.width/2-window.getSize().width/2, dim.height/2-window.getSize().height/2);
    
    setupAudio();
    window.setVisible(true);

    try {
        Thread.sleep(5000);
    } catch (InterruptedException e) {
        System.out.println("Caught InterrupedException");
    }
    
    window.setVisible(false);
    window.dispose();
}
 
开发者ID:Chenkers,项目名称:LVPDTool,代码行数:24,代码来源:SplashScreen.java

示例12: show

import javax.swing.JWindow; //导入方法依赖的package包/类
void show(Point location) {
    Rectangle screenBounds = null;
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    for (GraphicsDevice device : gds) {
        GraphicsConfiguration gc = device.getDefaultConfiguration();
        screenBounds = gc.getBounds();
        if (screenBounds.contains(location)) {
            break;
        }
    }

    // showing the popup tooltip
    cp = new TooltipContentPanel();
    Window w = SwingUtilities.windowForComponent(parent);
    contentWindow = new JWindow(w);
    contentWindow.add(cp);
    contentWindow.pack();
    Dimension dim = contentWindow.getSize();

    if (screenBounds.width + screenBounds.x - location.x < cp.longestLine) {
        // the whole window does fully not fit to the right
        // the x position where the window has to start to fully fit to the right
        int left = screenBounds.width + screenBounds.x - cp.longestLine;
        // the window should have x pos minimally at the screen's start
        location.x = Math.max(screenBounds.x, left);
    }
    
    if (location.y + dim.height + SCREEN_BORDER > screenBounds.y + screenBounds.height) {
        dim.height = (screenBounds.y + screenBounds.height) - (location.y + SCREEN_BORDER);
    }
    if (location.x + dim.width + SCREEN_BORDER > screenBounds.x + screenBounds.width) {
        dim.width = (screenBounds.x + screenBounds.width) - (location.x + SCREEN_BORDER);
    }

    contentWindow.setSize(dim);

    contentWindow.setLocation(location.x, location.y + 1);  // slight visual adjustment
    
    contentWindow.setVisible(true);
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            cp.scrollRectToVisible(new Rectangle(1, 1));
        }
    });
    Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.KEY_EVENT_MASK);
    w.addWindowFocusListener(this);
    contentWindow.addWindowFocusListener(this);
    contentWindow.addKeyListener(this);
    w.addKeyListener(this);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:53,代码来源:MsgTooltipWindow.java

示例13: setUp

import javax.swing.JWindow; //导入方法依赖的package包/类
protected void setUp() throws Exception {
    split = new MultiSplitPane();
    split.setDividerSize( DIVIDER_SIZE );
    
    testWindow = new JWindow();
    testWindow.setVisible( true );
    //testWindow.getContentPane().add( split );
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:MultiSplitPaneTest.java

示例14: start

import javax.swing.JWindow; //导入方法依赖的package包/类
/** Start the bot. */
public void start() {
    Toolkit tk = Toolkit.getDefaultToolkit();
    int xSize = ((int) tk.getScreenSize().getWidth());
    int ySize = ((int) tk.getScreenSize().getHeight());
    window = new JWindow();
    window.setSize(xSize, ySize);
    window.setOpacity(0.0f);
    window.setVisible(true);
    window.setAlwaysOnTop(true);
    window.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (clicks < _numberOfLocations) {
                location[clicks] = getLocation();
                window.setVisible(false);
                sleep();
                click();
                sleep();
                window.setVisible(true);
                sleep();
                clicks += 1;
            }
            if (clicks == _numberOfLocations) {
                window.setVisible(false);
                process();
            }
        }
    });
}
 
开发者ID:jenyeu,项目名称:clickbot,代码行数:31,代码来源:Bot.java

示例15: main

import javax.swing.JWindow; //导入方法依赖的package包/类
public static void main(String[] args) {
    Robot r = Util.createRobot();
    JWindow w = new JWindow();
    w.setSize(100, 100);
    w.setVisible(true);
    Util.waitForIdle(r);

    final JPopupMenu menu = new JPopupMenu();
    JButton item = new JButton("A button in popup");

    menu.add(item);

    w.addMouseListener(new MouseAdapter() {
            public void mousePressed(MouseEvent me) {
            menu.show(me.getComponent(), me.getX(), me.getY());

            System.out.println("Showing menu at " + menu.getLocationOnScreen() +
                               " isVisible: " + menu.isVisible() +
                               " isValid: " + menu.isValid());
            }
        });

    Util.clickOnComp(w, r);
    Util.waitForIdle(r);

    if (!menu.isVisible()) {
        throw new RuntimeException("menu was not shown");
    }

    menu.hide();
    System.out.println("Test passed.");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:33,代码来源:GrabOnUnfocusableToplevel.java


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