当前位置: 首页>>代码示例>>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;未经允许,请勿转载。