GeeCON Prague 2014*
The moose likes Swing / AWT / SWT and the fly likes Is Java's alignment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Is Java Watch "Is Java New topic
Author

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

naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 692

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 ?

The Only way to learn is ...........do!
Visit my blog http://inaved-momin.blogspot.com/
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
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

Joined: Jul 03, 2011
Posts: 692

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
Rancher

Joined: Sep 21, 2011
Posts: 2408
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

Joined: Jul 03, 2011
Posts: 692

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

Joined: Jun 09, 2003
Posts: 4632
> 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
Rancher

Joined: Sep 21, 2011
Posts: 2408
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

Joined: Jul 03, 2011
Posts: 692

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

Joined: Jul 03, 2011
Posts: 692

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
Rancher

Joined: Sep 21, 2011
Posts: 2408
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

Joined: Jul 03, 2011
Posts: 692

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



[Thumbnail for demo.png]

Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4572
    
    5

ALIGN_JUSTIFIED works fine for me. Show your code, in the form of an SSCCE.


luck, db
There are no new questions, but there may be new answers.
naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 692

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
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

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

Joined: Jul 03, 2011
Posts: 692

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

Joined: May 03, 2008
Posts: 4572
    
    5

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

Joined: Jul 03, 2011
Posts: 692

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

Joined: Oct 27, 2005
Posts: 19697
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 692

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 ......
 
GeeCON Prague 2014
 
subject: Is Java's alignment "Justify" is same as MS Word's alignment "Justify"?