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


Java JWindow.setLocationRelativeTo方法代碼示例

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


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

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

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

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

示例4: LoadingScreen

import javax.swing.JWindow; //導入方法依賴的package包/類
public LoadingScreen(int nbSteps, int minTime){
	this.minTime = minTime;
	this.nombreEtapes = nbSteps;
	etapeActuelle = 0;
	
	frmPrincipale = new JWindow();
	frmPrincipale.setSize(400, 260);
	
	JPanel pnlChargement = new JPanel(new BorderLayout());
	
	pgbChargement = new JProgressBar();
	pgbChargement.setValue(0);
	
	jtMessage = new JLabel();
	jtMessage.setHorizontalAlignment(SwingConstants.CENTER);
	
	SplashImage image = new SplashImage();
	
	frmPrincipale.add(image);
	
	pnlChargement.add(jtMessage,BorderLayout.NORTH);
	pnlChargement.add(pgbChargement,BorderLayout.SOUTH);
	
	frmPrincipale.add(pnlChargement,BorderLayout.SOUTH);
	frmPrincipale.setLocationRelativeTo(null);
	frmPrincipale.setVisible(true);
	
	startTime = System.currentTimeMillis();
}
 
開發者ID:oliverde8,項目名稱:Stroy-Liner,代碼行數:30,代碼來源:LoadingScreen.java

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

示例6: Splash

import javax.swing.JWindow; //導入方法依賴的package包/類
public Splash() {
    splashImg = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/de/rub/dez6a3/jpdfsigner/resources/images/jpdfsignersplash12.png"));
    ImageIcon splashImgIcon = new ImageIcon(splashImg);
    splashWidth = splashImgIcon.getIconWidth();
    splashHeight = splashImgIcon.getIconHeight();
    bufferedImage = new BufferedImage(splashWidth, splashHeight, BufferedImage.TYPE_INT_RGB);
    bg = (Graphics2D) bufferedImage.getGraphics();
    bg.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    bg.setFont(new Font("Arial", Font.PLAIN, 9));
    splashFrame = new JWindow() {

        @Override
        public void paint(Graphics g) {
            bg.drawImage(splashImg, 0, 0, this);
            bg.setColor(new Color(0, 0, 0, 50));
            bg.drawRect(0, 0, getWidth() - 1, getHeight() - 1);

            int x = 27;
            int y = 105;
            int width = ((splashWidth - (x * 2)) * percentBar) / 100;
            int height = 7;

            if (percentBar == 100) {
                loadingMessage = LanguageFactory.getText(LanguageFactory.SPLASH_LOADING_DONE);
            }

            bg.setColor(new Color(150, 150, 150));
            bg.drawString(loadingMessage, x, 205);

            if (percentBar < 0) {
                percentBar = 0;
            }
            if (percentBar > 100) {
                percentBar = 100;
            }


            bg.setColor(new Color(210, 210, 210));
            bg.fillRoundRect(x, y, getWidth() - (x * 2), height, 8, 8);
            bg.setColor(Color.white);
            bg.fillRoundRect(x + 1, y + 1, (getWidth() - (x * 2)) - 2, height - 2, 7, 7);
            bg.setColor(new Color(255, 0, 0, 40));
            bg.fillRoundRect(x + 2, y + 2, width - 4, height - 4, 6, 6);
            g.drawImage(bufferedImage, 0, 0, this);
            graphicsInit = true;
        }
    };

    Dimension splashDimension = new Dimension(splashWidth, splashHeight);
    splashFrame.setSize(splashDimension);
    splashFrame.setPreferredSize(splashDimension);
    splashFrame.setLocationRelativeTo(null);
}
 
開發者ID:ruhr-universitaet-bochum,項目名稱:jpdfsigner,代碼行數:54,代碼來源:Splash.java


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