• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

border layout

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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) {}

}
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
nothing to do with a gridbag, but see if this is a bit closer to what you want

 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
jason gass
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
reply
    Bookmark Topic Watch Topic
  • New Topic