Tabnine Logo
JFrame.setBounds
Code IndexAdd Tabnine to your IDE (free)

How to use
setBounds
method
in
javax.swing.JFrame

Best Java code snippets using javax.swing.JFrame.setBounds (Showing top 20 results out of 837)

Refine searchRefine arrow

  • JFrame.setVisible
  • JFrame.<init>
  • JFrame.setDefaultCloseOperation
origin: stackoverflow.com

 public static void main(String[] args) {
  Rectangle box = new Rectangle(5, 10, 20, 30);

  // New stuff - Create a program window and set it up.
  JFrame window = new JFrame();

  // Tell Swing to exit the program when the program window is closed.
  window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

  // Set the window boundaries to be 300x300 on the screen, and position it 30 pixels from the top and left edges of the monitor.
  window.setBounds(30, 30, 300, 300);

  // Get the content pane of the window, and give it our own custom component.
  window.getContentPane().add(new JComponent() {  // Not a typo - this is some advanced magic called an "anonymous class".
    Rectangle myBox = box;    // Give the component a reference to our box object.
    public void paint(Graphics g) {
      g.drawRect(myBox.x, myBox.y, myBox.width, myBox.height);
    }
  });

  // Make our window appear.
  window.setVisible(true);
}
origin: stackoverflow.com

 Dimension ss = Toolkit.getDefaultToolkit ().getScreenSize ();
Dimension frameSize = new Dimension ( 500, 300 );

JFrame frame = new JFrame ();
frame.setBounds ( ss.width / 2 - frameSize.width / 2, 
         ss.height / 2 - frameSize.height / 2,
         frameSize.width, frameSize.height );
frame.setVisible ( true );
origin: stackoverflow.com

frame.setDefaultCloseOperation ( JFrame.EXIT_ON_CLOSE );
frame.setBounds ( sb.x + sb.width / 2 - frameSize.width / 2,
    sb.y + sb.height / 2 - frameSize.height / 2, frameSize.width,
    frameSize.height );
frame.setVisible ( true );
origin: codeka/wwmmo

 /** Initialize the contents of the frame. */
 private void initialize() {
  frame = new JFrame();
  frame.setTitle("Planet Render");
  frame.setBounds(100, 100, 1200, 700);
  frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  frame.getContentPane().add(new AppContent());
 }
}
origin: net.java.dev.jets3t/jets3t

/**
 * Constructor to run this application in a stand-alone window.
 *
 * @param ownerFrame the frame the application will be displayed in
 * @throws S3ServiceException
 */
public Uploader(JFrame ownerFrame, Properties standAloneArgumentProperties) throws S3ServiceException {
  this(false);
  this.ownerFrame = ownerFrame;
  this.standAloneArgumentProperties = standAloneArgumentProperties;
  init();
  ownerFrame.getContentPane().add(this);
  ownerFrame.setBounds(this.getBounds());
  ownerFrame.setVisible(true);
}
origin: violetumleditor/violetumleditor

/**
 * Return a temporary frame if the real frame owner is not yet set
 * (for example, 
 */
private Frame getEmergencyDialogOwner()
{
  JFrame emergencyFrame = new JFrame();
  Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
  int screenWidth = (int) screenSize.getWidth();
  int screenHeight = (int) screenSize.getHeight();
  emergencyFrame.setBounds(screenWidth / 16, screenHeight / 16, screenWidth * 7 / 8, screenHeight * 7 / 8);
  return emergencyFrame;
}
origin: stackoverflow.com

 public static void main(String[] args) {
  JFrame frame = new JFrame();
  frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  frame.setBounds(0, 0, 300, 400);
  frame.setLayout(null);
  final JTabbedPane tabbedPane = new JTabbedPane();
  tabbedPane.addTab("One", new JPanel());
  tabbedPane.addTab("Two", new JPanel());
  tabbedPane.addTab("Three", new JPanel());
  tabbedPane.addChangeListener(new ChangeListener() {
    public void stateChanged(ChangeEvent e) {
      System.out.println("Tab: " + tabbedPane.getSelectedIndex());
    }
  });
  tabbedPane.setBounds(0, 0, 300, 400);
  frame.add(tabbedPane);
  frame.setVisible(true);
}
origin: stackoverflow.com

JFrame start = new JFrame("TatteredLands");
 start.setVisible(true);
 start.setBounds(0, 0, width, height);
 // add other initialization operations here...
origin: stackoverflow.com

 JFrame myFrame = new JFrame("My Frame");
myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)       
myFrame.setBounds(10, 10, 300, 100);
myFrame.setUndecorated(true);
origin: net.java.dev.jets3t/jets3t

/**
 * Constructor to run this application in a stand-alone window.
 *
 * @param ownerFrame the frame the application will be displayed in
 * @throws S3ServiceException
 */
public Cockpit(JFrame ownerFrame) throws S3ServiceException {
  this();
  this.ownerFrame = ownerFrame;
  isStandAloneApplication = true;
  init();
  ownerFrame.getContentPane().add(this);
  ownerFrame.setBounds(this.getBounds());
  ownerFrame.setVisible(true);
}
origin: stackoverflow.com

