javax.swing.JWindow.setLocationRelativeTo()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(3.7k)|赞(0)|评价(0)|浏览(165)

本文整理了Java中javax.swing.JWindow.setLocationRelativeTo()方法的一些代码示例,展示了JWindow.setLocationRelativeTo()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JWindow.setLocationRelativeTo()方法的具体详情如下:
包路径:javax.swing.JWindow
类名称:JWindow
方法名:setLocationRelativeTo

JWindow.setLocationRelativeTo介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

frame.add(new JLabel(new ImageIcon(ImageIO.read(getClass().getResource("/Puppy.png")))));
  frame.pack();
  frame.setLocationRelativeTo(null);
  frame.setVisible(true);
} catch (IOException ex) {

代码示例来源:origin: stackoverflow.com

JWindow window = new JWindow();
 window.add(new JButton("test"));
 window.setSize(500, 500);
 window.setLocationRelativeTo(null);
 window.setVisible(true);

代码示例来源:origin: stackoverflow.com

ImageIcon icon = new ImageIcon("images/ajax-loader.gif");
 JLabel label=new JLabel(icon);
 JWindow myJFrame=new JWindow();
 myJFrame.setLayout(new BorderLayout());
 myJFrame.add(label,BorderLayout.CENTER);
 myJFrame.setLocationRelativeTo(null);
 myJFrame.setOpacity(0.5f);
 myJFrame.setAlwaysOnTop(true);
 label.setOpaque(false);
 AWTUtilities.setWindowOpaque(myJFrame, false);
 myJFrame.pack();
 myJFrame.setVisible(true);

代码示例来源:origin: stackoverflow.com

public class ShowSplash 
{
  private static JWindow splashFrame;

  public void start(String splashImagePath) throws Exception
  {
   JLabel label;
   ImageIcon image;
   URL url;

   splashFrame = new JWindow();
   url         = ShowSplash.class.getResource(splashImagePath);
   image       = new ImageIcon(url);
   label       = new JLabel(image);

   splashFrame.add(label, BorderLayout.CENTER);
   splashFrame.pack();
   splashFrame.setLocationRelativeTo(null);
   splashFrame.setVisible(true);
  }

  public void stop() throws Exception
  {
   splashFrame.dispose();

   splashFrame = null;
  }
}

代码示例来源:origin: stackoverflow.com

window.setLocationRelativeTo(this);
window.add(new JLabel("Test JWindow", JLabel.CENTER));
window.setVisible(true);

代码示例来源:origin: stackoverflow.com

frame.add(new SplashPane());
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);

代码示例来源:origin: stackoverflow.com

frame.setContentPane(new ShapedPane());
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
frame.setAlwaysOnTop(true);

代码示例来源:origin: stackoverflow.com

public JWindow initSplash(){
    JWindow window = new JWindow();
    final JFXPanel fxPanel = new JFXPanel();
    window.add(fxPanel);
    window.setVisible(true);
    window.setLocationRelativeTo(null);

    Platform.runLater(new Runnable() {

      @Override
      public void run() {
        Scene scene = new Scene(new CustomFxSplash(), 475, 300, true);
        fxPanel.setScene(scene);
      }
    }
    return window;
}

代码示例来源:origin: GoldenGnu/jeveassets

public void show(final String text, final LockWorker lockWorker) {
  jLabel.setText(text);
  jWindow.pack();
  //Get the parent size
  Dimension parentSize = parent.getSize();
  //Calculate the frame location
  int x = (parentSize.width - jWindow.getWidth()) / 2;
  int y = (parentSize.height - jWindow.getHeight()) / 2;
  //Set the new frame location
  jWindow.setLocation(x, y);
  jWindow.setLocationRelativeTo(parent);
  parent.setEnabled(false);
  jProgress.setIndeterminate(false);
  jProgress.setIndeterminate(true);
  jWindow.setVisible(true); //Does not block!
  Wait wait = new Wait(lockWorker);
  wait.execute();
}

代码示例来源:origin: stackoverflow.com

public class TranslucentWindow {

  public static void main(String[] args) {
    new TranslucentWindow();
  }

  public TranslucentWindow() {
    EventQueue.invokeLater(new Runnable() {
      @Override
      public void run() {
        try {
          UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
        }

        JWindow window = new JWindow();
        window.setSize(100, 100);
        window.setBackground(new Color(255, 0, 0, 128));
        window.setLocationRelativeTo(null);
        window.setVisible(true);

      }
    });
  }

}

代码示例来源:origin: stackoverflow.com

splash.add(subMessage, gbc);
  splash.pack();
  splash.setLocationRelativeTo(null);
  splash.setVisible(true);
} catch (IOException ex) {

相关文章