Tabnine Logo
Container
Code IndexAdd Tabnine to your IDE (free)

How to use
Container
in
java.awt

Best Java code snippets using java.awt.Container (Showing top 20 results out of 12,078)

Refine searchRefine arrow

  • Window
  • JFrame
  • JComponent
  • Component
  • JPanel
  • JButton
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: stackoverflow.com

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: runelite/runelite

  @Override
  public void layoutContainer(Container parent)
  {
    int x = 0;
    for (Component c : parent.getComponents())
    {
      x += ITEM_PADDING;
      int height = c.getPreferredSize().height;
      if (height > TITLEBAR_SIZE)
      {
        height = TITLEBAR_SIZE;
      }
      c.setBounds(x, (TITLEBAR_SIZE - height) / 2, TITLEBAR_SIZE, height);
      x += TITLEBAR_SIZE;
    }
  }
});
origin: stanfordnlp/CoreNLP

private void initAboutBox() {
 aboutBox = new JDialog(this, "About Tregex");
 aboutBox.getContentPane().setLayout(new BorderLayout());
 aboutBox.getContentPane().add(new JLabel("<html><b>Tregex and Tsurgeon</b></html>", SwingConstants.CENTER), BorderLayout.NORTH);
 aboutBox.getContentPane().add(new JLabel("<html>Tregex by Galen Andrew and Roger Levy<br>Tsurgeon by Roger Levy<br>Graphical interface by Anna Rafferty<br>Additional features and development by Chris Manning<br></html>", SwingConstants.CENTER), BorderLayout.CENTER);
 aboutBox.getContentPane().add(new JLabel("<html><font size=2>\u00A92007 The Board of Trustees of The Leland Stanford Junior University.<br>Distributed under the GNU General Public License</font></html>", SwingConstants.CENTER), BorderLayout.SOUTH);
}
origin: jMonkeyEngine/jmonkeyengine

private static void createTabs(){
  tabbedPane = new JTabbedPane();
  canvasPanel1 = new JPanel();
  canvasPanel1.setLayout(new BorderLayout());
  tabbedPane.addTab("jME3 Canvas 1", canvasPanel1);
  canvasPanel2 = new JPanel();
  canvasPanel2.setLayout(new BorderLayout());
  tabbedPane.addTab("jME3 Canvas 2", canvasPanel2);
  frame.getContentPane().add(tabbedPane);
  currentPanel = canvasPanel1;
}
origin: org.netbeans.api/org-openide-util

/** Find a focus-traverable component.
* @param c the component to look in
* @return the same component if traversable, else a child component if present, else <code>null</code>
* @see Component#isFocusTraversable
*/
public static Component getFocusTraversableComponent(Component c) {
  if (c.isFocusable()) {
    return c;
  }
  if (!(c instanceof Container)) {
    return null;
  }
  int i;
  int k = ((Container) c).getComponentCount();
  for (i = 0; i < k; i++) {
    Component v = ((Container) c).getComponent(i);
    if (v != null) {
      return v;
    }
  }
  return null;
}
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

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

public class AnotherJFrame extends JFrame
{
  public AnotherJFrame()
  {
    super("Another GUI");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    add(new JLabel("Empty JFrame"));
    pack();
    setVisible(true);
  }
}
origin: stanfordnlp/CoreNLP

private void buildExtractButton() {
 if (extractButton == null) {
  JPanel buttonPanel = new JPanel();
  extractButton = new JButton("Run NER");
  buttonPanel.add(extractButton);
  frame.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
  extractButton.addActionListener(actor);
 }
}
origin: spotbugs/spotbugs

  public static void main(String args[]) {
    JFrame frame = new JFrame();
    frame.setTitle("Title");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JButton button = new JButton();
    button.setText("Hello, World!");
    frame.getContentPane().add(button, BorderLayout.CENTER);
    frame.setSize(200, 100);
    frame.pack();
    frame.setVisible(true);
    frame.show();
  }
}
origin: stackoverflow.com

