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