Article View: borland.public.jbuilder.java.swing
Article #8893Re: JScrollPane and JtextPane
From: Paul Furbacher [TeamB]
Date: Wed, 21 Jun 2000 00:00
Date: Wed, 21 Jun 2000 00:00
35 lines
1678 bytes
1678 bytes
JPBallet wrote: > Who says me how can i show the first line of my text in a JTextPane with a > JSCrollPane. > When i insert all text from a text file, only the last lines appear and i > am obliged to scroll up. > I wish that the first line appear and then scolling down. You can try getting the scroll pane's viewport and asking it to "setViewPosition(new Point(0,0))". You might also try to set the caret position of the text pane. > An other question. How can i justify my text because: > > DefaultStyledDocument doc = new DefaultStyledDocument(); > ... > textPane.setStyledDocument(doc); > SimpleAttributeSet attr = new SimpleAttributeSet(); > ... > > StyleConstants.setAlignment( > attr,StyleConstants.ParagraphConstants.ALIGN_CENTER); > > don't work. Just wondering, do you add the style to the document somewhere? I haven't worked with styles, so this is just a guess. A thorough reference for this type of document manipulation is Keith Topley's "Core Swing: Advanced Programming", chapter 2 and following. Paul Furbacher (TeamB)
Technical Details
Message-ID:
<395132B3.12610EB6@home.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<8iqj34$i377@bornews.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,fd03c856ba6f12e6 X-Google-Attributes: gid111d45,public From: "Paul Furbacher [TeamB]" <pnf@home.com> Subject: Re: JScrollPane and JtextPane Date: 2000/06/21 Message-ID: <395132B3.12610EB6@home.com> X-Deja-AN: 637379749 Content-Transfer-Encoding: 7bit References: <8iqj34$i377@bornews.borland.com> X-Accept-Language: en,pdf Content-Type: text/plain; charset=us-ascii Organization: Reverse Alchemy, Inc. Mime-Version: 1.0 Reply-To: pnf@home.com Newsgroups: borland.public.jbuilder.java.swing