Tabnine Logo
Window.setLocationByPlatform
Code IndexAdd Tabnine to your IDE (free)

How to use
setLocationByPlatform
method
in
java.awt.Window

Best Java code snippets using java.awt.Window.setLocationByPlatform (Showing top 20 results out of 315)

Refine searchRefine arrow

  • Window.setVisible
  • JFrame.setDefaultCloseOperation
  • Container.add
  • JFrame.<init>
  • Window.pack
  • SwingUtilities.invokeLater
origin: stackoverflow.com

 import javax.swing.JFrame;
import javax.swing.JLabel;

public class Annoying {
  public static void main(String[] args) {
    JFrame frame = new JFrame("Hello!!");

    // Set's the window to be "always on top"
    frame.setAlwaysOnTop( true );

    frame.setLocationByPlatform( true );
    frame.add( new JLabel("  Isn't this annoying?") );
    frame.pack();
    frame.setVisible( true );
  }
}
origin: stackoverflow.com

  JFrame f = new JFrame("Frame " + ii);
  f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  String s =
    "os.name: " + System.getProperty("os.name") +
    "\nos.version: " + System.getProperty("os.version");
  f.add(new JTextArea(s,3,28));  // suggest a size
  f.pack();
  f.setLocationByPlatform(true);
  f.setVisible(true);
