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


Java JWindow.pack方法代码示例

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


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

import javax.swing.JWindow; //导入方法依赖的package包/类
/**
 * Constructor.
 * 
 * @param parent
 * @param isApplet
 */
public SplashScreen(JFrame parent, boolean isApplet) {
    this.isApplet = isApplet;

    splashLabel = new JLabel(IconsRegistry.getImageIcon("splash.gif"));

    if (!isApplet) {
        splashScreen = new JWindow(parent);
        splashScreen.getContentPane().add(splashLabel);
        splashScreen.pack();
        Rectangle screenRect = parent.getGraphicsConfiguration()
                .getBounds();
        splashScreen
                .setLocation(screenRect.x + screenRect.width / 2
                        - splashScreen.getSize().width / 2, screenRect.y
                        + screenRect.height / 2
                        - splashScreen.getSize().height / 2);
    }
}
 
开发者ID:dvorka,项目名称:mindraider,代码行数:25,代码来源:SplashScreen.java

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

示例5: init

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

  setLayout(new BorderLayout());

  // create javafx panel
  final JFXPanel javafxPanel = new JFXPanel();
  javafxPanel.setFocusable(false);
  javafxPanel.setOpaque(false);

  add(javafxPanel, BorderLayout.CENTER);

  JWindow fxKeyboard = new JWindow();
  fxKeyboard.setModalExclusionType(java.awt.Dialog.ModalExclusionType.APPLICATION_EXCLUDE);
  fxKeyboard.getContentPane().add(javafxPanel);
  fxKeyboard.setFocusable(false);
  fxKeyboard.setBackground(null);

  fxKeyboard.pack();
  fxKeyboard.setLocationByPlatform(true);

  // create JavaFX scene
  Platform.runLater(() -> createScene(javafxPanel));

}
 
开发者ID:comtel2000,项目名称:fx-experience,代码行数:26,代码来源:StandAloneApp.java

示例6: prepareResources

import javax.swing.JWindow; //导入方法依赖的package包/类
@Override
protected void prepareResources() {
    window = new JWindow(SwingUtilities.getWindowAncestor(owner));
    window.setType(JWindow.Type.POPUP);
    window.getContentPane().add (contents);
    window.setLocation (new Point (x, y));
    window.pack();
    disableShadow(window);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:CustomPopupFactory.java

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

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

示例9: add

import javax.swing.JWindow; //导入方法依赖的package包/类
private static void add(String[] mmeldung, boolean fehler) {
    if (Boolean.parseBoolean(MVConfig.get(MVConfig.Configs.SYSTEM_NOTIFICATION))) {
        String meldung = "<html><head></head><body><p>";
        for (String s : mmeldung) {
            meldung += s + "<br />";
        }
        meldung += "</p></body></html>";

        final JWindow messageFrame = new JWindow();
        messageFrame.setLayout(new BorderLayout());
        final JPanel panel = new JPanel();
        panel.setBackground(Color.BLACK);

        messageFrame.setContentPane(panel);

        final JLabel iconLabel = new JLabel(fehler ? Icons.ICON_NOTIFICATION : Icons.ICON_NOTIFICATION_ERROR);
        iconLabel.setVerticalAlignment(SwingConstants.TOP);
        messageFrame.getContentPane().add(iconLabel, BorderLayout.WEST);
        final JLabel meldungsLabel = new JLabel(meldung);
        meldungsLabel.setForeground(Color.WHITE);

        messageFrame.getContentPane().add(meldungsLabel, BorderLayout.CENTER);
        messageFrame.pack();
        messageFrame.setFocusableWindowState(false);

        Notification notification = new Notification(messageFrame, WindowPosition.BOTTOMRIGHT, 20, 20, 6000);
        NotificationQueue q = new NotificationQueue();
        q.add(notification);

    }
}
 
开发者ID:mediathekview,项目名称:MediathekView,代码行数:32,代码来源:MVNotification.java

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

示例11: init

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

		String fontUrl = this.getClass().getResource("/font/FontKeyboardFX.ttf").toExternalForm();
		Font.loadFont(fontUrl, -1);

		setLayout(new BorderLayout());

		// create javafx panel
		final JFXPanel javafxPanel = new JFXPanel();
		javafxPanel.setFocusable(false);
		javafxPanel.setOpaque(false);

		add(javafxPanel, BorderLayout.CENTER);

		JWindow fxKeyboard = new JWindow();
		fxKeyboard.setModalExclusionType(java.awt.Dialog.ModalExclusionType.APPLICATION_EXCLUDE);
		fxKeyboard.getContentPane().add(javafxPanel);
		fxKeyboard.setFocusable(false);
		fxKeyboard.setBackground(null);

		fxKeyboard.pack();
		fxKeyboard.setLocationByPlatform(true);

		// create JavaFX scene
		Platform.runLater(new Runnable() {
			public void run() {
				createScene(javafxPanel);
			}
		});

	}
 
开发者ID:jointry,项目名称:jointry,代码行数:32,代码来源:AwtStandAloneApp.java

示例12: show

