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

How to use
setSize
method
in
java.awt.Window

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

Refine searchRefine arrow

  • Window.setVisible
  • Container.add
  • JFrame.setDefaultCloseOperation
  • JFrame.<init>
  • JPanel.<init>
origin: stackoverflow.com

 import java.awt.*;
import java.awt.geom.Line2D;
import javax.swing.*;

public class FrameTest {
  public static void main(String[] args) {
    JFrame jf = new JFrame("Demo");
    Container cp = jf.getContentPane();
    cp.add(new JComponent() {
      public void paintComponent(Graphics g) {
        Graphics2D g2 = (Graphics2D) g;
        g2.setStroke(new BasicStroke(10));
        g2.draw(new Line2D.Float(30, 20, 80, 90));
      }
    });
    jf.setSize(300, 200);
    jf.setVisible(true);
  }
}
origin: stackoverflow.com

 import java.awt.BorderLayout;
import java.awt.FlowLayout;
import javax.swing.ButtonGroup;
import javax.swing.JFrame;
import javax.swing.JRadioButton;


public class Rb  extends JFrame {
Rb (){
   JRadioButton male = new JRadioButton("male");
   JRadioButton female = new JRadioButton("Female");
   ButtonGroup bG = new ButtonGroup();
   bG.add(male);
   bG.add(female);
   this.setSize(100,200);
   this.setLayout( new FlowLayout());
   this.add(male);
   this.add(female);
   male.setSelected(true);
   this.setVisible(true);
 }
public static void main(String args[]){
  Rb j = new Rb();
}
origin: stackoverflow.com

 import java.awt.*;
import java.awt.event.*;

class FrameByeBye {

  // The method we wish to call on exit.
  public static void showMessage() {
    System.out.println("Bye Bye!");
  }

