javax.swing.JFrame.setLocation()方法的使用及代码示例

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

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

JFrame.setLocation介绍

暂无

代码示例

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

private static void createWindowForPanel(AwtPanel panel, int location){
  JFrame frame = new JFrame("Render Display " + location);
  frame.getContentPane().setLayout(new BorderLayout());
  frame.getContentPane().add(panel, BorderLayout.CENTER);
  frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  frame.addWindowListener(new WindowAdapter() {
    @Override
    public void windowClosed(WindowEvent e) {
      if (++panelsClosed == 2){
        app.stop();
      }
    }
  });
  frame.pack();
  frame.setLocation(location, Toolkit.getDefaultToolkit().getScreenSize().height - 400);
  frame.setVisible(true);
}

代码示例来源:origin: pmd/pmd

frame.setLocation((screenWidth - frame.getWidth()) / 2, (screenHeight - frame.getHeight()) / 2);
frame.setVisible(true);
int horozontalMiddleLocation = controlSplitPane.getMaximumDividerLocation() * 3 / 5;
controlSplitPane.setDividerLocation(horozontalMiddleLocation);

代码示例来源:origin: fossasia/neurolab-desktop

gameFrame = new JFrame("Neurofeedback Game");
gameFrame.addWindowListener(new WindowAdapter() {
  public void windowClosing(WindowEvent windowevent) {
gameFrame.setLocation((width / 10), (height / 10));
gameFrame.setAlwaysOnTop(true);

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

public class Test
{

  public static void main (String[] args)
  {

    JFrame f1 = new JFrame();
    f1. setSize(100, 100);
    f1.setLocationRelativeTo(null);
    f1.setVisible(true);

    JFrame f2 = new JFrame();
    f2.setSize(100, 100);
    f2.setLocation(f1.getX() + f1.getWidth(), f1.getY());
    f2.setVisible(true);

  }

}

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

class GUI implements Runnable {

  public static void main(String[] args) {
    EventQueue.invokeLater(new GUI());
  }

  @Override
  public void run() {
    JFrame myFrame = new JFrame("Frame Title");

    myFrame.setLocation(new Point(100, 100));
    myFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());
    myFrame.getContentPane().add(mainPanel);
    mainPanel.add(new JButton("Button Text"), BorderLayout.CENTER);

    myFrame.pack();
    myFrame.setLocationByPlatform(true);
    myFrame.setVisible(true);
  }

}

代码示例来源:origin: pmd/pmd

private void createRuleXML() {
  CreateXMLRulePanel rulePanel = new CreateXMLRulePanel(xpathQueryArea, codeEditorPane);
  JFrame xmlframe = new JFrame("Create XML Rule");
  xmlframe.setContentPane(rulePanel);
  xmlframe.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
  xmlframe.setSize(new Dimension(600, 700));
  xmlframe.addComponentListener(new java.awt.event.ComponentAdapter() {
    @Override
    public void componentResized(ComponentEvent e) {
      JFrame tmp = (JFrame) e.getSource();
      if (tmp.getWidth() < 600 || tmp.getHeight() < 700) {
        tmp.setSize(600, 700);
      }
    }
  });
  int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height;
  int screenWidth = Toolkit.getDefaultToolkit().getScreenSize().width;
  xmlframe.pack();
  xmlframe.setLocation((screenWidth - xmlframe.getWidth()) / 2, (screenHeight - xmlframe.getHeight()) / 2);
  xmlframe.setVisible(true);
}

代码示例来源:origin: i2p/i2p.i2p

private void handle(MouseEvent e) {
    //System.out.println("Button " + e.getButton() + " Frame was visible? " +
    //                   frame.isVisible() + " menu was visible? " + menu.isVisible() +
    //                   " trigger? " + menu.isPopupTrigger(e));
    // http://stackoverflow.com/questions/17258250/changing-the-laf-of-a-popupmenu-for-a-trayicon-in-java
    // menu visible check is never true
    if (!frame.isVisible() /* || !menu.isVisible() */ ) {
      frame.setLocation(e.getX(), e.getY());
      frame.setVisible(true);
      menu.show(frame, 0, 0);
    }
    updateMenu();
  }
});

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

