Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is Java's alignment "Justify" is same as MS Word's alignment "Justify"?

 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i was doing style into my jtextpane using styleDocument and i wanted it to align text as justify, i have achieved what i wanted to do but the alignment is not the same as MS word's "justify" alignment
is this is a case or i m doing something wrong ?
 
Tim Moores
Bartender
Posts: 2891
46
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm fairly certain that visual consistency with MS Word wasn't part of the Swing specification, so I'd tend to disregard any such discrepancies. If some part of Swing doesn't work according to your expectations, tell us in detail what you did, what you expected, and what the actual outcome was.
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Moores wrote:I'm fairly certain that visual consistency with MS Word wasn't part of the Swing specification, so I'd tend to disregard any such discrepancies. If some part of Swing doesn't work according to your expectations, tell us in detail what you did, what you expected, and what the actual outcome was.

thanks for the reply i was just trying to align "justify " my text
code for that



how ever after this code i have placed a simple print statement and retrieve the alignment and i get the same justify align but the text in my textpane positioned themselves in some way
but that way is not exactly what i wanted ?
all i wanted is the text should be justify properly just as like MS Word
 
Tim Moores
Bartender
Posts: 2891
46
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
MS Word is not the definition of text processing or layout. That its way would be the "proper" way is quite a stretch.

Can you be more precise about what "some way" is? And also, what exactly it is that you wanted? Or does the question mark at the end of that sentence indicate that you're not sure what you wanted and/or expected?
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Moores wrote:MS Word is not the definition of text processing or layout. That its way would be the "proper" way is quite a stretch.

Can you be more precise about what "some way" is? And also, what exactly it is that you wanted? Or does the question mark at the end of that sentence indicate that you're not sure what you wanted and/or expected?

yes, i m not getting what i m expecting
it will be very hard for me to explain you what i want because i guess you are not familiar with the align "Justify" of MS word
let me try once more, suppose you are writing a paragraph, and lines in that paragraph are not proper consider this example
your paragraph without justify align :
hi i love programming
do you love programming
yes i do love but , but what ?

now your paragraph with justify align:

hi[ss]i[ss]love[ss]programming
do[ ]you[ ]love[s]programming
yes i do love but ,[s]but what ?

note : [ ] or [] or [ss] indicates spaces for the example to appear cleaner
notice here how everything in a paragraph is justify this is how MS Word works and i m expecting this output, i guess now the picture is clear for you ?
and hope you can help me with that?
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> this is how MS Word works and i m expecting this output

how about you get apple to mimic everything MS does, then java/oracle might follow.
 
Tim Moores
Bartender
Posts: 2891
46
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm familiar with the concept of justification of text. What I asked was what you got instead of what you thought you should be getting.
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Moores wrote:I'm familiar with the concept of justification of text. What I asked was what you got instead of what you thought you should be getting.

oh you are familiar, i m sorry then , but i m getting the output just similar to the example i have shown you (without justify align).
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael Dunn wrote:> this is how MS Word works and i m expecting this output

how about you get apple to mimic everything MS does, then java/oracle might follow.

:) funny .....
 
Tim Moores
Bartender
Posts: 2891
46
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't tell from 4 lines of code what they might do in the context of an actual program. Maybe you can post a screenshot of the output, or, even better, post an SSCCE.
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Moores wrote:I can't tell from 4 lines of code what they might do in the context of an actual program. Maybe you can post a screenshot of the output, or, even better, post an SSCCE.

hope tim this helps
demo.png
[Thumbnail for demo.png]
left one is justify align in my app and right one is justify align in MS Word
 
Darryl Burke
Bartender
Posts: 5147
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ALIGN_JUSTIFIED works fine for me. Show your code, in the form of an SSCCE.
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Darryl Burke wrote:ALIGN_JUSTIFIED works fine for me. Show your code, in the form of an SSCCE.

if you need more code for clearification please ask me
thanks for your help

 
Paul Clapham
Sheriff
Posts: 21297
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you spend a moment and actually read the SSCCE document?

(Hint: part of the acronym stands for "self-contained". Find out what that means.)
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Darryl Burke wrote:ALIGN_JUSTIFIED works fine for me. Show your code, in the form of an SSCCE.

can you post your code so that I can make correction in my code and learn, where I was wrong ?
 
Darryl Burke
Bartender
Posts: 5147
11
Java Netbeans IDE Opera
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
naved, please keep technical discussions on the forum. Private messaging has its purposes, but repeating forum posts in a private message is not one of them.

You've been asked more than once to post your code in the form of an SSCCE, but it appears that you are unwilling to take the effort to make it easier for other members here to help you.

Good luck with your problem.
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Darryl Burke wrote:naved, please keep technical discussions on the forum. Private messaging has its purposes, but repeating forum posts in a private message is not one of them.

You've been asked more than once to post your code in the form of an SSCCE, but it appears that you are unwilling to take the effort to make it easier for other members here to help you.

Good luck with your problem.

OK i have read the SSCCE ...and now i m posting a code that can be run through just copy-paste operation into your IDE.
hope with this any one can provide me help ?

 
Rob Spoor
Sheriff
Pie
Posts: 20605
60
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's not an SSCCE - you forgot the imports: You should check if selexted inside your action listener is null. If you don't select anything you will get a NullPointerException.
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Spoor wrote:That's not an SSCCE - you forgot the imports: You should check if selexted inside your action listener is null. If you don't select anything you will get a NullPointerException.

yes, thanks for the import one ,
and yes i do know that i will get null pointer exception if i didnt select anything but thats not what i m searching here, i want justify align which is not happening or working in my code
can any one will point out the problem please
that will be a great help
thanks anyways ......
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic