Layout problem driving me insane - panels, resizing, etc  
Author Message
IchBin





PostPosted: 2006-6-14 8:27:00 Top

java-programmer, Layout problem driving me insane - panels, resizing, etc IchBin wrote:
> email***@***.com wrote:
>>> Get NetBeans. (Get the latest one, 5.5) You don't need any plugins,
>>> everything is there for you already. Go through the tutorial below,
>>> it'll take about 30 minutes. If your eyes don't pop out of your head
>>> like Rodger Rabbit, then you can safely ignore it.
>>>
>>> http://www.netbeans.org/kb/50/quickstart-gui.html
>>
>> 60 MB - yikes. I'll download it tonight and play with it a little
>> bit... and also try all the other suggestions. I'll try and post my
>> conclusions tomorrow.
>>

[snip]

Just looked at the code again. It's ok but wanted to slim it down one
more time..

import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.ListSelectionModel;
import javax.swing.SwingUtilities;

import com.jgoodies.forms.builder.DefaultFormBuilder;
import com.jgoodies.forms.debug.FormDebugPanel;
import com.jgoodies.forms.debug.FormDebugUtils;
import com.jgoodies.forms.factories.ButtonBarFactory;
import com.jgoodies.forms.layout.FormLayout;

public class LayoutProblem implements ActionListener
{
public static void main(String[] args)
{
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
new LayoutProblem();
}
});
}
public LayoutProblem()
{
jFrame.setDefaultCloseOperation(jFrame.EXIT_ON_CLOSE);
jFrame.add(buildMainPanel());
jFrame.setPreferredSize(new Dimension(475,600));
jFrame.pack();
jFrame.setVisible(true);
}
private JPanel buildMainPanel()
{
FormLayout layout = new FormLayout (
/* Columns */ "default:grow",
/* Rows */ "pref, 12dlu, fill:0:grow(0.50), 20dlu,
fill:0:grow(0.50)"
);
DefaultFormBuilder builder = DEBUGMODE
? new DefaultFormBuilder(layout,new FormDebugPanel())
: new DefaultFormBuilder(layout);

builder.setDefaultDialogBorder();
builder.nextLine(2);
builder.append(buildControl(jTable));
builder.append(buildButtonBar());
builder.append(buildControl(jTextArea));

if (DEBUGMODE)
{
FormDebugUtils.dumpAll(builder.getPanel());
}
return builder.getPanel();
}
private JComponent buildButtonBar()
{
JPanel jPanel = new JPanel();
jPanel = ButtonBarFactory.buildCenteredBar(
buildControl(BUTTON1),
buildControl(BUTTON2),
buildControl(BUTTON3),
buildControl(TEXT_EXIT));
jPanel.setBorder(BorderFactory.createRaisedBevelBorder());
return jPanel;
}
private JButton buildControl(String labelText)
{
jButton = new JButton(labelText);
jButton.addActionListener(this);
return jButton;
}
private JComponent buildControl(JTable jTable)
{
jTable = new JTable(dataValues, columnNames);
JScrollPane scrollPane = new JScrollPane(jTable);
jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
return scrollPane;
}
private JComponent buildControl(JTextArea jTextArea)
{
jTextArea = new JTextArea(logAreaHdr);
JScrollPane scrollPane = new JScrollPane(jTextArea );
return scrollPane;
}
public void actionPerformed(ActionEvent e)
{
final String method = "jBotton_actionPerformed(ActionEvent " +
e + "): ";
if (DEBUGMODE)
{
System.out.println(DEBUGHEATER + method);
}

if (BUTTON1.equals(e.getActionCommand()))
{
}
else if (BUTTON2.equals(e.getActionCommand()))
{
}
else if (BUTTON3.equals(e.getActionCommand()))
{
}
else if (TEXT_EXIT.equals(e.getActionCommand()))
{
System.exit(0);
}
}

private static final String PROGRAM = (((new
Throwable()).getStackTrace())[0].getClassName())+".";
private static final String DEBUGHEATER = "( DEBUG ) " + PROGRAM;
private static final boolean DEBUGMODE = false;

