Professional Documents
Culture Documents
*;
import java.awt.event.ActionEvent;
import javax.swing.*;
import java.awt.Event.*;
import java.awt.event.ActionListener;
import javax.swing.event.*;
List sourceList;
List destinationList;
Button addButton;
Button addAllButton;
Button removeButton;
Button removeAllButton;
Button OKButton;
Button cancelButton;
Button closeButton;
Label sourceLabel;
Label destinationLabel;
Frame aFrame;
GridBagLayout gbl;
GridBagConstraints gbc;
public gbl1() {
sourceList = new List();
destinationList = new List();
addButton = new Button( " >" );
addAllButton = new Button( ">>" );
removeButton = new Button( " >" );
removeAllButton = new Button( ">>" );
OKButton = new Button( "Ok" );
cancelButton = new Button( "Cancel" );
closeButton = new Button( "close" );
closeButton.addActionListener(new ActionListener () {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
aFrame.setLayout( gbl );
buildFrame();
aFrame.setSize( 300,200 );
aFrame.show();
}
/**
* A helper method to add Components to a Container using
* GridBagLayout
*/
public void addComponent( int x, int y, int w, int h, Container aContainer,
Component aComponent ) {
gbc.gridx = x;
gbc.gridy = y;
gbc.gridwidth = w;
gbc.gridheight = h;
gbl.setConstraints( aComponent, gbc );
aContainer.add( aComponent );
}