Re: Cannot divide into an 1:2 fashion by GridBagLayout
From: fix (fix_at_here.com)
Date: 11/13/03
- Next message: A. Bolmarcich: "Re: Cannot divide into an 1:2 fashion by GridBagLayout"
- Previous message: Gerbrand van Dieijen: "Re: check input in JTextField"
- In reply to: A. Bolmarcich: "Re: Cannot divide into an 1:2 fashion by GridBagLayout"
- Next in thread: A. Bolmarcich: "Re: Cannot divide into an 1:2 fashion by GridBagLayout"
- Reply: A. Bolmarcich: "Re: Cannot divide into an 1:2 fashion by GridBagLayout"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 13 Nov 2003 10:43:25 -0600
> It looks as if you are trying to compile TableLayout.java.
I wrote a small program called TableLayout.java to test the
functionality of the table layout.
> Extracting
> the files from TableLayout.jar will create a subdirectory named
> "layout". You want to use a command like "javac layout/TableLayout.java"
> in the directory in which you extracted the files from the jar.
> To compile a program that uses table layout, add TableLayout.jar to
> the CLASSPATH.
So that is not in the standard library? That's why I can't find it in
the doc. How can I write a program with this package?
I copied the program from
http://java.sun.com/products/jfc/tsc/articles/tablelayout/javadoc/layout/TableLayout.html
but it doesn't work, the error message is:
Exception in thread "main" java.lang.NoClassDefFoundError: tl
my code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import layout.TableLayout;
public class tl {
public static void main (String args[])
{
// Create a frame
Frame frame = new Frame("Example of TableLayout");
frame.setBounds (100, 100, 300, 300);
// Create a TableLayout for the frame
double border = 10;
double size[][] =
{{border, 0.10, 20, TableLayout.FILL, 20, 0.20, border}, //
Columns
{border, 0.20, 20, TableLayout.FILL, 20, 0.20, border}}; // Rows
frame.setLayout (new TableLayout(size));
// Create some buttons
String label[] = {"Top", "Bottom", "Left", "Right", "Center",
"Overlap"};
Button button[] = new Button[label.length];
for (int i = 0; i < label.length; i++)
button[i] = new Button(label[i]);
// Add buttons
frame.add (button[0], "1, 1, 5, 1"); // Top
frame.add (button[1], "1, 5, 5, 5"); // Bottom
frame.add (button[2], "1, 3 "); // Left
frame.add (button[3], "5, 3 "); // Right
frame.add (button[4], "3, 3, c, c"); // Center
frame.add (button[5], "3, 3, 3, 5"); // Overlap
// Allow user to close the window to terminate the program
frame.addWindowListener
(new WindowListener()
{
public void windowClosing (WindowEvent e)
{
System.exit (0);
}
public void windowOpened (WindowEvent e) {}
public void windowClosed (WindowEvent e) {}
public void windowIconified (WindowEvent e) {}
public void windowDeiconified (WindowEvent e) {}
public void windowActivated (WindowEvent e) {}
public void windowDeactivated (WindowEvent e) {}
}
);
// Show frame
frame.show();
}
}
Thanks a lot!
- Next message: A. Bolmarcich: "Re: Cannot divide into an 1:2 fashion by GridBagLayout"
- Previous message: Gerbrand van Dieijen: "Re: check input in JTextField"
- In reply to: A. Bolmarcich: "Re: Cannot divide into an 1:2 fashion by GridBagLayout"
- Next in thread: A. Bolmarcich: "Re: Cannot divide into an 1:2 fashion by GridBagLayout"
- Reply: A. Bolmarcich: "Re: Cannot divide into an 1:2 fashion by GridBagLayout"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]