layouts layouts layouts..  
Author Message
Frances





PostPosted: 2005-9-3 3:17:00 Top

java-programmer, layouts layouts layouts.. Andrew Thompson wrote:
> On Fri, 02 Sep 2005 12:09:47 -0400, Frances wrote:
>
> ..
>
>>>- Your button should occupate SOUTH (Looks like you want button to
>>>occupate all available place)
>>
>>no I don't!! that's just how it's coming out, can't figure out how to
>>control size for it (as I said, setSize() is being ignored..
>
>
> 'size' is often ignored, while prefered/minimum/maximum
> are more likely to be honored. Some layouts will ignore
> even the latter in some circumstances, especially like
> BorderLayout.CENTER.
>
>
>>..(I have been wondering, though, about BorderLayout, I
>>don't see WEST in yr post, I've been wondering if it's ok to use
>>BorderLayout if you don't fill all five "corners".. (NORTH, SOUTH,
>>CENTER, EAST, WEST..)
>
>
> Yes. BorderLayout allows 5 components, but can accept less.

great.. thank you Andrew, I really had been wondering about this...
again many thanks Andrew, to you and to all who responded... I got lots
to chew on here for the weekend now...
:)

 
Frances





PostPosted: 2005-9-3 3:17:00 Top

java-programmer >> layouts layouts layouts.. Andrew Thompson wrote:
> On Fri, 02 Sep 2005 12:09:47 -0400, Frances wrote:
>
> ..
>
>>>- Your button should occupate SOUTH (Looks like you want button to
>>>occupate all available place)
>>
>>no I don't!! that's just how it's coming out, can't figure out how to
>>control size for it (as I said, setSize() is being ignored..
>
>
> 'size' is often ignored, while prefered/minimum/maximum
> are more likely to be honored. Some layouts will ignore
> even the latter in some circumstances, especially like
> BorderLayout.CENTER.
>
>
>>..(I have been wondering, though, about BorderLayout, I
>>don't see WEST in yr post, I've been wondering if it's ok to use
>>BorderLayout if you don't fill all five "corners".. (NORTH, SOUTH,
>>CENTER, EAST, WEST..)
>
>
> Yes. BorderLayout allows 5 components, but can accept less.

great.. thank you Andrew, I really had been wondering about this...
again many thanks Andrew, to you and to all who responded... I got lots
to chew on here for the weekend now...
:)

 
Chris Smith





PostPosted: 2005-9-3 3:27:00 Top

java-programmer >> layouts layouts layouts.. Vova Reznik <email***@***.com> wrote:
> > JPanel buttonPanel = new JPanel();
> > buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
>
> FlowLayout is default layout for JPanel and CENTER is default constraint
> for FlowLayout

Yes. I set it explicitly in order to more easily point out the
possibility of changing the alignment.

> JButton will create preferred size for it self using its text and Icon
> and Insets (margin - default 2, 14, 2, 14)

The default Insets for a JButton are dependent on the look and feel.
Again, the preferred size depends on a lot of things.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
 
Chris Smith





PostPosted: 2005-9-3 3:28:00 Top

java-programmer >> layouts layouts layouts.. Thorsten Suckow-Homberg <email***@***.com> wrote:
> >[...]
>
> Gosh, do people like you even care about looking at the OP you are referring
> to?

Yes. What's your point?

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
 
Michael Dunn





PostPosted: 2005-9-3 4:04:00 Top

java-programmer >> layouts layouts layouts..
"Frances" <email***@***.com> wrote in message
news:431857b8$0$18641$email***@***.com...
>I know I have asked lot about this here, but I'm baffled by how hard this
>is.. I've been doing layouts w/HTML and css for years, and never have a
>problem getting my stuff to look exactly as I want it to, even complex
>layouts.. but Swing layouts is just a different league....;)
<snip>

as mentioned a few times, it's just an understanding of how the different
layout managers work,
recognizing the default managers for various containers and
combining/nesting them to get the
desired effect (i.e. lots of trial and error)

You sound like you're trying to understand this, rather than after a
handout, so here's the code
from your other post, modified to include the buttons and menu.
(I find it easier posting the code and having you work it out, rather than
trying to explain it all)