private JFrame jFrame = new JFrame("JGoodies
Forms Layout Demo");
private JTable jTable;
private JTextArea jTextArea;
private JButton jButton;

private final String BUTTON1 = "Button 1";
private final String BUTTON2 = "Button 2";
private final String BUTTON3 = "Button 3";
private final String TEXT_EXIT = "EXIT";
private final String logAreaHdr =
"---------------------------\n---------------------------\n---------------------------\n";

private final String columnNames[] = {"Column 1", "Column
2", "Column 3"};
private String dataValues[][] = {
{"0aa", "bbb", "ccc"},
{"0dd", "eee", "fff"},
{"0gg", "hhh", "iii"},
{"1aa", "bbb", "ccc"},
{"1dd", "eee", "fff"},
{"1gg", "hhh", "iii"},
{"2aa", "bbb", "ccc"},
{"2dd", "eee", "fff"},
{"2gg", "hhh", "iii"},
{"3aa", "bbb", "ccc"},
{"3dd", "eee", "fff"},
{"3gg", "hhh", "iii"},
{"4aa", "bbb", "ccc"},
{"4dd", "eee", "fff"},
{"4gg", "hhh", "iii"},
{"5aa", "bbb", "ccc"},
{"5dd", "eee", "fff"},
{"5gg", "hhh", "iii"},
{"6aa", "bbb", "ccc"},
{"6dd", "eee", "fff"},
{"6gg", "hhh", "iii"},
{"7aa", "bbb", "ccc"},
{"7dd", "eee", "fff"},
{"7gg", "hhh", "iii"},
{"8aa", "bbb", "ccc"},
{"8dd", "eee", "fff"},
{"8gg", "hhh", "iii"},
{"9aa", "bbb", "ccc"},
{"9dd", "eee", "fff"},
{"9gg", "hhh", "iii"},
{"aaa", "bbb", "ccc"},
{"ddd", "eee", "fff"},
{"ggg", "hhh", "iii"},};
}

--

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
 
IchBin





PostPosted: 2006-6-14 8:27:00 Top

java-programmer >> Layout problem driving me insane - panels, resizing, etc IchBin wrote:
> email***@***.com wrote:
>>> Get NetBeans. (Get the latest one, 5.5) You don't need any plugins,
>>> everything is there for you already. Go through the tutorial below,
>>> it'll take about 30 minutes. If your eyes don't pop out of your head
>>> like Rodger Rabbit, then you can safely ignore it.
>>>
>>> http://www.netbeans.org/kb/50/quickstart-gui.html
>>
>> 60 MB - yikes. I'll download it tonight and play with it a little
>> bit... and also try all the other suggestions. I'll try and post my
>> conclusions tomorrow.
>>

[snip]

Just looked at the code again. It's ok but wanted to slim it down one
more time..

import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.ListSelectionModel;
import javax.swing.SwingUtilities;

import com.jgoodies.forms.builder.DefaultFormBuilder;
import com.jgoodies.forms.debug.FormDebugPanel;
import com.jgoodies.forms.debug.FormDebugUtils;
import com.jgoodies.forms.factories.ButtonBarFactory;
import com.jgoodies.forms.layout.FormLayout;

public class LayoutProblem implements ActionListener
{
public static void main(String[] args)
{
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
new LayoutProblem();
}
});
}
public LayoutProblem()
{
jFrame.setDefaultCloseOperation(jFrame.EXIT_ON_CLOSE);
jFrame.add(buildMainPanel());
jFrame.setPreferredSize(new Dimension(475,600));
jFrame.pack();
jFrame.setVisible(true);
}
private JPanel buildMainPanel()
{
FormLayout layout = new FormLayout (
/* Columns */ "default:grow",
/* Rows */ "pref, 12dlu, fill:0:grow(0.50), 20dlu,
fill:0:grow(0.50)"
);
DefaultFormBuilder builder = DEBUGMODE
? new DefaultFormBuilder(layout,new FormDebugPanel())
: new DefaultFormBuilder(layout);

builder.setDefaultDialogBorder();
builder.nextLine(2);
builder.append(buildControl(jTable));
builder.append(buildButtonBar());
builder.append(buildControl(jTextArea));

if (DEBUGMODE)
{
FormDebugUtils.dumpAll(builder.getPanel());
}
return builder.getPanel();
}
private JComponent buildButtonBar()
{
JPanel jPanel = new JPanel();
jPanel = ButtonBarFactory.buildCenteredBar(
buildControl(BUTTON1),
buildControl(BUTTON2),
buildControl(BUTTON3),
buildControl(TEXT_EXIT));
jPanel.setBorder(BorderFactory.createRaisedBevelBorder());
return jPanel;
}
private JButton buildControl(String labelText)
{
jButton = new JButton(labelText);
jButton.addActionListener(this);
return jButton;
}
private JComponent buildControl(JTable jTable)
{
jTable = new JTable(dataValues, columnNames);
JScrollPane scrollPane = new JScrollPane(jTable);
jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
return scrollPane;
}
private JComponent buildControl(JTextArea jTextArea)
{
jTextArea = new JTextArea(logAreaHdr);
JScrollPane scrollPane = new JScrollPane(jTextArea );
return scrollPane;
}
public void actionPerformed(ActionEvent e)
{
final String method = "jBotton_actionPerformed(ActionEvent " +
e + "): ";
if (DEBUGMODE)
{
System.out.println(DEBUGHEATER + method);
}

if (BUTTON1.equals(e.getActionCommand()))
{
}
else if (BUTTON2.equals(e.getActionCommand()))
{
}
else if (BUTTON3.equals(e.getActionCommand()))
{
}
else if (TEXT_EXIT.equals(e.getActionCommand()))
{
System.exit(0);
}
}

