jQuery in Action, 2nd edition*
The moose likes Swing / AWT / SWT and the fly likes border layout Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "border layout" Watch "border layout" New topic
Author

border layout

jason gass
Greenhorn

Joined: Nov 11, 2004
Posts: 13
Hey Everyone,
Im a newbie in Java. I am trying to create a spreadsheet. Could somone help me? I am trying to get my labels to work properly on the top and side of a grid but I can not get the spacing right

/*
*
* GridBagLayout layout manager
*/

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

public class GridBagLayoutTest extends Frame
implements WindowListener {


public GridBagLayoutTest() {

super("GridBagLayout Test");

MenuBar mybar = new MenuBar();
setMenuBar(mybar);

// and some menus

Menu f_menu = new Menu("File");
f_menu.add(new MenuItem("Open"));
f_menu.add(new MenuItem("Save"));
f_menu.add(new MenuItem("Exit"));
mybar.add(f_menu);



Panel buttonPanel = new Panel ( );
buttonPanel.setLayout (new GridLayout (10, 10, 1, 1) );
for (int i = 1; i<=100; i++)
buttonPanel.add (new TextField(i + "") );



Panel centerPanel =new Panel();
centerPanel.add(buttonPanel);
add ("Center", centerPanel) ;

Panel bottomPanel = new Panel ( );
bottomPanel.add ( new Button("Dial") );
add ("South", bottomPanel) ;


Panel northPanel = new Panel ( );
northPanel.setLayout (new GridLayout (0, 10, 1, 1) );
for (int i = 1; i<=10; i++)
northPanel.add(new Label(i+""));
add ("North", northPanel) ;



Panel eastPanel = new Panel ( );
eastPanel.setLayout (new GridLayout (10, 1, 1, 1) );

add ("East", eastPanel) ;


Panel westPanel = new Panel ( );
westPanel.setLayout (new GridLayout (10, 1, 1, 1) );
for (int i = 1; i<=10; i++)
westPanel.add(new Label(i+""));
add ("West", westPanel) ;

addWindowListener(this);
GridBagLayout gridbag = new GridBagLayout();
GridBagConstraints constraints = new GridBagConstraints();


pack();
setBackground(SystemColor.control);
setVisible(true);
}

public static void main(String args[]) {
new GridBagLayoutTest();
}

//WindowListener Interface
public void windowClosing(WindowEvent e) {
dispose();
System.exit(0);
}
public void windowOpened(WindowEvent e) {}
public void windowActivated(WindowEvent e) {}
public void windowDeactivated(WindowEvent e) {}
public void windowIconified(WindowEvent e) {}
public void windowDeiconified(WindowEvent e) {}
public void windowClosed(WindowEvent e) {}

}
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
nothing to do with a gridbag, but see if this is a bit closer to what you want

Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
jason gass
Greenhorn

Joined: Nov 11, 2004
Posts: 13
Hey Thanks,
Thats what I was trying for. Which forum do I go to asking about programming the background on this? I want to be able to have a text box in which i can put C1=A1+B1, but im unsure on to reference the cells.

Thanks again, Im back off to try to get this to work.

Jason
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: border layout
 
Similar Threads
converting program
Multiple controls in a panel
Problems creating a new frame
refresh JPanel containing JTable
how to convert a light-weight into a heavy-weight component?