p.add(f);
frame.add(p);
suggestionsPanel = new JPanel();
suggestionsPanel.setLayout(new GridLayout(0, 1));
suggestionsPanel.setBackground(popUpBackground);
textField.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0, true), "Down released");
textField.getActionMap().put("Down released", new AbstractAction() {
  @Override
  public void actionPerformed(ActionEvent ae) {//focuses the first label on popwindow
    for (int i = 0; i < suggestionsPanel.getComponentCount(); i++) {
      if (suggestionsPanel.getComponent(i) instanceof SuggestionLabel) {
        ((SuggestionLabel) suggestionsPanel.getComponent(i)).setFocused(true);
        autoSuggestionPopUpWindow.toFront();
        autoSuggestionPopUpWindow.requestFocusInWindow();
        suggestionsPanel.requestFocusInWindow();
        suggestionsPanel.getComponent(i).requestFocusInWindow();
        break;
            autoSuggestionPopUpWindow.requestFocusInWindow();
            suggestionsPanel.requestFocusInWindow();
            suggestionsPanel.getComponent(i).requestFocusInWindow();
            lastFocusableIndex = i;
            break;
for (int i = 0; i < suggestionsPanel.getComponentCount(); i++) {
  if (suggestionsPanel.getComponent(i) instanceof SuggestionLabel) {
origin: stackoverflow.com

plafComponents.add(plafChooser);
plafComponents.add(pack);
gui.add(plafComponents, BorderLayout.NORTH);
JPanel dynamicLabels = new JPanel(new BorderLayout(4,4));
dynamicLabels.setBorder(
  new TitledBorder("BorderLayout(4,4)") );
gui.add(dynamicLabels, BorderLayout.WEST);
JButton addNew = new JButton("Add Another Label");
dynamicLabels.add( addNew, BorderLayout.NORTH );
addNew.addActionListener( new ActionListener(){
    labels.add( new JLabel("Label " + ++labelCount) );
    frame.validate();
dynamicLabels.add( new JScrollPane(labels), BorderLayout.CENTER );
ImageIcon ii = new ImageIcon(bi);
JLabel imageLabel = new JLabel(ii);
imagePanel.add( imageLabel, null );
  tableScroll,
  new JScrollPane(imagePanel));
gui.add( splitPane, BorderLayout.CENTER );
origin: stackoverflow.com

backingPanel.setSize(LAYERED_PANE_SIZE);
backingPanel.setLocation(2 * GAP, 2 * GAP);
backingPanel.setBackground(Color.black);
for (int row = 0; row < GRID_ROWS; row++) {
  for (int col = 0; col < GRID_COLS; col++) {
    panelGrid[row][col] = new JPanel(new GridBagLayout());
    backingPanel.add(panelGrid[row][col]);
redLabel.setOpaque(true);
redLabel.setBackground(Color.red.brighter().brighter());
redLabel.setPreferredSize(LABEL_SIZE);
panelGrid[4][3].add(redLabel);
panelGrid[1][1].add(blueLabel);
add(backingPanel, JLayeredPane.DEFAULT_LAYER);
MyMouseAdapter myMouseAdapter = new MyMouseAdapter();
addMouseListener(myMouseAdapter);
  clickedPanel = (JPanel) backingPanel.getComponentAt(me.getPoint());
  Component[] components = clickedPanel.getComponents();
  if (components.length == 0) {
    return;
    clickedPanel.remove(dragLabel);
    add(dragLabel, JLayeredPane.DRAG_LAYER);
  remove(dragLabel); // remove dragLabel for drag layer of JLayeredPane
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));
JButton start = new JButton("Start");
start.setToolTipText("Click to use library");
submitPanel.add(start);
frame.getContentPane().add(heroShotPanel, BorderLayout.NORTH);
frame.getContentPane().add(submitPanel, BorderLayout.SOUTH);
frame.setVisible(true);
frame.getRootPane().setDefaultButton(start);
start.requestFocus();
origin: stackoverflow.com

 component.getWidth(),
 component.getHeight(),
 BufferedImage.TYPE_INT_RGB
 );
component.paint( image.getGraphics() ); // alternately use .printAll(..)
return image;
Runnable r = new Runnable() {
 public void run() {
  final JFrame f = new JFrame("Test Screenshot");
    public void actionPerformed(ActionEvent ae) {
     BufferedImage img = getScreenShot(
      f.getContentPane() );
     JOptionPane.showMessageDialog(
      null,
  JMenuBar mb = new JMenuBar();
  mb.add(menu);
  f.setJMenuBar(mb);
  JPanel p = new JPanel( new BorderLayout(5,5) );
  p.setBorder( new TitledBorder("Main GUI") );
  p.add( new JScrollPane(new JTree()),
   BorderLayout.WEST );
  p.add( new JScrollPane( new JTextArea(HELP,10,30) ),
   BorderLayout.CENTER );
origin: stackoverflow.com

l.setBorder(new LineBorder(Color.RED, 2));
return l;
    JPanel border = new JPanel(new BorderLayout());
    border.add(getLabel(
      "Border", SwingConstants.CENTER), BorderLayout.CENTER);
    p.add(border);
    JPanel gridbag = new JPanel(new GridBagLayout());
    gridbag.add(getLabel("GridBag"));
    p.add(gridbag);
    JPanel grid = new JPanel(new GridLayout());
    grid.add(getLabel("Grid", SwingConstants.CENTER));
    p.add(grid);
    JPanel box = new JPanel();
    box.setLayout(new BoxLayout(box, BoxLayout.X_AXIS ));
    box.add(Box.createHorizontalGlue());
    box.add(getLabel("Box"));
    box.add(Box.createHorizontalGlue());
    p.add(box);
origin: stackoverflow.com

private JPanel panel = new JPanel();
private JScrollPane sp = new JScrollPane(panel);
  panel.add(new JLabel(name, JLabel.LEFT));
  panel.add(jtf);
  list.add(jtf);
  panel.setLayout(new GridLayout(0, 1));
  addField("First Name:");
  addField("Last Name:");
  sp.validate();
  Dimension d = sp.getPreferredSize();
  d.setSize(d.width, d.height / 2);
  sp.setPreferredSize(d);
  internaFrame.add(sp);
  internaFrame.pack();
  internaFrame.setVisible(true);
  desktopPane.add(internaFrame);
  JFrame frmtest = new JFrame();
  frmtest.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frmtest.add(desktopPane);
  frmtest.pack();
origin: stackoverflow.com

setLayout(new BorderLayout());
JPanel jp = new JPanel();
jp.setLayout(new BorderLayout());
JTabbedPane tb = new JTabbedPane();
tb.setUI(new CustomTabbedPaneUI());
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

 @Override
 public void run() {
  JFrame testFrame = new JFrame( "FormattedTextFieldDemo" );
  integerFormattedTextField.setColumns( 20 );
  testFrame.add( createButtonPanel( integerFormattedTextField ), BorderLayout.NORTH );
  integerFormattedTextField.addPropertyChangeListener( "value", updateTextAreaListener );
  testFrame.add( new JScrollPane( textArea ), BorderLayout.CENTER );
  testFrame.setDefaultCloseOperation( WindowConstants.DISPOSE_ON_CLOSE );
  testFrame.pack();
  testFrame.setVisible( true );
JPanel panel = new JPanel( new BorderLayout(  ) );
panel.add( aTextField, BorderLayout.WEST );
  aTextField.addPropertyChangeListener( "editValid", new PropertyChangeListener() {
   @Override
   public void propertyChange( PropertyChangeEvent evt ) {
panel.add( new JButton( action ), BorderLayout.EAST );
return panel;
origin: stackoverflow.com

JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.add(new MainPanel());
f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true);
Control control = new Control(model, view);
JLabel label = new JLabel("Guess what color!", JLabel.CENTER);
this.add(label, BorderLayout.NORTH);
this.add(view, BorderLayout.CENTER);
this.add(control, BorderLayout.SOUTH);
this.add(reset);
reset.addActionListener(new ButtonHandler());
label.setVerticalTextPosition(JLabel.BOTTOM);
label.setHorizontalTextPosition(JLabel.CENTER);
this.add(label, BorderLayout.CENTER);
this.add(genButtonPanel(), BorderLayout.SOUTH);
model.addObserver(new ModelObserver());
JPanel panel = new JPanel();
for (Piece p : Piece.values()) {
  PieceButton pb = new PieceButton(p);
  pb.addActionListener(new ButtonHandler());
  panel.add(pb);
java.awtContainer

Javadoc

A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT components.

Components added to a container are tracked in a list. The order of the list will define the components' front-to-back stacking order within the container. If no index is specified when adding a component to a container, it will be added to the end of the list (and hence to the bottom of the stacking order).

Most used methods

  • add
    Adds the specified component to this container. This is a convenience method for #addImpl. This meth
  • setLayout
    Sets the layout manager for this container.
  • getComponents
    Gets all the components in this container.
  • getComponent
    Gets the nth component in this container.
  • getParent
  • getComponentCount
    Gets the number of components in this panel.
  • remove
    Removes the specified component from this container.
  • getWidth
  • getInsets
    Determines the insets of this container, which indicate the size of the container's border. A Frame
  • getSize
  • getHeight
  • repaint
  • getHeight,
  • repaint,
  • setBackground,
  • getLayout,
  • validate,
  • getTreeLock,
  • removeAll,
  • getPreferredSize,
  • getBackground,
  • getBounds

Popular in Java

  • Parsing JSON documents to java classes using gson
  • setRequestProperty (URLConnection)
  • findViewById (Activity)
  • notifyDataSetChanged (ArrayAdapter)
  • 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
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • Color (java.awt)
    The Color class is used to encapsulate colors in the default sRGB color space or colors in arbitrary
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • Pattern (java.util.regex)
    Patterns are compiled regular expressions. In many cases, convenience methods such as String#matches
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • 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