private static final String PROGRAM = (((new
Throwable()).getStackTrace())[0].getClassName())+".";
private static final String DEBUGHEATER = "( DEBUG ) " + PROGRAM;
private static final boolean DEBUGMODE = false;

private JFrame jFrame = new JFrame("JGoodies
Forms Layout Demo");
private JTable jTable;
private JTextArea jTextArea;
private JButton jButton;

private final String BUTTON1 = "Button 1";
private final String BUTTON2 = "Button 2";
private final String BUTTON3 = "Button 3";
private final String TEXT_EXIT = "EXIT";
private final String logAreaHdr =
"---------------------------\n---------------------------\n---------------------------\n";

private final String columnNames[] = {"Column 1", "Column
2", "Column 3"};
private String dataValues[][] = {
{"0aa", "bbb", "ccc"},
{"0dd", "eee", "fff"},
{"0gg", "hhh", "iii"},
{"1aa", "bbb", "ccc"},
{"1dd", "eee", "fff"},
{"1gg", "hhh", "iii"},
{"2aa", "bbb", "ccc"},
{"2dd", "eee", "fff"},
{"2gg", "hhh", "iii"},
{"3aa", "bbb", "ccc"},
{"3dd", "eee", "fff"},
{"3gg", "hhh", "iii"},
{"4aa", "bbb", "ccc"},
{"4dd", "eee", "fff"},
{"4gg", "hhh", "iii"},
{"5aa", "bbb", "ccc"},
{"5dd", "eee", "fff"},
{"5gg", "hhh", "iii"},
{"6aa", "bbb", "ccc"},
{"6dd", "eee", "fff"},
{"6gg", "hhh", "iii"},
{"7aa", "bbb", "ccc"},
{"7dd", "eee", "fff"},
{"7gg", "hhh", "iii"},
{"8aa", "bbb", "ccc"},
{"8dd", "eee", "fff"},
{"8gg", "hhh", "iii"},
{"9aa", "bbb", "ccc"},
{"9dd", "eee", "fff"},
{"9gg", "hhh", "iii"},
{"aaa", "bbb", "ccc"},
{"ddd", "eee", "fff"},
{"ggg", "hhh", "iii"},};
}

--

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
 
IchBin





PostPosted: 2006-6-14 9:58:00 Top

java-programmer >> Layout problem driving me insane - panels, resizing, etc IchBin wrote:
> email***@***.com wrote:
>>> Get NetBeans. (Get the latest one, 5.5) You don't need any plugins,
>>> everything is there for you already. Go through the tutorial below,
>>> it'll take about 30 minutes. If your eyes don't pop out of your head
>>> like Rodger Rabbit, then you can safely ignore it.
>>>
>>> http://www.netbeans.org/kb/50/quickstart-gui.html
>>
>> 60 MB - yikes. I'll download it tonight and play with it a little
>> bit... and also try all the other suggestions. I'll try and post my
>> conclusions tomorrow.
>>
>> Again: Thanks, everybody!
>>
>
> No the actual JGoodies Forms Library (forms-1.0.6.jar) is only *48kb*.
>
> The complete Forms zip download, from
> http://www.jgoodies.com/downloads/libraries.html, is only *1.1MB*.
>
> Also the last example, using gridbag from Steve, is still doing what
> Oliver did earlier today in his example.. That is, not expanding left to
> right and no 50% growth for the JTextArea and JTable each.

[snip]

Just looked at the code again. It's ok but wanted to slim it down one
more time..

import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.ListSelectionModel;
import javax.swing.SwingUtilities;

import com.jgoodies.forms.builder.DefaultFormBuilder;
import com.jgoodies.forms.debug.FormDebugPanel;
import com.jgoodies.forms.debug.FormDebugUtils;
import com.jgoodies.forms.factories.ButtonBarFactory;
import com.jgoodies.forms.layout.FormLayout;

public class LayoutProblem implements ActionListener
{
public static void main(String[] args)
{
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
System.out.println(PROGRAM);
new LayoutProblem();
}
});
}
public LayoutProblem()
{
jFrame.setDefaultCloseOperation(jFrame.EXIT_ON_CLOSE);
jFrame.add(buildMainPanel());
jFrame.setPreferredSize(new Dimension(475,600));
jFrame.pack();
jFrame.setVisible(true);
}
private JComponent buildMainPanel()
{
FormLayout layout = new FormLayout (
/* Columns */ "default:grow",
/* Rows */ "fill:0:grow(0.50), 20dlu, fill:0:grow(0.50)"
);
DefaultFormBuilder builder = DEBUGMODE
? new DefaultFormBuilder(layout,new FormDebugPanel())
: new DefaultFormBuilder(layout);

builder.setDefaultDialogBorder();
builder.append(buildControl(jTable));
builder.append(buildButtonBar());
builder.append(buildControl(jTextArea));

if (DEBUGMODE)
{
FormDebugUtils.dumpAll(builder.getPanel());
}
return builder.getPanel();
}
private JComponent buildButtonBar()
{
JPanel jPanel = new JPanel();
jPanel = ButtonBarFactory.buildCenteredBar(
buildControl(BUTTON1),
buildControl(BUTTON2),
buildControl(BUTTON3),
buildControl(TEXT_EXIT));
jPanel.setBorder(BorderFactory.createRaisedBevelBorder());
return jPanel;
}
private JButton buildControl(String labelText)
{
jButton = new JButton(labelText);
jButton.addActionListener(this);
return jButton;
}
private JComponent buildControl(JTable jTable)
{
jTable = new JTable(dataValues, columnNames);
JScrollPane scrollPane = new JScrollPane(jTable);
jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
return scrollPane;
}
private JComponent buildControl(JTextArea jTextArea)
{
jTextArea = new JTextArea(logAreaHdr);
JScrollPane scrollPane = new JScrollPane(jTextArea );
return scrollPane;
}
public void actionPerformed(ActionEvent e)
{
final String method = "jBotton_actionPerformed(ActionEvent " +
e + "): ";
if (DEBUGMODE)
{
System.out.println(DEBUGHEATER + method);
}

if (BUTTON1.equals(e.getActionCommand()))
{
}
else if (BUTTON2.equals(e.getActionCommand()))
{
}
else if (BUTTON3.equals(e.getActionCommand()))
{
}
else if (TEXT_EXIT.equals(e.getActionCommand()))
{
System.exit(0);
}
}

