Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #3672 > unrolled thread

equally sizing text areas

Started by"Albretch Mueller" <albretch.mueller@THRWHITE.remove-dii-this>
First post2011-04-27 15:46 +0000
Last post2011-04-27 15:46 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.lang.java.gui


Contents

  equally sizing text areas "Albretch Mueller" <albretch.mueller@THRWHITE.remove-dii-this> - 2011-04-27 15:46 +0000
    Re: equally sizing text a "Daniele Futtorovic" <daniele.futtorovic@THRWHITE.remove-dii-this> - 2011-04-27 15:46 +0000

#3672 — equally sizing text areas

From"Albretch Mueller" <albretch.mueller@THRWHITE.remove-dii-this>
Date2011-04-27 15:46 +0000
Subjectequally sizing text areas
Message-ID<1213901841.510724@nntp.acecape.com>
  To: comp.lang.java.gui
 I have a container, a JFrame, with a JTabbedPane inside of it.

 The Dimension of the JFrame I set based on the screen size 

 Inside of the JTabbedPane I create three, two or just one text area.

 These JTextAreas are placed inside of a JScrollPane and separated by
JSplitPanes, but I would like for all these text areas to occupy equal
spaces

 I can not use as reference the JFrame or JTabbedPane Dimensions (which are
the same) because the JTabbedPane already uses space for the tabs
themselves

 How can you get the innner Dimension of the actual real estate that the
JTabbedPane lets you use to place in JPanels?

 Thanks
 lbrtchx

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [next] | [standalone]


#3685 — Re: equally sizing text a

From"Daniele Futtorovic" <daniele.futtorovic@THRWHITE.remove-dii-this>
Date2011-04-27 15:46 +0000
SubjectRe: equally sizing text a
Message-ID<g3mafe$eo0$1@registered.motzarella.org>
In reply to#3672
  To: comp.lang.java.gui
On 2008-06-19 20:57 +0100, Albretch Mueller allegedly wrote:
> I have a container, a JFrame, with a JTabbedPane inside of it.
> 
> The Dimension of the JFrame I set based on the screen size
> 
> Inside of the JTabbedPane I create three, two or just one text area.
> 
> These JTextAreas are placed inside of a JScrollPane and separated by 
> JSplitPanes, but I would like for all these text areas to occupy
> equal spaces
> 
> I can not use as reference the JFrame or JTabbedPane Dimensions
> (which are the same) because the JTabbedPane already uses space for
> the tabs themselves
> 
> How can you get the innner Dimension of the actual real estate that
> the JTabbedPane lets you use to place in JPanels?

JTabbedPane#getBoundsAt(int) may do the trick.

But I'd rather suggest you tried the following:

Assuming textArea1, textArea2, textArea3 are the components you want to
display.

private static class CustomPanel
extends JPanel
implements Scrollable
{
     public boolean getScrollableTracksViewPortWidth(){ return true; }

     //implement other Scrollable methods and JPanel c'tors accordingly
}

JPanel p = new CustomPanel();

JSplitPane spp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true,
texArea1, textArea2);
spp.setResizeWeight(.5);

spp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, spp, textArea3);
spp.setResizeWeight(2d/3);

p.add(spp, BorderLayout.CENTER);

JScrollPane scp = new JScrollPane(p);

.. and make scp the tab component.

-.-

I might add that this idea of putting three textAreas in split panes
does NOT seem like a very wise choice, in terms of GUI design, to me.
Consequently, I'd suggest you got rid of them. The code would then look
like this:

JPanel p = new CustomPanel(new GridLayout(1, 3, 5, 5)); //implement
appropriate c'tor in CustomPanel

p.add(textArea1);
p.add(textArea2);
p.add(textArea3);

JScrollPane scp = new JScrollPane(p);

.. and make scp the tab component.

-.-

All code from scratch, uncompiled, untested -- no guarantees.

-- 
DF.
to reply privately, change the top-level domain
in the FROM address from "invalid" to "net"

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.gui


csiph-web