- 论坛徽章:
- 0
|
mport java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class FlowLayoutdemo extends JFrame implements ActionListener
{
private JButton leftButton,centerButton,lightButton;
private Container container;
private FlowLayout layout;
public FlowLayoutdemo()
{
super("FlowLayoutDemo");
layout=new FlowLayout();
container=getContentPane();
container.setLayout(layout);
leftButton=new JButton("leftButton");
leftButton.addActionListener( new ActionListener()
{
public void actionPerformed(ActionEvevt event)
{
layout.setAlignment(FlowLayout.LEFT);
layout.layoutContainer(container);
}
}
);
container.add(leftButton);
setSize(300,75);
setVisible(true);
}
public static void main (String args[])
{
FlowLayoutdemo application=new FlowLayoutdemo();
application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
} |
|