Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #3645
| From | "Daniele Futtorovic" <daniele.futtorovic@THRWHITE.remove-dii-this> |
|---|---|
| Subject | Re: Working with swing-ba |
| Message-ID | <g363oa$7f2$1@registered.motzarella.org> (permalink) |
| Newsgroups | comp.lang.java.gui |
| Date | 2011-04-27 15:46 +0000 |
| Organization | TDS.net |
To: comp.lang.java.gui
On 2008-06-15 22:50 +0100, Joe Weinberg allegedly wrote:
> http://java.sun.com/docs/books/tutorial/uiswing/layout/card.html
>
>
> http://java.sun.com/docs/books/tutorialJWS/uiswing/layout/ex6/CardLayoutDemo.jnlp
>
> for another part of the GUI
>
>
> However, I think I may not have been clear enough. As I said, I am learning
> the specifics of this, I don't even know how to ask for it. Let me make up
> this scenario for illustration purposes:
>
> The swing app I had seen worked like this. Say you have a large text in L1
> you must translate to L2. You have a JTabbedPane with a left tab for the
> entire L1 text and a middle one with a large JLabel (or some other text
> component you can't update) on the top that would take each paragraph, a
> JTextArea right underneath for you to type in your translation and some
> navigation buttons
>
> Then you click "next" for the next paragraph to be shown on the top JLabel,
> but you also want for that section of text to be highlighted on the left
> and repositioned on the screen so that you don't have to be scrolling to
> view it
>
> Parsing the text and set(ting the)Text of a JLabel is easy, the part I have
> no clue about is how to programmatically re-center and highlight the
> current paragraph on the left
>
> I hope I was clearer now
>
> J
If you want to do this properly, you will have to work yourself through
the Text Component API:
<http://java.sun.com/docs/books/tutorial/uiswing/components/text.html>
See also the JavaDoc for JTextComponent:
<http://java.sun.com/javase/6/docs/api/javax/swing/text/JTextComponent.html>
You mentioned you got scared of the "EditorKit" and such stuff. I
suppose wading through the whole text component API will seem scary,
too. But you'll need to if you want a comprehensive understanding.
If you want a quick fix, though (no pun intended), the following could
be things to look for:
- for the highlighting
JTextComponent#setSelectedTextColor(Color)
JTextComponont#select(int, int)
- for "re-centering" a paragraph:
JTextComponent#modelToView(int)
JComponent#scrollRectToVisible(Rectangle) or
JViewPort#setViewPosition(Point)
(JTextComponent is the superclass of JTextField, JTextArea, JEditorPane)
Be sure to have at least a glimpse at the tutorials. Be sure to
thoroughly read the class' Javadoc and that of the methods you use.
--
DF.
to reply privately, change the top-level domain
in the FROM address from "invalid" to "net"
---
* 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 | Find similar | Unroll thread
Re: Working with swing-ba "Daniele Futtorovic" <daniele.futtorovic@THRWHITE.remove-dii-this> - 2011-04-27 15:46 +0000
csiph-web