At 03:41 AM 2/22/2002, John A. Preston wrote: >Hi, Do anybody know how to format text in a JTextArea so that it is >centered instead of left justfied.
Try this (I wrote this code from head, so it may not compile, but the general idea is there) JTextArea textArea = ...; Action centerAlignAction; Action[] availableActions = textArea.getEditorKit().getActions(); for( int i=0; i<availableActions.length; i++ ) { if( availableActions[i].getValue(Action.NAME).equals("center-justify") ) centerAlignAction = availableAction[i]; } textArea.selectAll(); centerAlignAction.actionPerformed( new ActionEvent(textArea,ActionEvent.ACTION_PERFORMED,"center-justify") ); You can also replace the entire for-loop with this: centerAlignAction = new StyledEditorKit.AlignmentAction("center-justify", StyleConstants.ALIGN_CENTER); Dmitry _______________________________________________ Swing mailing list [EMAIL PROTECTED] http://eos.dk/mailman/listinfo/swing