🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #7770

Re: Display Text centered in a JTextPane

#7770
From: Chris Denham
Date: Fri, 15 Dec 2000 16:12
21 lines
1547 bytes
Try this (after you put the text in):

import javax.swing.*;
import javax.swing.text.*;
.....
SimpleAttributeSet attributes = new SimpleAttributeSet();
StyleConstants.setAlignment(attributes, StyleConstants.ALIGN_CENTER);
StyledDocument doc = jTextPane1.getStyledDocument();
doc.setParagraphAttributes(0, doc.getLength(), attributes, false);

They don't make it easy do they?

Chris Denham.

"Bjoern de Myn" <demyn@gmx.de> wrote in message
news:jmpu2toh9339vm5r8o7ac1p82trt16hmki@4ax.com...
> How can i display several lines of text (each) centered in a
> JTextPane?
> Anone can help me?
>
> Bjoern de Myn
Technical Details
Message-ID: <3a3a4314_1@dnews>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!news-x.support.nl!newsfeeds.belnet.be!news.belnet.be!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!bornews.borland.com!dnews!137.108.41.217
References: <jmpu2toh9339vm5r8o7ac1p82trt16hmki@4ax.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,7e97a5fc0ba33efd
X-Google-Attributes: gid111d45,public
X-Google-ArrivalTime: 2000-12-15 08:13:44 PST
Reply-To: "Chris Denham" <c.m.denham@open.ac.uk>
From: "Chris Denham" <c.m.denham@open.ac.uk>
Newsgroups: borland.public.jbuilder.java.swing
References: <jmpu2toh9339vm5r8o7ac1p82trt16hmki@4ax.com>
Subject: Re: Display Text  centered in a JTextPane
Date: Fri, 15 Dec 2000 16:12:55 -0000
Lines: 23
X-Newsreader: Microsoft Outlook Express 5.50.4133.2400
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
NNTP-Posting-Host: 137.108.41.217
Message-ID: <3a3a4314_1@dnews>
X-Trace: 15 Dec 2000 08:13:08 -0800, 137.108.41.217
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!news-x.support.nl!newsfeeds.belnet.be!news.belnet.be!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!bornews.borland.com!dnews!137.108.41.217