Java BorderLayout .removeLayoutComponent (Component comp)

Syntax

BorderLayout.removeLayoutComponent(Component comp) has the following syntax.

public void removeLayoutComponent(Component comp)

Example

In the following code shows how to use BorderLayout.removeLayoutComponent(Component comp) method.


/*from ww  w. j a v  a  2 s  .c  om*/
import java.awt.BorderLayout;

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

public class Main  extends JPanel {

  public Main() {

    JButton btn1 = new JButton("Button1");
    JButton btn2 = new JButton("Button2");
    JButton btn3 = new JButton("Button3");
    JButton btn4 = new JButton("Button4");
    JButton btn5 = new JButton("Button5");
    JButton btn6 = new JButton("Button6");

    BorderLayout borderLayout = new BorderLayout(20,30);
    
    setLayout(borderLayout);

    add("North", btn1);
    add("West", btn2);
    add("Center", btn3);
    add("South", btn5);
    add("East", btn6);

    borderLayout.removeLayoutComponent(btn1);
  }

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

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




















Home »
  Java Tutorial »
    java.awt »




BasicStroke
BorderLayout
CardLayout
Color
Cursor
Desktop
DesktopManager
DisplayMode
EventQueue
FlowLayout
FocusTraversalPolicy
Font
FontMetrics
GradientPaint
Graphics
Graphics2D
GraphicsConfiguration
GraphicsDevice
GraphicsEnvironment
GridBagConstraints
GridBagLayout
GridLayout
Image
ItemSelectable
KeyboardFocusManager
LayoutManager
LayoutManager2
Point
Rectangle
Robot
Shape
SplashScreen
SystemColor
SystemTray
TexturePaint
TrayIcon
Toolkit
Transparency