SwingUtilities.invokeLater( new Runnable() {
  public void run() {
    try {
origin: stackoverflow.com

SwingUtilities.invokeLater( new Runnable() {
  public void run() {
    + "The effect we want is a multi-line label.";
    JFrame f = new JFrame("Label Render Test");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JLabel imageLabel = new JLabel(ii);
    f.getContentPane().add(imageLabel);
    f.pack();
    f.setLocationByPlatform(true);
    f.setVisible(true);
origin: stackoverflow.com

    final JFrame frame = new JFrame("Nested Layout Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    plafComponents.add(plafChooser);
    plafComponents.add(pack);
          SwingUtilities.updateComponentTreeUI(frame);
          if (pack.isSelected()) {
            frame.pack();
            frame.setMinimumSize(frame.getSize());
    gui.add(plafComponents, BorderLayout.NORTH);
    frame.pack();
      frame.setLocationByPlatform(true);
      frame.setMinimumSize(frame.getSize());
    } catch(Throwable ignoreAndContinue) {
    frame.setVisible(true);
SwingUtilities.invokeLater(r);
origin: stackoverflow.com

SwingUtilities.invokeLater(new Runnable() {
  public void run() {
    JPanel p = new JPanel(new GridLayout(2,2,4,4));
    border.add(getLabel(
      "Border", SwingConstants.CENTER), BorderLayout.CENTER);
    p.add(border);
    gridbag.add(getLabel("GridBag"));
    p.add(gridbag);
    p.add(box);
    JFrame f = new JFrame("Streeeetch me..");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setContentPane(p);
    f.pack();
    f.setLocationByPlatform(true);
    f.setVisible(true);
origin: stackoverflow.com

JFrame frame = new JFrame("DrawGraph");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(mainPanel);
frame.pack();
frame.setLocationByPlatform(true);
frame.setVisible(true);
SwingUtilities.invokeLater(new Runnable() {
  public void run() {
   createAndShowGui();
origin: stackoverflow.com

JFrame frame = new JFrame("Image Example");
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.pack();
frame.setLocationByPlatform(true);
frame.setVisible(true);
origin: stackoverflow.com

JFrame frame = new JFrame("Input Integer Example");
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
((AbstractDocument)tField.getDocument()).setDocumentFilter(
    new MyDocumentFilter());        
contentPane.add(tField); 
frame.pack();
frame.setLocationByPlatform(true);
frame.setVisible(true);
origin: stackoverflow.com

final JFrame f = new JFrame("Good Location & Size");
f.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
f.addWindowListener( new WindowAdapter() {
  public void windowClosing(WindowEvent we) {
f.add(ta);
f.pack();
  f.setLocationByPlatform(true);
f.setVisible(true);
origin: stackoverflow.com

SwingUtilities.invokeLater(new Runnable() {
  public void run() {
    final JFrame f = new JFrame("Say Bye Bye!");
    f.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    f.addWindowListener( new WindowAdapter() {
      @Override
    f.setLocationByPlatform(true);
    f.setVisible(true);
origin: stackoverflow.com

 import javax.swing.*;

class CenterTheDialog {

  CenterTheDialog() {
    for (int ii=1; ii<4; ii++) {
      JFrame f = new JFrame("Frame " + ii);
      f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

      f.setSize(400,300);
      f.setLocationByPlatform(true);
      f.setVisible(true);

      JDialog d = new JDialog(f);
      d.setSize(300,200);
      d.setLocationRelativeTo(f);
      d.setVisible(true);
    }
  }

  public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        new CenterTheDialog();
      }
    });
  }
}
origin: stackoverflow.com

    tree.expandRow(ii);
  gui.add(buttonPanel, BorderLayout.PAGE_START);
  buttonPanel.add(new JLabel("H Gap"));
if (c instanceof Window) {
  Window w = (Window)c;
  w.pack();
    JFrame f = new JFrame("White (OK Red) Space");
    f.add(gui);
    f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    f.setLocationByPlatform(true);
    f.pack();
    f.setVisible(true);
SwingUtilities.invokeLater(r);
origin: stackoverflow.com

JFrame frame = new JFrame("Layout Example");
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
for (int i = 0; i < 5; i++) {
  buttons[i] = new JButton(borderConstraints[i]);
  borderPanel.add(buttons[i], borderConstraints[i]);
contentPane.add(borderPanel);
for (int i = 5; i < 8; i++) {
  buttons[i] = new JButton(Integer.toString(i));
  flowPanel.add(buttons[i]);
contentPane.add(flowPanel);
frame.pack();
frame.setLocationByPlatform(true);
frame.setVisible(true);
origin: stackoverflow.com

ArrowTest mainPanel = new ArrowTest();
JFrame frame = new JFrame("ArrowTest");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(mainPanel);
frame.pack();
frame.setLocationByPlatform(true);
frame.setVisible(true);
SwingUtilities.invokeLater(new Runnable() {
  public void run() {
   createAndShowGui();
origin: stackoverflow.com

final JFrame frame = new JFrame("Text HIGHLIGHT");
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
contentPane.add(scrollPane);
frame.add(remHighButton, BorderLayout.PAGE_START);
frame.add(contentPane, BorderLayout.CENTER);
frame.add(button, BorderLayout.PAGE_END);
frame.pack();
frame.setLocationByPlatform(true);
frame.setVisible(true);
SwingUtilities.invokeLater(new Runnable()
origin: stackoverflow.com

ArrowTest mainPanel = new ArrowTest();
JFrame frame = new JFrame("ArrowTest");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(mainPanel);
frame.pack();
frame.setLocationByPlatform(true);
frame.setVisible(true);
SwingUtilities.invokeLater(new Runnable() {
  public void run() {
   createAndShowGui();
origin: stackoverflow.com

URL url = new URL("http://i.stack.imgur.com/iQFxo.gif");
final Image image = new ImageIcon(url).getImage();
SwingUtilities.invokeLater(new Runnable() {
  public void run() {
    JFrame f = new JFrame("Image");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setLocationByPlatform(true);
    imagePanel.setBorder(new EmptyBorder(20,20,20,20));
    for (int ii=1; ii<51; ii++) {
      imagePanel.add(new JButton("" + ii));
    f.pack();
    f.setVisible(true);
origin: stackoverflow.com

public void run() {
  JFrame frame = new JFrame("Gabby");
  final JPanel dm = new JPanel() {
  dm.setBorder(BorderFactory.createLineBorder(Color.blue, 10));
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.add(dm);
  frame.pack();
  frame.setLocationByPlatform(true);
  menuBar.add(fileMenu);
  frame.setJMenuBar(menuBar);
  frame.setVisible(true);
origin: stackoverflow.com

@Override
public void run() {
  JFrame f = new JFrame("Image");
  f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  f.setLocationByPlatform(true);
  imagePanel.setBorder(new EmptyBorder(20, 20, 20, 20));
  for (int ii = 1; ii < 51; ii++) {
    imagePanel.add(new JButton("" + ii));
  f.pack();
  f.setVisible(true);
origin: stackoverflow.com

  toggleBtn.addActionListener(btnListener);
  toggleBtn.setActionCommand(text);
  btnPanel.add(toggleBtn);
  btnGroup.add(toggleBtn);
otherPanel.add(textField ); // just to take focus elsewhere
add(btnPanel);
add(otherPanel);
BunchOfButtons mainPanel = new BunchOfButtons();
JFrame frame = new JFrame("BunchOfButtons");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(mainPanel);
frame.pack();
frame.setLocationByPlatform(true);
frame.setVisible(true);
SwingUtilities.invokeLater(new Runnable() {
  public void run() {
   createAndShowGui();
java.awtWindowsetLocationByPlatform

Popular methods of Window

  • dispose
    Releases all of the native screen resources used by thisWindow, its subcomponents, and all of its ow
  • setVisible
  • setLocation
  • pack
    Causes this Window to be sized to fit the preferred size and layouts of its subcomponents. If the wi
  • addWindowListener
    Adds the specified window listener to receive window events from this window. If l is null, no excep
  • getSize
  • getWidth
  • getHeight
  • setSize
  • setBounds
  • getBounds
  • removeWindowListener
    Removes the specified window listener so that it no longer receives window events from this window.
  • getBounds,
  • removeWindowListener,
  • getGraphicsConfiguration,
  • isVisible,
  • addComponentListener,
  • getX,
  • getY,
  • toFront,
  • getLocation,
  • removeComponentListener

Popular in Java

  • Start an intent from android
  • getSharedPreferences (Context)
  • findViewById (Activity)
  • addToBackStack (FragmentTransaction)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • Path (java.nio.file)
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • Best IntelliJ plugins
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