private static void createAndShowGUI() {
 //Create and set up the window.
 JFrame frame = new JFrame("HelloWorldSwing");
 frame.setLocation (50, 50);
 ...

代码示例来源:origin: wildfly/wildfly

public void go() throws Exception {
  if(!no_channel && !use_state)
    channel.connect(cluster_name);
  mainFrame=new JFrame();
  mainFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  panel=new DrawPanel(use_state);
  panel.setBackground(background_color);
  sub_panel=new JPanel();
  mainFrame.getContentPane().add("Center", panel);
  clear_button=new JButton("Clear");
  clear_button.setFont(default_font);
  clear_button.addActionListener(this);
  leave_button=new JButton("Leave");
  leave_button.setFont(default_font);
  leave_button.addActionListener(this);
  sub_panel.add("South", clear_button);
  sub_panel.add("South", leave_button);
  mainFrame.getContentPane().add("South", sub_panel);
  mainFrame.setBackground(background_color);
  clear_button.setForeground(Color.blue);
  leave_button.setForeground(Color.blue);
  mainFrame.pack();
  mainFrame.setLocation(15, 25);
  mainFrame.setBounds(new Rectangle(250, 250));
  if(!no_channel && use_state) {
    channel.connect(cluster_name, null, state_timeout);
  }
  mainFrame.setVisible(true);
  setTitle();
}

代码示例来源:origin: RaiMan/SikuliX2

contentPane.add(panel);
frame.pack();
frame.setLocation(storyTopLeft.x, storyTopLeft.y);
if (waitBefore > 0) {
 new Thread(new ShowWaitBefore(frame, waitBefore)).start();
} else {
 frame.setVisible(true);
 log.trace("Story frame visible");

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

JFrame fr=new JFrame();
fr.setLocation(position1);

代码示例来源:origin: wildfly/wildfly

stomp_client.subscribe(clients_dest);
mainFrame=new JFrame();
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
panel=new DrawPanel(false);
leave_button.setForeground(Color.blue);
mainFrame.pack();
mainFrame.setLocation(15, 25);
mainFrame.setBounds(new Rectangle(250, 250));
mainFrame.setVisible(true);
setTitle();

代码示例来源:origin: sc.fiji/Cell_Counter

@Override
  public void run() {
    jFrame.pack();
    jFrame.setLocation(1000, 200);
    jFrame.setVisible(true);
  }
}

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

Point location = MouseInfo.getPointerInfo().getLocation(); 
int x = (int) location.getX();
int y = (int) location.getY();
JFrame frame = new JFrame(); //this is just the initialization of the window
frame.setLocation(x, y);

代码示例来源:origin: wildfly/wildfly

public void start() throws Exception {
  mainFrame=new JFrame("Chat demo");
  mainFrame.setPreferredSize(new Dimension(600,600));
  mainFrame.setBackground(Color.white);
  mainFrame.setLocation(15, 25);
  Dimension main_frame_size=mainFrame.getSize();
  txtArea.setPreferredSize(new Dimension((int)(main_frame_size.width * 0.9), (int)(main_frame_size.height * 0.8)));
  mainFrame.setVisible(true);
  txtField.setFocusable(true);
  txtField.requestFocusInWindow();

代码示例来源:origin: IanDarwin/javasrc

/** "main program" method - construct and show */
public static void main(String[] av) {
  // create a MoreChoices object, tell it to show up
  JFrame jf = new MoreChoices();
  jf.setLocation(100, 100);	// get away from screen corner,
            // since on some OSes a main window at 0,0 may be
            // partly obscured (e.g. notebook with PowerPanel
  jf.setVisible(true);
}

代码示例来源:origin: IanDarwin/javasrc

public EvalServer() throws java.rmi.RemoteException {
  super();
  // System.out.println("In EvalServer constructor");
  h = new HashMap<String,Evaluation>();
  if (!isVisual)
    return;
  f = new JFrame("Daily Evaluation Server");
  f.setLocation(100, 100);
  f.setContentPane(g = new Grapher());
  f.pack();
}

代码示例来源:origin: igniterealtime/Smack

JFrame window = new JFrame();
JPanel jp = new JPanel();
window.add(jp);
window.setLocation(0, 0);
window.setSize(600, 600);
receiver.setVisible(true);
window.setAlwaysOnTop(true);
window.setVisible(true);

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

public static void main(String[] args) {
  JFrame c = new AppController("FilmDataBase"); 
  c.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  c.setLocation(1600, 400);
  c.setSize(600, 200);
  c.setVisible(true);
}

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

JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setTitle("MyFirstFrame");
frame.setBackground(Color.BLACK);
frame.setLocation(0,0);
frame.setSize(150,150);

相关文章

JFrame类方法