JFrame frame = new JFrame();
 frame.setBounds(100, 100, 529, 300);
 frame.getContentPane().setLayout(null);//over ride default
 Container c = frame.getContentPane();
 JButton btnNewButton_4 = new JButton("New button");
 c.add(btnNewButton_4);
 c.seBounds(4,10,40,25);
 JButton btnNewButton_3 = new JButton("New button 3");
 c.add(btnNewButton_3);
 c.seBounds(40,10,40,25);//...etc
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: stackoverflow.com

 public class MainGui {

  private JFrame top;

  public MainGui(ActionListener listener) {
    top = new JFrame();
    top.setBounds(300, 300, 600, 300);
    JButton doneButton = new JButton("Done");
    doneButton.addActionListener(listener);
    top.add(doneButton);
    top.pack();
    top.setVisible(true);
  }
}
origin: stackoverflow.com

JFrame frame = new JFrame();
 frame.setBounds(100, 100, 784, 533);
 frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
 // Use whatever layout suits you but I prefer mig
 frame.getContentPane().setLayout(new MigLayout("", "[344.00,grow,fill][-457.00]", "[grow]"));
 frame.setTitle("Title");
 frame.setAlwaysOnTop(true);
 JPanel panel = new JPanel();
 frame.getContentPane().add(panel, "cell 0 0,grow");
// Then add Text fields and labels so the user knows what to enter
 JLabel lbl = new JLabel("Environment Name");
 panel .add(lbl, "cell 0 0");
 JTextField textField = new JTextField();
 panel.add(textField , "cell 0 1,growx");
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.jets3t

/**
 * Constructor to run this application in a stand-alone window.
 *
 * @param ownerFrame the frame the application will be displayed in
 * @throws S3ServiceException
 */
public Cockpit(JFrame ownerFrame) throws S3ServiceException {
  this();
  this.ownerFrame = ownerFrame;
  isStandAloneApplication = true;
  init();
  ownerFrame.getContentPane().add(this);
  ownerFrame.setBounds(this.getBounds());
  ownerFrame.setVisible(true);
}
origin: stackoverflow.com

 PopupFactory factory = PopupFactory.getSharedInstance();
JFrame frame = new JFrame();
frame.setLayout(null);
frame.setBounds(428, 99, 185, 155);

final JButton button = new JButton();
button.setText("Button");
button.setBounds(10, 93, 111, 25);
frame.getContentPane().add(button);

final Popup popup = factory.getPopup(null, frame, 200, 200);
popup.show();
origin: wildfly/wildfly

stomp_client.subscribe(clients_dest);
mainFrame=new JFrame();
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
panel=new DrawPanel(false);
panel.setBackground(background_color);
mainFrame.pack();
mainFrame.setLocation(15, 25);
mainFrame.setBounds(new Rectangle(250, 250));
mainFrame.setVisible(true);
setTitle();
origin: stackoverflow.com

 JFrame snakeFrame = new JFrame();
snakeFrame.setBounds(100, 200, 800, 800);
snakeFrame.setVisible(true);
snakeFrame.add(new JLabel(new ImageIcon("Images/Snake.png")));
snakeFrame.pack();
origin: stackoverflow.com

 import java.awt.BorderLayout;

public class MyFrame {
  JFrame frame;
  private JTable table;

  public MyFrame() {
    frame = new JFrame();
    frame.setBounds(100, 100, 450, 300);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    table = new JTable();
    table.setModel(new MyTableModel());
    table.setFillsViewportHeight(true);
    table.getColumnModel()
      .getColumn(1)
      .setCellRenderer(new MyPanelCellRenderer());
    table.setRowHeight(40); // static sizing

    JScrollPane scrollPane = new JScrollPane();
    frame.getContentPane().add(scrollPane, BorderLayout.CENTER);
    scrollPane.setViewportView(table);
  }
}
origin: net.java.dev.jets3t/jets3t

/**
 * Constructor to run this application in a stand-alone window.
 *
 * @param ownerFrame the frame the application will be displayed in
 * @throws S3ServiceException
 */
public CockpitLite(JFrame ownerFrame, Properties standAloneArgumentProperties) throws S3ServiceException {
  mCredentialProvider = new BasicCredentialsProvider();
  this.ownerFrame = ownerFrame;
  this.standAloneArgumentProperties = standAloneArgumentProperties;
  isStandAloneApplication = true;
  init();
  ownerFrame.getContentPane().add(this);
  ownerFrame.setBounds(this.getBounds());
  ownerFrame.setVisible(true);
}
javax.swingJFramesetBounds

Popular methods of JFrame

  • <init>
  • setVisible
  • setDefaultCloseOperation
  • pack
  • getContentPane
  • setSize
  • add
  • addWindowListener
  • dispose
  • setTitle
  • setContentPane
  • setLocation
  • setContentPane,
  • setLocation,
  • setLocationRelativeTo,
  • setJMenuBar,
  • setLayout,
  • setResizable,
  • setIconImage,
  • getRootPane,
  • getSize

Popular in Java

  • Making http post requests using okhttp
  • scheduleAtFixedRate (ScheduledExecutorService)
  • requestLocationUpdates (LocationManager)
  • putExtra (Intent)
  • VirtualMachine (com.sun.tools.attach)
    A Java virtual machine. A VirtualMachine represents a Java virtual machine to which this Java vir
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • Option (scala)
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now