Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #154
| From | "bill turner" <bill.turner@THRWHITE.remove-dii-this> |
|---|---|
| Subject | jtextpane has no componen |
| Message-ID | <1164131384.208120.191630@h48g2000cwc.googlegroups.com> (permalink) |
| Newsgroups | comp.lang.java.gui |
| Date | 2011-04-27 15:25 +0000 |
| Organization | TDS.net |
To: comp.lang.java.gui
I am having a problem with jtextpane that I do not understand. It is
probably quite obvious, but I am not strong with Swing, so please be
gentle. I've spent time on the tutorials and googling, but there are
not samples nor any discussions that I've seen doing what it is I am
attempting to do. Essentially, when the app starts up, it tries to
initialize the display. Using the jtextpane setText method, the html is
loaded. After that is done, I display the number of components and it
is always 0. This means that my call to the method parseHtml() has
nothing to parse. This method loops over the components and tests to
see if the component is an instanceof a Swing component, such as
JTextField and, if so, sets a member variable of that type to the
component. I do this so that I have a handle to the various components.
Then, I call the method setOutput() and set the text value of the
various components. I am trying to load the current state of the data
for immediate display, which makes sense for this app. Think of an
editor that displays application properties or any other type of
current settings. It does not make sense to put in a button, in my
opinion, to load the data. However, it seems like that is what I need
to do as I can display the data just fine after an event (pressing my
update button, for example). I call the same two methods. So, how can I
get handle to the components before the initial display so that I can
set the dynamic content? Below is the method that builds the initial
display. the variable dataEntryPane is a member variable of type
JTextPane.
private JScrollPane makeDataEntryPane()
{
URL myHtml = null;
File f = new File(filename);
try
{
myHtml = f.toURL();
dataEntryPane.setEditorKit(new HTMLEditorKit());
dataEntryPane.setPage(myHtml);
dataEntryPane.setEditable(false);
System.out.println("dataEntryPane.getComponentCount()=" +
dataEntryPane.getComponentCount());
parseHtml();
setOutput();
}
catch (MalformedURLException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
return new JScrollPane(dataEntryPane);
}
Your help is greatly appreciated!
Bill
---
* 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 | Next — Next in thread | Find similar
jtextpane has no componen "bill turner" <bill.turner@THRWHITE.remove-dii-this> - 2011-04-27 15:25 +0000
Re: jtextpane has no comp "bill turner" <bill.turner@THRWHITE.remove-dii-this> - 2011-04-27 15:25 +0000
Re: jtextpane has no comp "usenet" <usenet@THRWHITE.remove-dii-this> - 2011-04-27 15:26 +0000
csiph-web