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


Groups > comp.lang.java.gui > #583

Re: Question about JTextA

From "lee" <lee@THRWHITE.remove-dii-this>
Subject Re: Question about JTextA
Message-ID <oM2dnYGeu4CE0jzYnZ2dnUVZ_oKnnZ2d@insightbb.com> (permalink)
Newsgroups comp.lang.java.gui
References <1168197931.029515.109690@42g2000cwt.googlegroups.com>
Date 2011-04-27 15:28 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.gui
In article <1168197931.029515.109690@42g2000cwt.googlegroups.com>, "printdude1968@gmail.com" <printdude1968@gmail.com> wrote:
>I'm starting to piece my way through the construction of a GUI which
>has 4 buttons (add, change, delete, print) and a JTextArea that
>displays the contents of a file using a vertical scroll bar.
>I'm not sure what I'm doing wrong here, but when I add panel2 my
>buttons disappear.  If I leave it off the frame, my buttons stay where
>I put them.  I left out the part of the program that parses the XML
>file and checks for wellformedness just to keep the code compact
<snip>
>class MainFrame extends JFrame
>{
>        public MainFrame() throws FileNotFoundException, IOException
>        {
>                Toolkit kit = Toolkit.getDefaultToolkit();
>                Dimension screenSize = kit.getScreenSize();
>                int screenHeight = screenSize.height;
>                int screenWidth = screenSize.width;
>
>                setSize(screenWidth/2, screenHeight/2);
>                setLocation(screenWidth/4, screenHeight/4);
>                ButtonPanel panel1 = new ButtonPanel();
>                add(panel1);
>                TextPanel panel2 = new TextPanel();
>// if I let this happen, my buttons disappear   add(panel2);
>        }
>}
<snip>

By default, a JFrame has Border Layout assigned to it.  You are adding both 
panels to the same region of the BorderLayout, therefore, the second one is 
covering over the first one.  Try changing your second add() statement to 
this:
        add( panel2, BorderLayout.SOUTH );

Then, you might want to look up BorderLayout in the doc files.

Lee Weiner
lee AT leeweiner DOT org

---
 * 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

Back to comp.lang.java.gui | Previous | NextPrevious in thread | Find similar


Thread

Question about JTextAreas printdude1968@gmail.com.remove-dii-this - 2011-04-27 15:28 +0000
  Re: Question about JTextA "lee" <lee@THRWHITE.remove-dii-this> - 2011-04-27 15:28 +0000

csiph-web