private static final String PROGRAM = (((new
Throwable()).getStackTrace())[0].getClassName())+".";
private static final String DEBUGHEATER = "( DEBUG ) " + PROGRAM;
private static final boolean DEBUGMODE = false;

private JFrame jFrame = new JFrame("JGoodies
Forms Layout Demo");
private JTable jTable;
private JTextArea jTextArea;
private JButton jButton;

private final String BUTTON1 = "Button 1";
private final String BUTTON2 = "Button 2";
private final String BUTTON3 = "Button 3";
private final String TEXT_EXIT = "EXIT";
private final String logAreaHdr =
"---------------------------\n---------------------------\n---------------------------\n";

private final String columnNames[] = {"Column 1", "Column
2", "Column 3"};
private String dataValues[][] = {
{"0aa", "bbb", "ccc"},
{"0dd", "eee", "fff"},
{"0gg", "hhh", "iii"},
{"1aa", "bbb", "ccc"},
{"1dd", "eee", "fff"},
{"1gg", "hhh", "iii"},
{"2aa", "bbb", "ccc"},
{"2dd", "eee", "fff"},
{"2gg", "hhh", "iii"},
{"3aa", "bbb", "ccc"},
{"3dd", "eee", "fff"},
{"3gg", "hhh", "iii"},
{"4aa", "bbb", "ccc"},
{"4dd", "eee", "fff"},
{"4gg", "hhh", "iii"},
{"5aa", "bbb", "ccc"},
{"5dd", "eee", "fff"},
{"5gg", "hhh", "iii"},
{"6aa", "bbb", "ccc"},
{"6dd", "eee", "fff"},
{"6gg", "hhh", "iii"},
{"7aa", "bbb", "ccc"},
{"7dd", "eee", "fff"},
{"7gg", "hhh", "iii"},
{"8aa", "bbb", "ccc"},
{"8dd", "eee", "fff"},
{"8gg", "hhh", "iii"},
{"9aa", "bbb", "ccc"},
{"9dd", "eee", "fff"},
{"9gg", "hhh", "iii"},
{"aaa", "bbb", "ccc"},
{"ddd", "eee", "fff"},
{"ggg", "hhh", "iii"},};
}

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
 
 
IchBin





PostPosted: 2006-6-14 10:21:00 Top

java-programmer >> Layout problem driving me insane - panels, resizing, etc IchBin wrote:
> email***@***.com wrote:
>>> Get NetBeans. (Get the latest one, 5.5) You don't need any plugins,
>>> everything is there for you already. Go through the tutorial below,
>>> it'll take about 30 minutes. If your eyes don't pop out of your head
>>> like Rodger Rabbit, then you can safely ignore it.
>>>
>>> http://www.netbeans.org/kb/50/quickstart-gui.html
>>
>> 60 MB - yikes. I'll download it tonight and play with it a little
>> bit... and also try all the other suggestions. I'll try and post my
>> conclusions tomorrow.
>>
>> Again: Thanks, everybody!
>>
>
> No the actual JGoodies Forms Library (forms-1.0.6.jar) is only *48kb*.
>
> The complete Forms zip download, from
> http://www.jgoodies.com/downloads/libraries.html, is only *1.1MB*.
>
> Also the last example, using gridbag from Steve, is still doing what
> Oliver did earlier today in his example.. That is, not expanding left to
> right and no 50% growth for the JTextArea and JTable each.
>

[snip]

Just looked at the code again. It's ok but wanted to slim it down one
more time..


import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.ListSelectionModel;
import javax.swing.SwingUtilities;

import com.jgoodies.forms.builder.DefaultFormBuilder;
import com.jgoodies.forms.debug.FormDebugPanel;
import com.jgoodies.forms.debug.FormDebugUtils;
import com.jgoodies.forms.factories.ButtonBarFactory;
import com.jgoodies.forms.layout.FormLayout;

public class LayoutProblem implements ActionListener
{
public static void main(String[] args)
{
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
new LayoutProblem();
}
});
}
public LayoutProblem()
{
jFrame.setDefaultCloseOperation(jFrame.EXIT_ON_CLOSE);
jFrame.add(buildMainPanel());
jFrame.setPreferredSize(new Dimension(475,600));
jFrame.pack();
jFrame.setVisible(true);
}
private JComponent buildMainPanel()
{
FormLayout layout = new FormLayout (
/* Columns */ "default:grow",
/* Rows */ "fill:0:grow(0.50), 20dlu, fill:0:grow(0.50)"
);
DefaultFormBuilder builder = DEBUGMODE
? new DefaultFormBuilder(layout,new FormDebugPanel())
: new DefaultFormBuilder(layout);

builder.setDefaultDialogBorder();
builder.append(buildControl(jTable));
builder.append(buildButtonBar());
builder.append(buildControl(jTextArea));

if (DEBUGMODE)
{
FormDebugUtils.dumpAll(builder.getPanel());
}
return builder.getPanel();
}
private JComponent buildButtonBar()
{
JPanel jPanel = new JPanel();
jPanel = ButtonBarFactory.buildCenteredBar(
buildControl(BUTTON1),
buildControl(BUTTON2),
buildControl(BUTTON3),
buildControl(TEXT_EXIT));
jPanel.setBorder(BorderFactory.createRaisedBevelBorder());
return jPanel;
}
private JButton buildControl(String labelText)
{
jButton = new JButton(labelText);
jButton.addActionListener(this);
return jButton;
}
private JComponent buildControl(JTable jTable)
{
jTable = new JTable(dataValues, columnNames);
jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
return new JScrollPane(jTable);
}
private JComponent buildControl(JTextArea jTextArea)
{
jTextArea = new JTextArea(logAreaHdr);
return new JScrollPane(jTextArea );
}
public void actionPerformed(ActionEvent e)
{
final String method = "jBotton_actionPerformed(ActionEvent " +
e + "): ";
if (DEBUGMODE)
{
System.out.println(DEBUGHEATER + method);
}

if (BUTTON1.equals(e.getActionCommand()))
{
}
else if (BUTTON2.equals(e.getActionCommand()))
{
}
else if (BUTTON3.equals(e.getActionCommand()))
{
}
else if (TEXT_EXIT.equals(e.getActionCommand()))
{
System.exit(0);
}
}

