當前位置: 首頁>>代碼示例>>Java>>正文


Java JWindow.getSize方法代碼示例

本文整理匯總了Java中javax.swing.JWindow.getSize方法的典型用法代碼示例。如果您正苦於以下問題:Java JWindow.getSize方法的具體用法?Java JWindow.getSize怎麽用?Java JWindow.getSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.JWindow的用法示例。


在下文中一共展示了JWindow.getSize方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例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,代碼行數:36,代碼來源:TooltipWindow.java

示例3: 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

示例4: setContents

import javax.swing.JWindow; //導入方法依賴的package包/類
public void setContents() {
    visible = true;
    JWindow tempWindow = new JWindow();
    tempWindow.getContentPane().add(contents);
    tempWindow.pack();
    tempWindowSize = tempWindow.getSize();
    tempWindow.getContentPane().removeAll();
    animatingSheet.setSource(contents);
    container.removeAll();
    container.add(animatingSheet);
}
 
開發者ID:mars-sim,項目名稱:mars-sim,代碼行數:12,代碼來源:SlideAnimator.java

示例5: run

import javax.swing.JWindow; //導入方法依賴的package包/類
public void run()
{
    splash = new JWindow();
    JPanel content = new JPanel();
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    URL url=ClassLoader.getSystemResource("Data/splash.jpg");
    JLabel label = new JLabel(new ImageIcon(url));
    content.add(label,BorderLayout.CENTER);
    content.setBorder(BorderFactory.createLineBorder(Color.black, 1));
    splash.add(content);
    splash.pack();
    Dimension s=splash.getSize();
    int x = (screen.width-s.width)/2;
    int y = (screen.height-s.height)/2;
    splash.setBounds(x,y,s.width,s.height);
    AWTUtilities.setWindowOpacity(splash,Float.valueOf(0));
    ii=0;
    splash.setVisible(true);
    alphaChanger = new Timer(60,new ActionListener() {
        private float incrementer = .1f;
        @Override 
        public void actionPerformed(ActionEvent e)
        {
           ii=ii+incrementer;
           if(ii>((float)0.9))
           {   
               alphaChanger.stop();
               AWTUtilities.setWindowOpacity(splash,Float.valueOf(1));
               try{
                   Thread.sleep(1500);
                }catch(InterruptedException ex){}
                splash.setVisible(false);
            }
           AWTUtilities.setWindowOpacity(splash,Float.valueOf(ii));
        }
    });
    alphaChanger.start();
}
 
開發者ID:ayushmaanbhav,項目名稱:iitpwebapp,代碼行數:39,代碼來源:Splash.java


注:本文中的javax.swing.JWindow.getSize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。