• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

at TextPane??

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all..
at TextPane how to get the text to right or center from its position..
 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ali,
browse SwingConstants class in the javax.swing.text package. It seems that u r trying to write a word processor so better take a look at the whole package.
Use SwingConstants.setAlignment(MutableattributeSet, int) where int is one of SwingConstants.ALIGN_CENTER, SwingConstants.ALIGN_JUSTIFIED, SwingConstants.ALIGN_LEFT, SwingConstants.ALIGN_RIGHT
After that u can pass that modified attributeset to textPane.setParagraphAttributes(AttributeSet, boolean)
BTW do u know the entire javax.swing.text package is designed/written by a single person Timothy Prinzing. One more don in swing i know is Kim Topley so if u come across any material of any of these gurus go thru them thoroughly
Best of Luck
 
ali rafiq
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i didnt understand very well
now i got the problen with ur situation
jt= new JTextPane();
SwingConstants.setAlignment("LEFT-JUSTIFY", LEFT_ALIGN);
or
SwingConstants.setAlignment("LEFT-JUSTIFY", SwingConstants.LEFT_ALIGN);
jt.setParagraphAttributes("LEFT-Align", true);
but its given a lots of error
 
Ashish Mahajan
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ali,
U r passing different type of arguments. that's why.
 
Ashish Mahajan
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For more info take a look at :-
http://www.csie.ntu.edu.tw/~b7506051/docs/Swing/Chapter20html/
 
ali rafiq
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
protected MutableAttributeSet set;
public FontDemo1()
{
super("TESTING FONT");
try{
InputStream is =new FileInputStream("urdu.ttf");
f=Font.createFont(Font.TRUETYPE_FONT,is);
is.close();
jt = new JTextPane();
set = new SimpleAttributeSet();
jt.setFont(f.deriveFont(25f));

SwingConstants.setAlignment(set, SwingConstants.ALIGN_RIGHT);
it a giving two error its

FontDemo1.java:33: cannot resolve symbol
symbol : variable ALIGN_RIGHT
location: interface javax.swing.SwingConstants
SwingConstants.setAlignment(set, SwingConstants.ALIGN_RIGHT);
^
1 error
if i change the veriable then its gives me
another error
FontDemo1.java:33: cannot resolve symbol
symbol : method setAlignment (javax.swing.text.MutableAttributeSet,int)
location: interface javax.swing.SwingConstants
SwingConstants.setAlignment(set, SwingConstants.RIGHT);
^
1 error

if i change the interface to StyleConstants
StyleConstants.setAlignment(set,StyleConstants.ALIGN_RIGHT);
it does not give any error but . my create font change into defualt font of java..

i got lots of site to see this topic but i have a simple programe i need i simple example.. atually my font start from the right side.
 
reply
    Bookmark Topic Watch Topic
  • New Topic