import javax.swing.*;
import java.awt.*;
class Testing extends JFrame
{
public Testing()
{
setSize(700,450);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setLocation(300,100);
JTextPane textAreaTop = new JTextPane();
JScrollPane scrollTop = new JScrollPane(textAreaTop,22,31);
JTextPane textAreaBottom = new JTextPane();
JScrollPane scrollBottom = new JScrollPane(textAreaBottom,22,31);
JSplitPane splitP = new
JSplitPane(JSplitPane.VERTICAL_SPLIT,scrollTop,scrollBottom);
splitP.setResizeWeight(0.65);

JPanel leftPanel = new JPanel(new BorderLayout());
JButton btnSend = new JButton("Send");
JPanel leftSouthPanel =new JPanel();
leftSouthPanel.add(btnSend);
leftPanel.add(splitP,BorderLayout.CENTER);
leftPanel.add(leftSouthPanel,BorderLayout.SOUTH);

JTextPane textAreaRight = new JTextPane();
JScrollPane scrollRight = new JScrollPane(textAreaRight);
JPanel rightPanel = new JPanel(new BorderLayout());
JButton btnOnline = new JButton("Online");
rightPanel.add(scrollRight,BorderLayout.CENTER);
rightPanel.add(btnOnline,BorderLayout.SOUTH);

JSplitPane splitP2 = new
JSplitPane(JSplitPane.HORIZONTAL_SPLIT,leftPanel,rightPanel);
splitP2.setResizeWeight(0.85);
getContentPane().add(splitP2);

JMenu menuUser = new JMenu("User");
JMenu menuMembers = new JMenu("Members");
JMenu menuOwner = new JMenu("Owner");
JMenuBar menuBar = new JMenuBar();
menuBar.add(menuUser);
menuBar.add(menuMembers);
menuBar.add(menuOwner);
setJMenuBar(menuBar);
}
public static void main( String args[] ){new Testing().setVisible(true);}
}


 
 
Jim Sculley





PostPosted: 2005-9-3 8:51:00 Top

java-programmer >> layouts layouts layouts.. Thomas Fritsch wrote:
> Frances wrote:
>
>> I know I have asked lot about this here, but I'm baffled by how hard
>> this is.. I've been doing layouts w/HTML and css for years, and never
>> have a problem getting my stuff to look exactly as I want it to, even
>> complex layouts.. but Swing layouts is just a different league....;)
>
> Well, you are probably right.
> Here is a course with several rather complex layout examples, including
> sources:
> http://java.sun.com/developer/onlineTraining/GUI/AWTLayoutMgr/shortcourse.html
>
> (Actually I'm quite enthusiastic about this course. It must have been
> drafted by a genius teacher)
>

It was written by Scott Stanchfield (http://javadude.com/). After
reading his description of how to design a GridBagLayout GUI on paper, I
finally understood how all the GBL constraints worked.

Jim S.
--
Remove my extraneous mandibular appendages to reply via email.
 
 
Frances





PostPosted: 2005-9-4 8:46:00 Top

java-programmer >> layouts layouts layouts.. Michael Dunn wrote:
> "Frances" <email***@***.com> wrote in message
> news:431857b8$0$18641$email***@***.com...
>
>>I know I have asked lot about this here, but I'm baffled by how hard this
>>is.. I've been doing layouts w/HTML and css for years, and never have a
>>problem getting my stuff to look exactly as I want it to, even complex
>>layouts.. but Swing layouts is just a different league....;)
>
> <snip>
>
> as mentioned a few times, it's just an understanding of how the different
> layout managers work,
> recognizing the default managers for various containers and
> combining/nesting them to get the
> desired effect (i.e. lots of trial and error)
>
> You sound like you're trying to understand this, rather than after a
> handout, so here's the code
> from your other post, modified to include the buttons and menu.
> (I find it easier posting the code and having you work it out, rather than
> trying to explain it all)
>
> import javax.swing.*;
> import java.awt.*;
> class Testing extends JFrame
> {
> public Testing()
> {
> setSize(700,450);
> setDefaultCloseOperation(EXIT_ON_CLOSE);
> setLocation(300,100);
> JTextPane textAreaTop = new JTextPane();
> JScrollPane scrollTop = new JScrollPane(textAreaTop,22,31);
> JTextPane textAreaBottom = new JTextPane();
> JScrollPane scrollBottom = new JScrollPane(textAreaBottom,22,31);
> JSplitPane splitP = new
> JSplitPane(JSplitPane.VERTICAL_SPLIT,scrollTop,scrollBottom);
> splitP.setResizeWeight(0.65);
>
> ........
Michael, this is TOTALLY awesome.. truly what I wanted.. I didn't want
you to write it all for me, actually, because as you say I do want
mainly to understand how it all works (I mean you have to understand all
your you use it seems to me....;) but well, this is perfect, I will
study your code, I will know how it's done right.... again many many
thanks... :)

(Michael, I just realized I responded to you earlier by e-mail by
mistake... sorry....)




 
 
Monique Y. Mudama





PostPosted: 2005-9-8 6:27:00 Top

java-programmer >> layouts layouts layouts.. On 2005-09-03, Jim Sculley penned:
>
> It was written by Scott Stanchfield (http://javadude.com/). After
> reading his description of how to design a GridBagLayout GUI on
> paper, I finally understood how all the GBL constraints worked.
>

I actually worked with him at my first job. He's probably the only
reason I ever understood layouts. A great guy to bounce design ideas
off of, too =)

--
monique

Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html