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: printdude1968@gmail.com.remove-dii-this Subject: Question about JTextAreas Message-ID: <1168197931.029515.109690@42g2000cwt.googlegroups.com> X-Comment-To: comp.lang.java.gui Newsgroups: comp.lang.java.gui Content-Type: text/plain; charset=IBM437 Content-Transfer-Encoding: 8bit X-Gateway: time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92] Lines: 96 Date: Wed, 27 Apr 2011 15:28:21 GMT NNTP-Posting-Host: 96.60.20.240 X-Complaints-To: news@tds.net X-Trace: newsreading01.news.tds.net 1303918101 96.60.20.240 (Wed, 27 Apr 2011 10:28:21 CDT) NNTP-Posting-Date: Wed, 27 Apr 2011 10:28:21 CDT Organization: TDS.net Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.gui:581 To: comp.lang.java.gui 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 package mainPackage; // omitted a bunch of imports public class printControlMaintenanceGUI { public static void main(String[] args) throws FileNotFoundException, IOException { // TODO Auto-generated method stub MainFrame frame = new MainFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } } 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); } } class TextPanel extends JPanel { public TextPanel() throws FileNotFoundException, IOException { ArrayList pcControl = new ArrayList(); JTextArea currentList = new JTextArea("",20,80); pcControl=loadXMLFile(); <-- I left this code out because it works. displayXMLFile(pcControl, currentList); add(currentList); } public static void displayXMLFile(ArrayList aList, JTextArea ta) { String newLine = "\n"; for (int tt=0;tt<=aList.size() - 1;tt++) { String line2 = (String) aList.get(tt); System.out.println("Line: " + tt + " " + line2); ta.append(line2 ); ta.append(newLine); } } // left out to make the attachment smaller // end of ommitted stuff } class ButtonPanel extends JPanel { public ButtonPanel() { JButton addButton = new JButton("Add"); JButton changeButton = new JButton("Change"); JButton deleteButton = new JButton("Delete"); JButton printButton = new JButton("Print"); add(addButton); add(changeButton); add(deleteButton); add(printButton); } } Remember, I'm just starting this.. putting it together piece by piece. I started by getting the JFrame working, then the buttons. The last thing I did was set up the TextArea and append the strings I read in to it. It "looks" like it works but I won't know for sure until I can have both the TextArea and the buttons on the screen at the same time. I've tried setting the location of the text panel using the setLocation method, but it still doesn't work. --- * 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