private static final String PROGRAM = (((new
Throwable()).getStackTrace())[0].getClassName())+".";
private static final String DEBUGHEATER = "( DEBUG ) " + PROGRAM;
private static final boolean DEBUGMODE = false;

private JFrame jFrame = new JFrame("JGoodies
Forms Layout Demo");
private JTable jTable;
private JTextArea jTextArea;
private JButton jButton;

private final String BUTTON1 = "Button 1";
private final String BUTTON2 = "Button 2";
private final String BUTTON3 = "Button 3";
private final String TEXT_EXIT = "EXIT";
private final String logAreaHdr =
"---------------------------\n---------------------------\n---------------------------\n";

private final String columnNames[] = {"Column 1", "Column
2", "Column 3"};
private String dataValues[][] = {
{"0aa", "bbb", "ccc"},
{"0dd", "eee", "fff"},
{"0gg", "hhh", "iii"},
{"1aa", "bbb", "ccc"},
{"1dd", "eee", "fff"},
{"1gg", "hhh", "iii"},
{"2aa", "bbb", "ccc"},
{"2dd", "eee", "fff"},
{"2gg", "hhh", "iii"},
{"3aa", "bbb", "ccc"},
{"3dd", "eee", "fff"},
{"3gg", "hhh", "iii"},
{"4aa", "bbb", "ccc"},
{"4dd", "eee", "fff"},
{"4gg", "hhh", "iii"},
{"5aa", "bbb", "ccc"},
{"5dd", "eee", "fff"},
{"5gg", "hhh", "iii"},
{"6aa", "bbb", "ccc"},
{"6dd", "eee", "fff"},
{"6gg", "hhh", "iii"},
{"7aa", "bbb", "ccc"},
{"7dd", "eee", "fff"},
{"7gg", "hhh", "iii"},
{"8aa", "bbb", "ccc"},
{"8dd", "eee", "fff"},
{"8gg", "hhh", "iii"},
{"9aa", "bbb", "ccc"},
{"9dd", "eee", "fff"},
{"9gg", "hhh", "iii"},
{"aaa", "bbb", "ccc"},
{"ddd", "eee", "fff"},
{"ggg", "hhh", "iii"},};
}

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
 
 
jackp





PostPosted: 2006-6-14 22:57:00 Top

java-programmer >> Layout problem driving me insane - panels, resizing, etc Karsten Lentzsch wrote:

> Right. I just like to add that there exist layout managers
> that handle huge classes of screen design, for example
> the ExplicitLayout, or even better the ExplicitLayout plus
> Explicit Table Builder.


Ladies and gentlemen, I do believe we have a winner.

import com.zookitec.layout.*;

import java.awt.*;
import javax.swing.*;
import javax.swing.table.*;

public class LayoutProblem extends JFrame {

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

String columnNames[] = { "Column 1", "Column 2", "Column 3" };
String dataValues[][] = {
{ "0aa","bbb","ccc"}, { "0dd","eee","fff"}, { "0gg","hhh","iii"},
{ "1aa","bbb","ccc"}, { "1dd","eee","fff"}, { "1gg","hhh","iii"},
{ "2aa","bbb","ccc"}, { "2dd","eee","fff"}, { "2gg","hhh","iii"},
{ "3aa","bbb","ccc"}, { "3dd","eee","fff"}, { "3gg","hhh","iii"},
{ "4aa","bbb","ccc"}, { "4dd","eee","fff"}, { "4gg","hhh","iii"},
{ "5aa","bbb","ccc"}, { "5dd","eee","fff"}, { "5gg","hhh","iii"},
{ "6aa","bbb","ccc"}, { "6dd","eee","fff"}, { "6gg","hhh","iii"},
{ "7aa","bbb","ccc"}, { "7dd","eee","fff"}, { "7gg","hhh","iii"},
{ "8aa","bbb","ccc"}, { "8dd","eee","fff"}, { "8gg","hhh","iii"},
{ "9aa","bbb","ccc"}, { "9dd","eee","fff"}, { "9gg","hhh","iii"},
{ "aaa","bbb","ccc"}, { "ddd","eee","fff"}, { "ggg","hhh","iii"},
};

public LayoutProblem() {

JTable table;
JButton button1, button2, button3, button4;
JTextArea logArea;

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

// table
table = new JTable(dataValues, columnNames);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
JScrollPane tableScrollPane = new JScrollPane(table);

// button panel
JPanel buttonPanel = new JPanel();
buttonPanel.setBorder(BorderFactory.createRaisedBevelBorder() );

SpringLayout buttonPanelLayout = new SpringLayout();
buttonPanel.setLayout(buttonPanelLayout);

final int PADDING = 6;

button1 = new JButton("Button 1");
buttonPanelLayout.putConstraint(SpringLayout.WEST, button1, PADDING,
SpringLayout.WEST, buttonPanel);
buttonPanelLayout.putConstraint(SpringLayout.NORTH, button1, PADDING,
SpringLayout.NORTH, buttonPanel);
buttonPanel.add(button1);

button2 = new JButton("Button 2");
buttonPanelLayout.putConstraint(SpringLayout.WEST, button2, PADDING,
SpringLayout.EAST, button1);
buttonPanelLayout.putConstraint(SpringLayout.NORTH, button2, PADDING,
SpringLayout.NORTH, buttonPanel);
buttonPanel.add(button2);

button3 = new JButton("Button 3");
buttonPanelLayout.putConstraint(SpringLayout.WEST, button3, PADDING,
SpringLayout.EAST, button2);
buttonPanelLayout.putConstraint(SpringLayout.NORTH, button3, PADDING,
SpringLayout.NORTH, buttonPanel);
buttonPanel.add(button3);

button4 = new JButton("Button 4");
buttonPanelLayout.putConstraint(SpringLayout.WEST, button4, PADDING,
SpringLayout.EAST, button3);
buttonPanelLayout.putConstraint(SpringLayout.NORTH, button4, PADDING,
SpringLayout.NORTH, buttonPanel);
buttonPanel.add(button4);

// text area
logArea = new JTextArea();
logArea.setText("---------------------------\n---------------------------\n?--------------------------\n");
JScrollPane logAreaScrollPane = new JScrollPane(logArea);

// and now, the magic begins
Container cont = getContentPane(); // for Java 1.4
cont.setLayout(new ExplicitLayout());

cont.add(buttonPanel, new ExplicitConstraints(
buttonPanel,
ContainerEF.centerX(cont),
ContainerEF.centerY(cont),
ContainerEF.width(cont),
MathEF.constant(40),
0.5, 0.5, true, true
));

cont.add(tableScrollPane, new ExplicitConstraints(
tableScrollPane,
ContainerEF.left(cont),
ContainerEF.top(cont),
ContainerEF.width(cont),
true,
MathEF.subtract(ComponentEF.top(buttonPanel), PADDING),
false
));

cont.add(logAreaScrollPane, new ExplicitConstraints(
logAreaScrollPane,
ContainerEF.left(cont),
MathEF.add(ComponentEF.bottom(buttonPanel), PADDING),
ContainerEF.width(cont),
true,
ContainerEF.bottom(cont),
false
));

pack();
setSize(450,600); // initial app size
setVisible(true);
}

}

This layout manager is exactly what I've been looking for - I don't
think I'll ever use gridbaglayout again. IchBin's JGoodies solution
looks great too, but since I already spent way too much time on this, I
wanted to go with a standalone, layout manager only solution - and
since IchBin's already solved the problem with JGoodies there wasn't
any more fun to be had that way.

I still need to install eclipse and look at SWT and netBeans, and
probably the other JGoodies, but it seems at least as far as layout
managers are concerned, I'm all set.

Again: Thanks, everybody.

 
 
IchBin





PostPosted: 2006-6-15 1:59:00 Top

java-programmer >> Layout problem driving me insane - panels, resizing, etc email***@***.com wrote:
> Karsten Lentzsch wrote:
>
>> Right. I just like to add that there exist layout managers
>> that handle huge classes of screen design, for example
>> the ExplicitLayout, or even better the ExplicitLayout plus
>> Explicit Table Builder.
>
>
> Ladies and gentlemen, I do believe we have a winner.
>
> import com.zookitec.layout.*;

[snip code]

>
> This layout manager is exactly what I've been looking for - I don't
> think I'll ever use gridbaglayout again. IchBin's JGoodies solution
> looks great too, but since I already spent way too much time on this, I
> wanted to go with a standalone, layout manager only solution - and
> since IchBin's already solved the problem with JGoodies there wasn't
> any more fun to be had that way.
>
> I still need to install eclipse and look at SWT and netBeans, and
> probably the other JGoodies, but it seems at least as far as layout
> managers are concerned, I'm all set.
>
> Again: Thanks, everybody.
>

Good, at least now you are all squared away. Funny, as it were, Karsten
Lentzsch, who recommended ExplicitLayout for a large amount of classes
in a screen design, is the developer and owner of JGoodies.

Sorry, I took the fun out of it for ya. I just wanted to give you a good
example of JGoodies and factories to work from now and in the future. I
still think that the actual code to do what you wanted was smaller than
the ExplicitLayout. For me, it actually only took 5 commands to lay it out.

Well, this is also for the benefit of anyone else looking at this thread
and the Forms from JGoodies...

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
 
 
steve





PostPosted: 2006-6-15 5:52:00 Top

java-programmer >> Layout problem driving me insane - panels, resizing, etc On Wed, 14 Jun 2006 22:57:10 +0800, email***@***.com wrote
(in article <email***@***.com>):

> Karsten Lentzsch wrote:
>
>> Right. I just like to add that there exist layout managers
>> that handle huge classes of screen design, for example
>> the ExplicitLayout, or even better the ExplicitLayout plus
>> Explicit Table Builder.
>
>
> Ladies and gentlemen, I do believe we have a winner.
>
> import com.zookitec.layout.*;
>
> import java.awt.*;
> import javax.swing.*;
> import javax.swing.table.*;
>
> public class LayoutProblem extends JFrame {
>
> public static void main(String[] args) {
> new LayoutProblem();
> }
>
> String columnNames[] = { "Column 1", "Column 2", "Column 3" };
> String dataValues[][] = {
> { "0aa","bbb","ccc"}, { "0dd","eee","fff"}, { "0gg","hhh","iii"},
> { "1aa","bbb","ccc"}, { "1dd","eee","fff"}, { "1gg","hhh","iii"},
> { "2aa","bbb","ccc"}, { "2dd","eee","fff"}, { "2gg","hhh","iii"},
> { "3aa","bbb","ccc"}, { "3dd","eee","fff"}, { "3gg","hhh","iii"},
> { "4aa","bbb","ccc"}, { "4dd","eee","fff"}, { "4gg","hhh","iii"},
> { "5aa","bbb","ccc"}, { "5dd","eee","fff"}, { "5gg","hhh","iii"},
> { "6aa","bbb","ccc"}, { "6dd","eee","fff"}, { "6gg","hhh","iii"},
> { "7aa","bbb","ccc"}, { "7dd","eee","fff"}, { "7gg","hhh","iii"},
> { "8aa","bbb","ccc"}, { "8dd","eee","fff"}, { "8gg","hhh","iii"},
> { "9aa","bbb","ccc"}, { "9dd","eee","fff"}, { "9gg","hhh","iii"},
> { "aaa","bbb","ccc"}, { "ddd","eee","fff"}, { "ggg","hhh","iii"},
> };
>
> public LayoutProblem() {
>
> JTable table;
> JButton button1, button2, button3, button4;
> JTextArea logArea;
>
> setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
>
> // table
> table = new JTable(dataValues, columnNames);
> table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
> JScrollPane tableScrollPane = new JScrollPane(table);
>
> // button panel
> JPanel buttonPanel = new JPanel();
> buttonPanel.setBorder(BorderFactory.createRaisedBevelBorder() );
>
> SpringLayout buttonPanelLayout = new SpringLayout();
> buttonPanel.setLayout(buttonPanelLayout);
>
> final int PADDING = 6;
>
> button1 = new JButton("Button 1");
> buttonPanelLayout.putConstraint(SpringLayout.WEST, button1, PADDING,
> SpringLayout.WEST, buttonPanel);
> buttonPanelLayout.putConstraint(SpringLayout.NORTH, button1, PADDING,
> SpringLayout.NORTH, buttonPanel);
> buttonPanel.add(button1);
>
> button2 = new JButton("Button 2");
> buttonPanelLayout.putConstraint(SpringLayout.WEST, button2, PADDING,
> SpringLayout.EAST, button1);
> buttonPanelLayout.putConstraint(SpringLayout.NORTH, button2, PADDING,
> SpringLayout.NORTH, buttonPanel);
> buttonPanel.add(button2);
>
> button3 = new JButton("Button 3");
> buttonPanelLayout.putConstraint(SpringLayout.WEST, button3, PADDING,
> SpringLayout.EAST, button2);
> buttonPanelLayout.putConstraint(SpringLayout.NORTH, button3, PADDING,
> SpringLayout.NORTH, buttonPanel);
> buttonPanel.add(button3);
>
> button4 = new JButton("Button 4");
> buttonPanelLayout.putConstraint(SpringLayout.WEST, button4, PADDING,
> SpringLayout.EAST, button3);
> buttonPanelLayout.putConstraint(SpringLayout.NORTH, button4, PADDING,
> SpringLayout.NORTH, buttonPanel);
> buttonPanel.add(button4);
>
> // text area
> logArea = new JTextArea();
>
logArea.setText("---------------------------\n---------------------------
\n? > ---------------------------\n");
> JScrollPane logAreaScrollPane = new JScrollPane(logArea);
>
> // and now, the magic begins
> Container cont = getContentPane(); // for Java 1.4
> cont.setLayout(new ExplicitLayout());
>
> cont.add(buttonPanel, new ExplicitConstraints(
> buttonPanel,
> ContainerEF.centerX(cont),
> ContainerEF.centerY(cont),
> ContainerEF.width(cont),
> MathEF.constant(40),
> 0.5, 0.5, true, true
> ));
>
> cont.add(tableScrollPane, new ExplicitConstraints(
> tableScrollPane,
> ContainerEF.left(cont),
> ContainerEF.top(cont),
> ContainerEF.width(cont),
> true,
> MathEF.subtract(ComponentEF.top(buttonPanel), PADDING),
> false
> ));
>
> cont.add(logAreaScrollPane, new ExplicitConstraints(
> logAreaScrollPane,
> ContainerEF.left(cont),
> MathEF.add(ComponentEF.bottom(buttonPanel), PADDING),
> ContainerEF.width(cont),
> true,
> ContainerEF.bottom(cont),
> false
> ));
>
> pack();
> setSize(450,600); // initial app size
> setVisible(true);
> }
>
> }
>
> This layout manager is exactly what I've been looking for - I don't
> think I'll ever use gridbaglayout again. IchBin's JGoodies solution
> looks great too, but since I already spent way too much time on this, I
> wanted to go with a standalone, layout manager only solution - and
> since IchBin's already solved the problem with JGoodies there wasn't
> any more fun to be had that way.
>
> I still need to install eclipse and look at SWT and netBeans, and
> probably the other JGoodies, but it seems at least as far as layout
> managers are concerned, I'm all set.
>
> Again: Thanks, everybody.
>

glad we could all help.
personally , I love GBL
but if you want to see why GBL sorts the men from the boys checkout:


http://madbean.com/blog/2004/17/totallygridbag.html

Steve


 
 
Karsten Lentzsch





PostPosted: 2006-6-15 15:28:00 Top

java-programmer >> Layout problem driving me insane - panels, resizing, etc steve wrote:

> glad we could all help.
> personally , I love GBL
> but if you want to see why GBL sorts the men from the boys checkout:

If you want to see what sorts men from men that
can compete with native application layout, see
http://tinyurl.com/ar5n5 and you may want to love
layout systems that can do more than the weak GBL ;-)

-Karsten