JEditorPane and HTMLEditorKit: can't set alignment after invoking setText

When i write text into JEditorPane i can change the alignment of this text.
With getText i get the html-code. After invoking setText() with this html-code the alignment-action does not work.
Here is some test-code to show this. but the test fails only sometimes.
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.util.HashMap;
import java.util.Map;
import javax.swing.Action;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.text.html.HTMLEditorKit;
import junit.extensions.jfcunit.JFCTestCase;
import junit.extensions.jfcunit.JFCTestHelper;
import junit.extensions.jfcunit.eventdata.KeyEventData;
import junit.framework.AssertionFailedError;
public class EditorPaneTest extends JFCTestCase {
  // Private instance variables ( fixtures )
  // ==============================================================================================
  private JFCTestHelper jfcHelper= null;
  private JEditorPane testInstance = null;
  public EditorPaneTest( String testName ) {
    super( testName );
  // Class methods
  // ==================================================================================================================
  public static junit.framework.Test suite() {
    junit.framework.TestSuite suite = new junit.framework.TestSuite( EditorPaneTest.class );
      return new junit.extensions.RepeatedTest( suite , 5 );
  // Instance methods
  // ==================================================================================================================
  // Protected ( setup and teardown test case )
  protected void setUp() throws java.lang.Exception {
    super.setUp();
    junit.extensions.jfcunit.JFCTestHelper.setCurrentTestCase( this );
    jfcHelper = new JFCTestHelper();
  protected void tearDown() throws java.lang.Exception {
    try {
      // Add tearDown code for fixtures here
    } // try
    finally {
      jfcHelper = null;
      junit.extensions.jfcunit.TestHelper.cleanUp( this );
      super.tearDown();
    } // finally
  // Public ( testcases )
  @SuppressWarnings("nls")
  public void testCreation() throws Exception {
    SwingUtilities.invokeAndWait( new Runnable() {
      public void run() {
        testInstance = new JEditorPane();
    assertNotNull( testInstance );
    final JFrame frame = new JFrame( "test" );
    frame.getContentPane().add( testInstance , BorderLayout.CENTER );
    frame.setSize( 800 , 600 );
    frame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE );
    frame.setVisible( true );
    testInstance.setEditorKit( new HTMLEditorKit() );
    Map< String , Action > actionMap = new HashMap< String , Action >();
    Action[] actions = testInstance.getEditorKit().getActions();
    for ( Action a : actions ) {
      actionMap.put( ( String ) a.getValue( Action.NAME ) , a );
    jfcHelper.sendKeyAction( new KeyEventData( this , testInstance , KeyEvent.VK_T ) );
    jfcHelper.sendKeyAction( new KeyEventData( this , testInstance , KeyEvent.VK_S ) );
    jfcHelper.sendKeyAction( new KeyEventData( this , testInstance , KeyEvent.VK_T ) );
    selectAll();
    Action centerAction = actionMap.get( "center-justify" ); //$NON-NLS-1$
    centerAction.actionPerformed( new ActionEvent( this , ActionEvent.ACTION_PERFORMED , "align" ) );
    final String html = testInstance.getText();
    SwingUtilities.invokeAndWait( new Runnable() {
      public void run() {
        testInstance.setText( html );
    final String htmlAfterInit = testInstance.getText();
    selectAll();
    Action leftAction = actionMap.get( "left-justify" );//$NON-NLS-1$
    leftAction.actionPerformed( new ActionEvent( this , ActionEvent.ACTION_PERFORMED , "align" ) );
    final String htmlAfterAlignLeft = testInstance.getText();
    new alltests.AbstractMockTimeoutVerifier( alltests.AbstractMockTimeoutVerifier.Type.SWING ) {
      public void doVerify() throws AssertionFailedError {
        assertFalse( htmlAfterInit.equals( htmlAfterAlignLeft ) );
        System.out.println(htmlAfterInit); //$NON-NLS-1$ // TODO: Remove
        System.out.println("-------------------------"); //$NON-NLS-1$ // TODO: Remove
        System.out.println(htmlAfterAlignLeft); //$NON-NLS-1$ // TODO: Remove
    }.verify();
  // Private ( helpers )
  private void selectAll() throws AssertionFailedError, InterruptedException{
    SwingUtilities.invokeLater( new Runnable() {
      public void run() {
        testInstance.selectAll(); 
    new alltests.AbstractMockTimeoutVerifier( alltests.AbstractMockTimeoutVerifier.Type.SWING ) {
      public void doVerify() throws AssertionFailedError {
        assertTrue( 0 < testInstance.getSelectedText().length() );
    }.verify();
}

I remember having a similiar problem. It was caused by the session not using the properties passed in. I seem to remember I needed to set a system property at startup, but can't remember what it was. JGuru has this to say though:
Q:
I'm getting my Session with Session.getDefaultInstance and its not getting changes to the Properties passed in. What's wrong?
A:
In getDefaultInstance(Properties props), the Properties are only used in the initial call. Future calls ignore the setting, returning the previously created Session. If you need to change the Properties, like to change SMTP servers, you should use getInstance(Properties props) instead.

Similar Messages

  • Can't set brightness after screen blanking

    After last update, I can't set brightness after the screen goes off because of inactivity, before that everything works normally.
    When I reboot brightness setting works, as is after suspend/unsuspend.
    The laptop is Dell Latitude D830.
    Any ideas?

    b4d wrote:
    After last update, I can't set brightness after the screen goes off because of inactivity, before that everything works normally.
    When I reboot brightness setting works, as is after suspend/unsuspend.
    The laptop is Dell Latitude D830.
    Any ideas?
    Can you share your kernel version and graphics controller information, please? I had a similar issue with my graphics controller after upgrading to the 3.x kernel in core.

  • If my wife and I share our Imac but have separate Iphones and Ipads, can we set up 2 separate Iclouds on the Imac?  Or do we have 1 Icloud account and synch our individual devices separately?

    If my wife and I share our Imac but have separate Iphones and Ipads, can we set up 2 separate Iclouds on the Imac?  Or do we have 1 Icloud account and synch our individual devices separately?

    Set 2 independent users on the iMac, each can then have their own accounts (iCloud, iTunes etc)

  • HP widget loses its configuration and I can't set it bagk for my c7280

    HP widget loses its configuration and I can't set it bagk for my c7280

    if it keeps asking for the password again just write "0000", add the controller to your favorites, close bluetooth before asked for a password again, and the open bluetooth again

  • Why my iTunes crashes when I try to watch my videos and I can't reopen it after doing so.

    Why my iTines crashes when I try to wtch videos and I can't reopen  it after doing so?

    Is it giving you an "iTunes has stopped working" message when you play the videos?
    If so, let's try the following user tip with that one:
    iTunes for Windows 10.7.0.21: "iTunes has stopped working" error messages when playing videos, video podcasts, movies and TV shows

  • I always want google classic, but sometimes i get google beta or google security (or whatever, can't remember its name) when i don't want it. why does this happen and how can i set google classic as the default?

    google is my default on the home page. But when i ask for google or simply open firefox, i sometimes get google beta or google security (or whatever its name is) instead of google classic. I just want google classic. How can i set it as my default. (I have a desk top computer, use firefox, and this never happens.)

    Why Apple can't undo its mistake?
    Whose mistake? The source of the problem:
    I was required to enter my recovery key. Now, there begins that huge flaw. I've forgotten it (I know it was my responsibility to remember it).
    If you had just taken the simple steps of storing your recovery key as Apple tells you to when you set it up, none of this would've happened.
    As it clearly states in the FAQ on 2-step verification: http://support.apple.com/kb/HT5570
    After you turn it on, there will be no way for anyone to access and manage your account at My Apple ID other than by using your password, verification codes sent your trusted devices, or your Recovery Key. You must be responsible for:
    Remembering your password.
    Keeping your trusted devices physically secure.
    Keeping your Recovery Key in a safe place.
    If you lose access to two of these three items at the same time, you could be locked out of your Apple ID account permanently.
    In addition, with two-step verification turned on, only you can reset your password, manage your trusted devices, or create a new recovery key.
    Apple Support can help you with other aspects of your service, but they will not be able to update or recover these three things on your behalf.
    If you aren't responsible enough to do that, you should not have turned the optional security feature on.
    This is your fault, not Apple's.

  • How can use set automatically after executeQuery in UIX Site?

    Hallo ...,
    i start in my site with an initial event for instance site.do?event=init.
    in the init event i make a roolback, setWhereClause and executeQuery. then the site will display. after the executeQuery i have data in my site which i want to put on variables. all solutions i know need an event. when i put an submit button on the site and go to an event variable there i can say set value=... property=... target=... and can work for example with session variables. but i want to fill the variables without user interaction. but i don't know a way.
    any help is appreciated.

    Hi Marc,
    You can use the Origin property of the pane to set the top left point of your front panel.
    Is this what you are after?
    Dave
    Message Edited by DavidU on 10-06-2008 10:13 AM
    Attachments:
    OriginProperty.png ‏2 KB

  • I have deleted my e mail account and  now can not set it up again as it will not recognise my account details although they are the same as before

    I am trying to set up my e mail account on my I phone after deleting it but even though I am putting in the same details it does not recognise my account details how can I set up my e mail?

    Just call your internet supplier and ask for the correct settings for the email

  • JEditorPane and HTML Coded Character Set

    Hi.
    How to prevent JEditorPane to convert its content into HTML coded character set (like
    &#1072;&#1073;&#1074;&#1075;&#1076;&#1077;&#1105;&#1078;
    I would like to receive normal unicode string from getText() method.
    Setting content type
    editorPane.setContentType("text/html; charset=ISO-10646");
    has no effect.

    you would have to iterate through the elements of the HTMLDocument in the JEditorPane and look for the HTML tags you are interested in. Once a tag is found its AttributeSet will have the content. I am too lazy to post how it is done again. There are tons of postings in the forum about the topic, so by simply using the search function you should find respective hints.

  • TS2621 Done everything and still can't set up my email account, what is wrong?

    How can I set up my e mail account if I only get the same message that the userID or my password ar wrong and they are not?

    Use the correct credentials. If you are sure they are correct, contact your e-mail provider for help. The problem is not on the phone unless you have set something up incorrectly. The mail server is rejecting the ID / password combination you supplied.

  • What is the default identity store - and how can I set it?

    Hi,
    I'm running Webcenter on WLS, and using WLS and JPS for the authentication of users. On the WLS Console, if I go to Security Realms -> myrealm -> Providers, I have a list of four different providers.
    If I understand correctly, these four providers are my identity stores. How can I set one as the 'default' identity store? Or see which one is currently the default?
    The reason I'm asking is I have the following code in Webcenter to create a new user in the Active Directory:
          // Get the default identity store
          IdentityStore idStore = WCSecurityUtility.getDefaultIdentityStore();
          // Get the user manager object
          UserManager usermgr = idStore.getUserManager();
          usermgr.createUser(loginName, password.toCharArray(), propertySet);So I have a utility Java class which gives me the "default identity store". Now I want to change the WLS configuration so that the Active Directory in which I want to create new users is the "default" identity store.
    Thanks in advance for any help,
    Ludovic

    Hi,
    Thanks a lot for your help and providing this link. I'd actually already looked at that before, but I don't understand how it clarifies what the default identity store is. The relevant part is this, if I understand correctly:
    OPSS initializes the identity store service with the LDAP authenticator chosen from the list of configured LDAP authenticators according to the following algorithm:
    1.    Consider the subset of LDAP authenticators configured. Note that, since the context is assumed to contain at least one LDAP authenticator, this subset is not empty.
    2.    Within that subset, consider those that have set the maximum flag. The flag ordering used to compute this subset is the following:
        REQUIRED > REQUISITE > SUFFICIENT > OPTIONAL
        Again, this subset (of LDAPs realizing the maximum flag) is not empty.
    3.    Within that subset, consider the first configured in the context.Step (1) will match 2 external AD's and the built-in WLS LDAP, so 3 in total.
    Step (2) will still match 3 in total, as they are all 'sufficient'. In my setup, I need them all to be 'sufficient'.
    Step (3) is a step I don't understand. What is "the first configured in the context"? What context? Do they mean the one that was first created? In that case I can't change the default, right?
    Or do they mean "the first in the list on the WLS Console"?
    Best regards,
    Ludovic

  • Mac's and PCs can no longer connect after 10.4.10 Upgrade SMB Crash - Help

    This is my second post on this topic. I have read other similar threads, but none of the advice I have tried has worked so far. We have 4 PCs and 5 Macs at home that were networking nicely until we upgraded the G5 10.4.10. The G5 can browse and connect to any machine on the network. However, no other machine can connect to a shared folder on the G5.
    I installed a clean 10.4.10 on a second hard drive and it works fine. So that eliminates hardware and infrastructure. I really did not want to have to reinstall everything from scratch.
    I performed an Archive and Install and that did not work.
    1) On my G5 I turn on Personal or Windows File Sharing
    2) From another computer PC or Mac I attempt to connect to the shared files
    3) The connection is made most of the time and I can see the folders. However within a few minutes or the second time I attempt to browse the folders, I get an error.
    4) When I return to the G5, the Service is unchecked
    The console log is reporting...
    Aug 19 18:36:02 G5 crashdump14892: smbd crashed
    Aug 19 18:36:02 G5 crashdump14892: crash report written to: /Library/Logs/CrashReporter/smbd.crash.log
    Aug 19 18:59:51 G5 crashdump27414: AppleFileServer crashed
    Aug 19 18:59:52 G5 crashdump27414: crash report written to: /Library/Logs/CrashReporter/AppleFileServer.crash.log
    smbd will crash when attempting a connection from XP
    AppleFileServer will crash when attempting a connection from a Mac
    The AppleFileServer.crash.log reports (first few lines...)
    Binary Images Description:
    0x1000 - 0x132fff AppleFileServer /usr/sbin/AppleFileServer
    0x8fe00000 - 0x8fe52fff dyld 46.12 /usr/lib/dyld
    0x90000000 - 0x901bcfff libSystem.B.dylib /usr/lib/libSystem.B.dylib
    0x90214000 - 0x90219fff libmathCommon.A.dylib /usr/lib/system/libmathCommon.A.dylib
    0x907bb000 - 0x90894fff com.apple.CoreFoundation 6.4.7 (368.28) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
    0x908dd000 - 0x908ddfff com.apple.CoreServices 10.4 (???)

    Usually whan an Archive & Install doesn't work, it's very few things...
    Bad prefs/plists carried over.
    Some APP or kext or support file not replaced due to permissions, HD Errors, bad aliases, etc.
    Bad info in caches.

  • I have I phone 5 and I can't open iCloud after deleting me old one and tried to open a new one it didn't let me because it said it maxed out

    I have my phone is I phone5 and I had an account iCloud but I deleted along time ago and I have no idea what was my email address or user name or password , and tried to open a new one on my phone it won't let me because it said it maxed out and u can open iCloud one time, I need to open a new account so I can safe my information, 

    I've never seen an error discribing "maxed out". Please type in the exact error message you are seeing so I can maybe assist you further.

  • My iPad was changed to Suomi language and I can't set it back to English the settings are not the same so that does not help

    iPad changed to Suomi language can't set it back to English. The settings are not the same as the advice given by support???

    Just follow this:
    http://support.apple.com/kb/ht2371

  • Help Incomplete Time Machine Backup and I can't set ownership options

    Two days ago my iMac HD stopped working and I decided it was time to upgrade my machine so I purchased a new iMac with Mavericks installed. I seem to only have a partial Time Machine Backup located on my NAS drive, so I read various threads about how to manually retrieve files from the .inprogress file. I was able to browse the package contents and when I navigated to Macintosh HD the folder was greyed out and when I attempt to open the folder it looks empty. When I select get info the Macintosh HD folder shows almost 80GB and over 160,000 files inside. I tried copying the folder onto the desktop which failed and also onto an external drive formatted the same way as the NAS - Mac OS Extended (Journaled, Case Sensitive). Everytime I try it says something along the lines of me not having the ownership rights to copy the file over.
    I tried going to the NAS drive and the mounted sparsefile and couldn't figure out how to get the ignore ownership on this volume option. When I go to Disk Utility it says Owners Enabled Yes, I can't figure out how to turn that off to let me copy the file over. I tried some recommendations about creating an Alias to Macintosh HD and also setting up Automator actions Get Selected Finder Items > Get Folder Contents > Open Finder Items > Copy Finder Items (to desktop or external drive) both of these failed.
    I also don't understand why I can't view the files inside the greyed out Macintosh HD as get info shows many files inside. The sharing and permissions already says everyone can read. Is there anyway I can recover some of the files? It would be so great!
    Thanks for helping me.

    I solved the problem and I hope this solution can help others with incomplete Time Machine Backups.
    1. I made sure hidden files were shown by pasting the following line into Terminal:
    defaults write com.apple.finder AppleShowAllFiles -boolean true ; killall Finder
    2. On NAS drive I have a folder called Time Machine Backup and inside that folder it lists the different users with Time Machine Backups. I double clicked the user with the incomplete time machine backup to mount it.
    3. Once mounted there should be a folder called backups.backupdb > machine name > dateandtime.inprogress. I right click that .inprogress file and selected show package contents. This lead to another folder randomly named with numbers and text. Inside that folder you should see a greyed out Macintosh HD folder. The date of the greyed out Macintosh HD folder might read something like January 24th, 1984. This appears to be the date that the Macintosh 128k was first introduced. I read on another thread that the creation date of the folder is incorrectly set after a crash resulting in the greyed out folder.
    4. Due to the NAS having ownership issues I was not able to drag either the greyed out Macintosh HD or the folder above it to an external drive or the desktop of my new computer. Automator didn't work either. Here is what did work: I trashed the folder with the greyed out Macintosh HD inside from the NAS and dragged it from the trash onto my desktop. The move took a few hours to complete and the files were now all successfully on the new computer.
    5. Once on the desktop the Macintosh HD folder was still greyed out. The solution was to select in the finder: View > Show Path Bar, then search for any file you remember inside your backup. For example I searched the word download and files inside the greyed out Macintosh HD folder showed up. Left clicking the file confirmed the path, that it was from the greyed out Macintosh HD folder. Now you can simply right click one of the folders in the Path Bar and open in new tab if you have Mavericks. I still couldn't directly open the Macintosh HD folder in a new tab, but I could open any of the subfolders inside in a new tab, including the users which lets you access all the backup files. I tested in Mountain Lion that you can also choose Open in Enclosing Folder by right clicking the file that you searched for or right clicking the folder in the bottom of the Path Bar.
    6. Once I was done organizing backup files, I turned off hidden files by pasting this line into Terminal:
    defaults write com.apple.finder AppleShowAllFiles -boolean false ; killall Finder
    This took me days to figure out how to make use of an .inprogress file and greyed out Macintosh HD folder.
    Hope this helps!!!

Maybe you are looking for