本文整理匯總了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);
}
示例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));
}
示例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);
}
示例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);
}
示例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);
}
});
}
示例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);
}
示例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;
}
示例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();
}