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


Java JWindow.setBackground方法代碼示例

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


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

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

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

示例3: safeSetBackground

import javax.swing.JWindow; //導入方法依賴的package包/類
private static void safeSetBackground(JWindow window, Color background) {
    GraphicsConfiguration gc = window.getGraphicsConfiguration();
    
    if (!gc.isTranslucencyCapable()) return; // PERPIXEL_TRANSLUCENT not supported
    if (gc.getDevice().getFullScreenWindow() == window) return; // fullscreen windows not supported
    
    window.setBackground(background);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:9,代碼來源:CustomPopupFactory.java

示例4: NewCorefAction

import javax.swing.JWindow; //導入方法依賴的package包/類
public NewCorefAction() {
  popupWindow = new JWindow(SwingUtilities.getWindowAncestor(textView.
      getGUI()));
  popupWindow.setBackground(UIManager.getLookAndFeelDefaults().
                            getColor("ToolTip.background"));
  mainPanel.setLayout(new BorderLayout());
  mainPanel.setOpaque(true);
  mainPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
  mainPanel.setBackground(UIManager.getLookAndFeelDefaults().
                          getColor("ToolTip.background"));
  popupWindow.setContentPane(mainPanel);

  panel.setLayout(new BorderLayout());
  panel.setOpaque(false);
  panel.add(new JScrollPane(list), BorderLayout.CENTER);

  subPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
  subPanel.add(add);
  subPanel.add(cancel);
  subPanel.setOpaque(false);
  panel.add(subPanel, BorderLayout.SOUTH);
  mainPanel.add(label, BorderLayout.NORTH);
  mainPanel.add(panel, BorderLayout.CENTER);

  // and finally load the data for the list
  AddAction action = new AddAction();
  add.addActionListener(action);
  cancel.addActionListener(action);
  listEditor = new ListEditor(action);
  list.setMaximumRowCount(5);
  list.setEditable(true);
  list.setEditor(listEditor);
  list.setModel(model);
}
 
開發者ID:GateNLP,項目名稱:gate-core,代碼行數:35,代碼來源:CorefEditor.java

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

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

示例7: getPopup

import javax.swing.JWindow; //導入方法依賴的package包/類
@Override
public Popup getPopup(Component owner, Component contents, int x, int y)
    throws IllegalArgumentException
{
    Popup popup = super.getPopup(owner, contents, x, y);
    
    // 比較安全的hack方式
    Object obj = SwingUtilities.getWindowAncestor(contents);

    if (obj instanceof JWindow)
    {
        JWindow window = (JWindow) obj;

        // 承載內容的窗體透明
        window.setBackground(UIManager.getColor(LuckGlobalBundle.TRANSLUCENT_COLOR));

        ((JComponent) window.getContentPane()).setOpaque(false);
        
        JdkVersion version = JdkVersion.getSingleton();
        
        boolean isCompatible = (version.getMajor() <= 1 && version.getMinor() < 8);
        
        if (contents instanceof JPopupMenu && isCompatible)
        {
            boolean isFound = false;
            
            for (ComponentListener listener : window.getComponentListeners())
            {
                if(listener instanceof LuckPopupComponentListener)
                {
                    isFound = true;
                    
                    break;
                }
            }
            
            if(!isFound)
            {
                window.addComponentListener(new LuckPopupComponentListener());
            }
        }
    }

    return popup;
}
 
開發者ID:freeseawind,項目名稱:littleluck,代碼行數:46,代碼來源:LuckPopupFactory.java

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


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