import javax.swing.JWindow; //导入方法依赖的package包/类
public void show() {
//        Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
//        if (focusOwner != null) focusRef = new WeakReference(focusOwner);
            
        owner = ownerRef == null ? null : ownerRef.get();
        ownerLocation = owner == null ? null : owner.getLocationOnScreen();
        
        window = new JWindow(owner);
        window.setType(Window.Type.POPUP);
        window.setAlwaysOnTop(false);
        window.setFocusable(true);
        window.setFocusableWindowState(true);
        window.setAutoRequestFocus(true);
        
        window.getContentPane().add(content);
        window.pack();
        
        if (popupAlign == -1) {
            window.setLocation(location.getLocation());
        } else {
            Dimension size = content.getSize();
            
            int x;
            switch (popupAlign) {
                case SwingConstants.EAST:
                case SwingConstants.NORTH_EAST:
                case SwingConstants.SOUTH_EAST:
                    x = location.x + location.width - size.width + 1;
                    break;
                default:
                    x = location.x + 1;
                    break;
            }
            
            int y;
            switch (popupAlign) {
                case SwingConstants.NORTH:
                case SwingConstants.NORTH_EAST:
                case SwingConstants.NORTH_WEST:
                    y = location.y - size.height + 1;
                    break;
                default:
                    y = location.y + location.height + 1;
                    break;
            }
            
            window.setLocation(x, y);
        }
        
        window.setVisible(true);
        
        Component defaultFocus = content.getFocusTraversalPolicy().getDefaultComponent(content);
        if (defaultFocus != null) defaultFocus.requestFocusInWindow();
        
        content.installListeners();
        
        if (listener != null) listener.popupShown();
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:59,代码来源:ProfilerPopup.java

示例13: Main

import javax.swing.JWindow; //导入方法依赖的package包/类
public Main(File []files, Dimension size) {
    setBackground(Color.black);
    this.files = files;
    UserAgentAdapter ua = new UserAgentAdapter();
    renderer  = new StaticRenderer();
    userAgent = ua;
    loader    = new DocumentLoader(userAgent);
    ctx       = new BridgeContext(userAgent, loader);
    ua.setBridgeContext(ctx);

    if (size == null) {
        size = Toolkit.getDefaultToolkit().getScreenSize();
    }

    setPreferredSize(size);
    setDoubleBuffered(false);
    addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent me) {
                if (done)
                    System.exit(0);
                else
                    togglePause();
            }
        });

    size.width += 2;
    size.height += 2;
    display = new BufferedImage(size.width, size.height,
                                BufferedImage.TYPE_INT_BGR);

    Thread t = new RenderThread();
    t.start();

    JWindow w = new JWindow();
    w.setBackground(Color.black);
    w.getContentPane().setBackground(Color.black);
    w.getContentPane().add(this);
    w.pack();
    w.setLocation(new Point(-1, -1));
    w.setVisible(true);
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:42,代码来源:Main.java

示例14: createAndShowLoading

import javax.swing.JWindow; //导入方法依赖的package包/类
private static void createAndShowLoading(){
    // create loading welcome
    JWindow loading = new JWindow();
    loading.setAlwaysOnTop(true);
    
    // set backgroud
    loading.setBackground(new Color(0, 0, 0, 0));
    
    // set transparent content
    loading.setContentPane(new JPanel(){        
        @Override
        public void setOpaque(boolean isOpaque) {
            super.setOpaque(false); 
        }
        @Override
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            // get g2
            Graphics2D g2 = (Graphics2D)g.create();
            g2.setComposite(AlphaComposite.SrcOver.derive(0.0f));
            g2.setColor(getBackground());
            g2.fillRect(0, 0, getWidth(), getHeight());
        }          
    });
    
    JLabel mainLabel = null;
    // add the icon
    java.net.URL imgURL = WirelessLCDSystem.class.getResource("resource/welcome.png");
    if(null != imgURL){
        mainLabel = new JLabel(new ImageIcon(imgURL));
        loading.add(mainLabel);
    }
    
    // set the property location
    loading.setLocationRelativeTo(null);
    int x = loading.getLocation().x;
    int y = loading.getLocation().y;
    loading.setLocation(x-400, y-250);
    
    // pack and show
    loading.pack();
    // show 
    loading.setVisible(true);
    // use a thread to update the logo
    (new WelcomeLogo(loading, mainLabel)).execute();
}
 
开发者ID:smileboywtu,项目名称:EmbeddedMonitor,代码行数:47,代码来源:WirelessLCDSystem.java

示例15: createPanchangInputWindow

import javax.swing.JWindow; //导入方法依赖的package包/类
private Window createPanchangInputWindow(){
	
	JWindow window = new JWindow(this);
	
	Container windowPane = window.getContentPane(  );
	
	windowPane.setLayout(new BorderLayout());
	
	spinner = new CalendarSpinner(CalendarSpinner.FMT_MONTH_YEAR);
	
	spinner.addDateListener( new DateListener () {

		public void dateChanged(Date date) {
			
			outputFileChooser.setFilePath(getPanchangOutputFile(date));
		}
		
	});
	
	JPanel panChooser = spinner.getChooser();
	JPanel p = new JPanel();
	
	p.add(panChooser);
	p.add(fullYear);
	
	p.setBackground(UIConsts.CAL_COMBO_BACKGROUND);
	p.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
	
	windowPane.add(p, BorderLayout.CENTER);
	
	window.pack();
	
	fullYear.addActionListener(new ActionListener(){

		public void actionPerformed(ActionEvent e) {
			outputFileChooser.setFilePath(getPanchangOutputFile(spinner.getSelectedDate()));
		}
	});
	return window;
}
 
开发者ID:erajasekar,项目名称:Astrosoft,代码行数:41,代码来源:PrintDialog.java


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