本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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();
}
}
示例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;
}
示例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();
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
示例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 );
}
示例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();
}
}
});
}
示例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.");
}