Path: csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!news.glorb.com!news-out.readnews.com!news-xxxfer.readnews.com!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail From: "lee" Subject: Re: Question about JTextA Message-ID: X-Comment-To: comp.lang.java.gui Newsgroups: comp.lang.java.gui In-Reply-To: <1168197931.029515.109690@42g2000cwt.googlegroups.com> References: <1168197931.029515.109690@42g2000cwt.googlegroups.com> Content-Type: text/plain; charset=IBM437 Content-Transfer-Encoding: 8bit X-Gateway: time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92] Lines: 44 Date: Wed, 27 Apr 2011 15:28:22 GMT NNTP-Posting-Host: 96.60.20.240 X-Complaints-To: news@tds.net X-Trace: newsreading01.news.tds.net 1303918102 96.60.20.240 (Wed, 27 Apr 2011 10:28:22 CDT) NNTP-Posting-Date: Wed, 27 Apr 2011 10:28:22 CDT Organization: TDS.net Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.gui:583 To: comp.lang.java.gui In article <1168197931.029515.109690@42g2000cwt.googlegroups.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 >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); > } >} 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