  public static void main(String[] args) {
    Frame f = new Frame("Say Bye Bye!");
    f.addWindowListener( new WindowAdapter() {
      @Override
      public void windowClosing(WindowEvent we) {
        showMessage();
        System.exit(0);
      }
    } );
    f.setSize(300,200);
    f.setLocationByPlatform(true);
    f.setVisible(true);
  }
}
origin: stackoverflow.com

constraints.fill = GridBagConstraints.BOTH;
JLabel l = new JLabel("You have got 2 new Messages.");
panel.add(l, constraints);
constraints.gridx++;
constraints.weightx = 0f;
b.setMargin(new Insets(1, 4, 1, 4));
b.setFocusable(false);
panel.add(b, constraints);
dialog.setUndecorated(true);
dialog.setSize(300, 100);
dialog.setLocation(screenSize.width - dialog.getWidth(),
    screenSize.height - taskBarSize - dialog.getHeight());
origin: stackoverflow.com

JFrame frame = new JFrame();
frame.setTitle("Test Background");
frame.setLocation(200, 100);
frame.setSize(600, 400);
frame.addWindowListener(new WindowAdapter() {
frame.setVisible(true);
origin: stackoverflow.com

  defaultItem.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      setVisible(true);
      setExtendedState(JFrame.NORMAL);
      try {
        tray.add(trayIcon);
        setVisible(false);
        System.out.println("added to SystemTray");
      } catch (AWTException ex) {
      try{
  tray.add(trayIcon);
  setVisible(false);
  System.out.println("added to SystemTray");
  }catch(AWTException ex){
setVisible(true);
setSize(300, 200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
origin: stackoverflow.com

private JFrame frame = new JFrame("Test");
private JPanel panel = new JPanel();
private JLabel label = new JLabel("CenteredJLabel");
  panel.add(label);
  panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
  frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  frame.add(panel);
  frame.setSize(400, 300);
  frame.setLocationRelativeTo(null);
  frame.setVisible(true);
origin: stackoverflow.com

label1 = new JLabel("max 10 chars");
textfield1 = new JTextField(15);
add(label1);
add(textfield1);
textfield1.setDocument(new JTextFieldLimit(10));
setSize(300,300);
setVisible(true);
origin: stackoverflow.com

 import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class MainClass extends JPanel {

 public MainClass() {

   addMouseListener(new MouseAdapter() { 
     public void mousePressed(MouseEvent me) { 
      System.out.println(me); 
     } 
    }); 

 }

 public static void main(String[] args) {
  JFrame frame = new JFrame();
  frame.getContentPane().add(new MainClass());

  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

  frame.setSize(200, 200);
  frame.setVisible(true);
 }
}
origin: stackoverflow.com

JPanel jp = new JPanel();
jp.setLayout(new BorderLayout());
JTabbedPane tb = new JTabbedPane();
tb.add("Tab4", new JTextArea(""));
tb.add("Tab5", new JTextArea(""));
jp.add(tb, BorderLayout.CENTER);
add(jp, BorderLayout.CENTER);
tb.setEnabledAt(1, false);
tb.setEnabledAt(3, false);
JFrame frame = new JFrame();
frame.getContentPane().add(new TabbedPane());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(500, 200);
frame.setVisible(true);
origin: stackoverflow.com

 import javax.swing.*;
import java.awt.*;

public class Main {
  public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
    frame.setSize(600, 400);

    JPanel panel = new JPanel() {
      @Override
      public void paintComponent(Graphics g) {
        super.paintComponent(g);
        g.setColor(Color.BLUE);
        g.fillRect(0, 0, 100, 100);
      }
    };
    frame.add(panel);

    // Graphics g = panel.getGraphics();
    // g.setColor(Color.BLUE);
    // g.fillRect(0, 0, 100, 100);

    frame.validate(); // because you added panel after setVisible was called
    frame.repaint(); // because you added panel after setVisible was called
  }
}
origin: stackoverflow.com

MyButton button = new MyButton("Hello, World!");
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400, 400);
contentPane.add(button);
frame.setVisible(true);
origin: stackoverflow.com

JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
frame.setSize(600, 400);
frame.add(panel);
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

JFrame f = new JFrame();
f.setSize(500, 500);
f.setTitle("Sometimes Red, Sometimes Blue");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setContentPane(new TestPanel());
f.setVisible(true);
origin: stackoverflow.com

table.setAutoResizeMode( JTable.AUTO_RESIZE_OFF );
final JScrollPane scrollPane = new JScrollPane( table );
getContentPane().add( scrollPane );
frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
frame.pack();
frame.setSize(400, 300);
frame.setVisible(true);
origin: stackoverflow.com

JFrame frame = new JFrame("Labels in a circle");
frame.setSize(500, 500);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel();;
SpringLayout layout = new SpringLayout();
for (Point point : points) {
 JLabel label = new JLabel("Point " + count);
 panel.add(label);
 count++;
 layout.putConstraint(SpringLayout.WEST, label, point.x, SpringLayout.WEST, panel);
frame.add(panel);
frame.setVisible(true);
origin: stackoverflow.com

public static void main(String args[]) {
  FrameTestBase t = new FrameTestBase();
  t.add(new JComponent() {
    public void paintComponent(Graphics g) {
      String str = "hello world!";
  t.setDefaultCloseOperation(EXIT_ON_CLOSE);
  t.setSize(400, 200);
  t.setVisible(true);
origin: stackoverflow.com

super("Add component on JFrame at runtime");
setLayout(new BorderLayout());
this.panel = new JPanel();
this.panel.setLayout(new FlowLayout());
add(panel, BorderLayout.CENTER);
JButton button = new JButton("CLICK HERE");
add(button, BorderLayout.SOUTH);
button.addActionListener(this);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(500, 500);
setVisible(true);
this.panel.add(new JButton("Button"));
this.panel.revalidate();
validate();
origin: stackoverflow.com

JFrame frame = new JFrame();
frame.setTitle("Welcome!");
frame.setSize(520, 480);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel heroShotPanel = new JPanel();
JLabel heroShot = new JLabel(heroShotImage);
heroShotPanel.add(heroShot);
JPanel submitPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
submitPanel.add(start);
frame.getContentPane().add(heroShotPanel, BorderLayout.NORTH);
frame.getContentPane().add(submitPanel, BorderLayout.SOUTH);
frame.setVisible(true);
frame.getRootPane().setDefaultButton(start);
start.requestFocus();
java.awtWindowsetSize

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
  • setBounds
  • getBounds
  • removeWindowListener
    Removes the specified window listener so that it no longer receives window events from this window.
  • getGraphicsConfiguration
    This method returns the GraphicsConfiguration used by this Window.
  • removeWindowListener,
  • getGraphicsConfiguration,
  • isVisible,
  • addComponentListener,
  • getX,
  • getY,
  • toFront,
  • getLocation,
  • removeComponentListener

Popular in Java

  • Making http post requests using okhttp
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getSupportFragmentManager (FragmentActivity)
  • getApplicationContext (Context)
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • From CI to AI: The AI layer in your organization
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