Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #155
| From | "bill turner" <bill.turner@THRWHITE.remove-dii-this> |
|---|---|
| Subject | Re: jtextpane has no comp |
| Message-ID | <1164133791.768459.57200@j44g2000cwa.googlegroups.com> (permalink) |
| Newsgroups | comp.lang.java.gui |
| References | <1164131384.208120.191630@h48g2000cwc.googlegroups.com><1 |
| Date | 2011-04-27 15:25 +0000 |
| Organization | TDS.net |
To: comp.lang.java.gui
Daniel Pitts wrote:
> bill turner wrote:
> > 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.
>
> I think you are confusing Swing components with HTML controls.
>
> JTextPane will parse an HTML file, but not very well, and it doesn't
> leave much interaction to the rest of the application. You'de be
> better off setting up a JPanel with the Swing components that you want
> in them. You may also want to look into JGoodies for form layout.
Sorry If I have the terminology incorrect, but, no, I am not confusing
things as far as I am aware. As I point out, the data will display
after an event, I am able to get a handle to the components in the
jtextpane (see method below) after the event. I just cannot do it
before the event, when I am initially loading the page. As for using
Swing components instead, I was told to go this way. There will be
other pages that will connect to the internet rather than local
resources, and several of the pages were already developed in html. So,
I would rather solve the issue than abandon it. Of course, if it is
insurmountable, then, of course, I will have no choice. Here is how I
parse the jtextpane. Again, on initial load, there are no components,
after the event there are.
private void parseHtml()
{
System.out.println("dataEntryPane.getComponentCount()=" +
dataEntryPane.getComponentCount());
for (int i = 0; i < dataEntryPane.getComponentCount(); i++)
{
Container c = (Container) dataEntryPane.getComponent(i);
Component swingComponentOfHTMLInputType = c.getComponent(0);
if (swingComponentOfHTMLInputType instanceof JTextField)
{
switch (i)
{
case JTF1:
jtf1 = (JTextField) swingComponentOfHTMLInputType;
break;
case JTF2:
jtf2 = (JTextField) swingComponentOfHTMLInputType;
break;
case JTF3:
jtf3 = (JTextField) swingComponentOfHTMLInputType;
break;
.
.
.
}
}
}
---
* 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 — Previous in thread | 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