Two Laptop Bag
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 Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "border layout" Watch "border layout" New topic

border layout

jason gass

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();

// 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"));

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();
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) ;

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


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

//WindowListener Interface
public void windowClosing(WindowEvent e) {
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

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.

Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: border layout
jQuery in Action, 3rd edition