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

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

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

JFrame.setSize介绍

暂无

代码示例

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

public void run () {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.setSize(480, 320);
    frame.setLocationRelativeTo(null);
    JPanel panel = new JPanel();
    frame.getContentPane().add(panel);
    panel.add(new NewSlider(200, 100, 500, 0.1f, 150, 300));
    frame.setVisible(true);
  }
});

代码示例来源:origin: apache/shiro

methodPanel.add(secureMethod3Button);
frame = new JFrame("Apache Shiro Sample Application");
frame.setSize(500, 200);
Container panel = frame.getContentPane();
panel.setLayout(new BorderLayout());
panel.add(logo, BorderLayout.NORTH);
panel.add(methodPanel, BorderLayout.SOUTH);
frame.setVisible(true);
frame.addWindowListener(new WindowAdapter() {
  public void windowClosing(WindowEvent e) {

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

JFrame guiFrame = new JFrame();
guiFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
guiFrame.setTitle("Example GUI");
guiFrame.setSize(300,250);

代码示例来源:origin: Nilhcem/FakeSMTP

mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mainFrame.addWindowListener(new WindowAdapter() {
  @Override
mainFrame.setSize(frameSize);
mainFrame.setMinimumSize(frameSize);
mainFrame.getContentPane().add(panel.get());
mainFrame.setVisible(true);

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

final JFrame frame = new JFrame();
frame.setSize(0, 0);
final JPopupMenu menu = getSwingMainMenu();
menu.setFocusable(true);
frame.add(menu);
TrayIcon ti = new TrayIcon(getTrayImage(), tooltip, null);
ti.addMouseListener(new MouseListener() {

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

public void run () {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.setSize(480, 320);
    frame.setLocationRelativeTo(null);
    JPanel panel = new JPanel();
    frame.getContentPane().add(panel);
    panel.add(new NewSlider(200, 100, 500, 0.1f, 150, 300));
    frame.setVisible(true);
  }
});

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

private void createDebug() {
  frame = new JFrame("Smack Debug Window");
  frame.getContentPane().add(tabbedPane);
  frame.setSize(650, 400);
    frame.setVisible(true);

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

public void run () {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.setSize(480, 320);
    frame.setLocationRelativeTo(null);
    JPanel panel = new JPanel();
    frame.getContentPane().add(panel);
    panel.add(new Slider(200, 100, 500, 0.1f, 150, 300));
    frame.setVisible(true);
  }
});

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

public JFrame showInJFrame(String title, int width, int height, boolean allowZoom, boolean showControls, boolean exitOnClose) {
  final JFrame main = new JFrame(title);
  int mainWidth = width;
  JScrollPane scroll = new JScrollPane(this);
  main.getContentPane().add(scroll, BorderLayout.CENTER);
  final CursorDisplayer glass = new CursorDisplayer();
  main.setGlassPane(glass);
    JPanel zoomPanel = new JPanel();
    zoomPanel.setLayout(new BoxLayout(zoomPanel, BoxLayout.Y_AXIS));
    main.getContentPane().add(zoomPanel, BorderLayout.WEST);
    zoomPanel.add(Box.createVerticalGlue());
    JButton zoomIn = new JButton("Zoom In");
    zoomPanel.add(Box.createVerticalGlue());
  main.setSize(mainWidth, height);
  if (exitOnClose) {
    main.addWindowListener(new java.awt.event.WindowAdapter() {
  main.setVisible(true);
  this.requestFocus();
  return main;

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

public void run () {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.setSize(480, 320);
    frame.setLocationRelativeTo(null);
    JPanel panel = new JPanel();
    frame.getContentPane().add(panel);
    panel.add(new Slider(200, 100, 500, 0.1f, 150, 300));
    frame.setVisible(true);
  }
});

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

public JFrame showInJFrame(String title, int width, int height, boolean allowZoom, boolean showControls, boolean exitOnClose) {
  final JFrame main = new JFrame(title);
  int mainWidth = width;
  JScrollPane scroll = new JScrollPane(this);
  main.getContentPane().add(scroll, BorderLayout.CENTER);
  final CursorDisplayer glass = new CursorDisplayer();
  main.setGlassPane(glass);
    JPanel zoomPanel = new JPanel();
    zoomPanel.setLayout(new BoxLayout(zoomPanel, BoxLayout.Y_AXIS));
    main.getContentPane().add(zoomPanel, BorderLayout.WEST);
    zoomPanel.add(Box.createVerticalGlue());
    JButton zoomIn = new JButton("Zoom In");
    zoomPanel.add(Box.createVerticalGlue());
  main.setSize(mainWidth, height);
  if (exitOnClose) {
    main.addWindowListener(new java.awt.event.WindowAdapter() {
  main.setVisible(true);
  this.requestFocus();
  return main;

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

public static void main(String[] args) throws Exception {
  JFrame frame = new JFrame("Test");

  ImageIcon loading = new ImageIcon("ajax-loader.gif");
  frame.add(new JLabel("loading... ", loading, JLabel.CENTER));

  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.setSize(400, 300);
  frame.setVisible(true);
}

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

frame = new JFrame("Smack Debug Window -- " + connection.getXMPPServiceDomain() + ":" +
    connection.getPort());
menu.add(menuItem2);
frame.getContentPane().add(tabbedPane);
frame.setSize(550, 400);
frame.setVisible(true);

代码示例来源:origin: libgdx/packr

public static void main (String[] args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setTitle("My Test App");
    frame.setSize(480, 320);
    frame.setVisible(true);
    JOptionPane.showConfirmDialog(null, "Working dir: " + new File(".").getAbsolutePath());
  }
}

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

frame.getContentPane().add(mainPanel, BorderLayout.CENTER);
frame.pack();
frame.setSize(400, 300);
frame.setResizable(true);
frame.setVisible(true);

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

JFrame jFrame = new JFrame("Test");
jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//jFrame.setLocationRelativeTo(null);
jFrame.setSize(600, 600);
jFrame.pack();
jFrame.setVisible(true);
jFrame.setLocationRelativeTo(null); //To center the code

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

final JFrame jframe = new JFrame("Focus-O-Meter");
jframe.addWindowListener(new WindowAdapter()
int height = gd.getDisplayMode().getHeight();
jframe.getContentPane().add(glcanvas, BorderLayout.CENTER);
jframe.setSize(100, height);
jframe.setLocation(width - 100, 0);
jframe.setAlwaysOnTop(true);
jframe.setUndecorated(true);
jframe.setVisible(true);

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

JFrame frame = new JFrame();
frame.setLayout(new BorderLayout());
frame.setSize(200, 200);

// create the status bar panel and shove it down the bottom of the frame
JPanel statusPanel = new JPanel();
statusPanel.setBorder(new BevelBorder(BevelBorder.LOWERED));
frame.add(statusPanel, BorderLayout.SOUTH);
statusPanel.setPreferredSize(new Dimension(frame.getWidth(), 16));
statusPanel.setLayout(new BoxLayout(statusPanel, BoxLayout.X_AXIS));
JLabel statusLabel = new JLabel("status");
statusLabel.setHorizontalAlignment(SwingConstants.LEFT);
statusPanel.add(statusLabel);

frame.setVisible(true);

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

final JFrame jframe = new JFrame("Focus-O-Meter");
jframe.addWindowListener(new WindowAdapter()
int height = gd.getDisplayMode().getHeight();
jframe.getContentPane().add(glcanvas, BorderLayout.CENTER);
jframe.setSize(100, height);
jframe.setLocation(width - 100, 0);
jframe.setAlwaysOnTop(true);
jframe.setUndecorated(true);
jframe.setVisible(true);

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

public static void main(String[] args) {
  JFrame frame = new JFrame();
  frame.setLayout(new GridBagLayout());
  JPanel panel = new JPanel();
  panel.add(new JLabel("This is a label"));
  panel.setBorder(new LineBorder(Color.BLACK)); // make it easy to see
  frame.add(panel, new GridBagConstraints());
  frame.setSize(400, 400);
  frame.setLocationRelativeTo(null);
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.setVisible(true);
}

相关文章

JFrame类方法