Problem with Invisible Caret in JTextPane

Hi there,
Using latest JDK, I'm running into the following problem - a JTextPane, placed in a JScrollPane, made editable by doubleclicking on it, doesn't show the caret after having been made editable.
private class EditableTextPane extends JTextPane{
          private String preEditString;          
          protected EditableTextPane(){
               super();
               setFont( TicketPanel.ticketFont );
               setMargin( new Insets( 24, 5, 5, 5 ) );
               setEditable( false );
               addMouseListener( new MouseAdapter(){
                    public void mouseClicked( MouseEvent e ){
                         if( e.getClickCount() == 2 ){
                              if( !isEditable() ){
                                   preEditString = getText();
                                   setEditable( true );
//added these two in an attempt to solve the problem
                                   EditableTextPane.this.requestFocus();
                                   EditableTextPane.this.setCaretPosition( getText().length() );
                              else{
                                   performEdit();
                                   setEditable( false );
          public void setText( String s ){
               super.setText( s );
               if( isEditable() )
                    setEditable( false );
               preEditString = null;
          private void performEdit(){
               if( preEditString == null )
                    return;
          public void setEditable( boolean b ){
               super.setEditable( b );
               setForeground( b ? Color.blue : Color.black );
     }Any ideas?
Thanks!
Alex

Thanks for the post camickr, didn't think of that, but unfortunately that didn't do it. Here's the SSCE:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class TestClass {
     public static void main( String args[] ){
          JFrame f = new JFrame();
          EditableTextPane e = new EditableTextPane();
          e.setText( "This is some test text" );
          JScrollPane p = new JScrollPane( e, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS );
          f.getContentPane().add( p );
          f.setSize( 400, 400 );
          f.setVisible( true );
     private static class EditableTextPane extends JTextPane{
          private static final long serialVersionUID = 1L;
          private String preEditString;          
          protected EditableTextPane(){
               super();
               setMargin( new Insets( 24, 5, 5, 5 ) );
               setEditable( false );
               addMouseListener( new MouseAdapter(){
                    public void mouseClicked( MouseEvent e ){
                         if( e.getClickCount() == 2 ){
                              if( !isEditable() ){
                                   preEditString = getText();
                                   setEditable( true );                              
                                   EditableTextPane.this.requestFocus();
                                   SwingUtilities.invokeLater( new Runnable(){
                                        public void run(){
                                             EditableTextPane.this.setCaretPosition( getText().length() );
                              else{
                                   performEdit();
                                   setEditable( false );
          public void setText( String s ){
               super.setText( s );
               if( isEditable() )
                    setEditable( false );
               preEditString = null;
          private void performEdit(){
               if( preEditString == null )
                    return;
          public void setEditable( boolean b ){
               super.setEditable( b );
               setForeground( b ? Color.blue : Color.black );
}Thanks again.
Alex

Similar Messages

  • Problems with dynamic resize of JTextPane...

    Dear Java Gurus,
    I am quite new to Java, so I am strill struggling to understand the details about it all...but thanks
    to a lot of very helpful people in this forum, the bits and pieces start to come together, even
    though it's obvious that I now need guidance again :-)
    I posted yesterday regarding how I could implement a JTextPane that dynamically would change
    its height. This means that the JTextPane has a fixed width, but when the user types in text, its sets
    its own height to fit the enterred text. A very kind person posted some code that more or less looks
    like the code below, with a few changes:
    package test;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.text.*;
    import java.awt.*;
    public class test {   
      public static void main(String[] argv)
        final JFrame frame = new JFrame();           
        JTextPane pane= new JTextPane("Test ");           
        pane.getDocument().addDocumentListener(new DocumentListener()
          public void insertUpdate(DocumentEvent e) {proccess(e.getDocument());}         
          public void removeUpdate(DocumentEvent e) {proccess(e.getDocument());}         
          public void changedUpdate(DocumentEvent e) {proccess(e.getDocument());}   
          private void proccess(Document doc)
            Dimension size = pane.getPreferredSize();     
            pane.setSize(150, (int)size.getHeight());    
            frame.validate();    
        frame.getContentPane().add(new JScrollPane(pane), BorderLayout.SOUTH);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);      
        frame.setSize(400, 300);       
        frame.setLocationRelativeTo(null);       
        frame.setVisible(true);   
    }The code works just fine, but has a small "feature" in it that I don't understand. It appears
    like the resizing has a delay in it. If you enter the JTextPane and press return once, the text
    pane will not resize. If you press backspace, the cursor will move back up, but now the
    text pane will increase its size, to fit the size of the previos text size. If you now press the
    return key again, the text pane shrinks by one line.
    In other words...it seems the resizing is always delayed by one, as if the last entered
    character is not taken into account when preferredSize() returns the value. As I don't yet
    understand in which order events are generated and handled, does anybody see what I
    need to change in order to get rid of this slightly disturbing delay? :-)
    Any comments would be highly appreciated!
    Best regards,
    Xxodus.

    You try to ask size before edition process is complete.
    Try to change size after finishing processing of document change event.
    Like this.
          private void proccess(Document doc)
              SwingUtilities.invokeLater(new Runnable() {
                  public void run() {
                      Dimension size = pane.getPreferredSize();
                      pane.setSize(150, (int)size.getHeight());
                      frame.validate();
          }regards,
    Stas

  • Problem with invisible subfolders in favorites

    Hi,
    In NW2004s we can't see any subfolders with workbooks, queries in the user's favorites.
    We tried the following :
    1) Logon via Bex, save workbook, create subfolder in favorites, save it there. Next time you logon the subfolder is gone and the favorite can't be found. I checked SMEN_BUFFC, the favorite is not physically there neither although Bex didn't give an error message while saving.
    2) Create a subfolder in the SAPGUI favorite structure manually with a workbook assigned to it, afterwards we logon in Bex and the subfolder is not visible neither.
    This can't be an authorisation problem as it doesn't work neither with SAP_ALL assigned. I'm using BI 7.0 FEP11 at this moment. I tried to upgrade to FEP12 but this screwed up my Bex completely. Also, we have another collegue with FEP12 working and the problem remains.
    Since this symptom doesn't ring a bell on SDN, OSS searches I'm wondering if someone else experienced this and if someone could solve this ?
    thanks

    Hi Krishna ,
    I always make bookmark, when I want to save a new link. Problem is that suddenly after 2 years system BW stopped also make a note that this issue is with "new reports "
    Puru
    Edited by: Purushotham on Jul 7, 2011 11:51 AM

  • Problem with timer/ caret position

    I�m developing a virtual keyboard "mobile phone" like (2->a->b->c)
    For that i need a timer.
    The problem is than when the timer fires the associated text componnent loose is caret position.
    Any ideas?

    import java.awt.event.KeyEvent;
    public class DemoCaret extends javax.swing.JFrame {
        private final long DELAYKEYBORAD = 500;
        private  String cars = "ABCDE";
        private int ntics = 0;
        private java.util.Timer timer = null;
        private java.util.TimerTask timertask = null;
        private char last_car;
        private javax.swing.JButton jBnok;
        private javax.swing.JButton jBok;
        private javax.swing.JTextField jTextField1;
        public DemoCaret() {
            timer = new java.util.Timer();
            initComponents();
        private void initComponents() {
            jTextField1 = new javax.swing.JTextField();
            jBok = new javax.swing.JButton();
            jBnok = new javax.swing.JButton();
            getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            jTextField1.addKeyListener(new java.awt.event.KeyAdapter() {
                public void keyPressed(java.awt.event.KeyEvent evt) {
                    jTextField1KeyPressed(evt);
                public void keyReleased(java.awt.event.KeyEvent evt) {
                    jTextField1KeyReleased(evt);
                public void keyTyped(java.awt.event.KeyEvent evt) {
                    jTextField1KeyTyped(evt);
            getContentPane().add(jTextField1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 160, -1));
            jBok.setText("CaretOk");
            jBok.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jBokActionPerformed(evt);
            getContentPane().add(jBok, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 40, -1, -1));
            jBnok.setText("CaretNok");
            jBnok.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jBnokActionPerformed(evt);
            getContentPane().add(jBnok, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 40, -1, -1));
            pack();
        private void jTextField1KeyTyped(java.awt.event.KeyEvent evt) {                                    
            System.out.println("Typed " +evt.getKeyChar() + " CARET = " + jTextField1.getCaretPosition()); 
        private void jTextField1KeyReleased(java.awt.event.KeyEvent evt) {                                       
             System.out.println("Released " +evt.getKeyChar() + " CARET = " + jTextField1.getCaretPosition()); 
        private void jTextField1KeyPressed(java.awt.event.KeyEvent evt) {                                      
             System.out.println("Pressed " +evt.getKeyChar());        
          private void restartTimer() {
           // final int pos= jTextField1.getCaretPosition();       
            timertask = new java.util.TimerTask() {           
                public void run() {  
                    Typed();    
                    Release();
               //     jTextField1.setCaretPosition(pos + 1); // work ok
                    cancel();
            timer.schedule(timertask, DELAYKEYBORAD);       
        private void jBnokActionPerformed(java.awt.event.ActionEvent evt) {                                     
               if(timertask != null) timertask.cancel(); // parar o timer
               char car = cars.charAt(ntics);
               ntics = (++ntics) % cars.length();
               Pressed(car);
               restartTimer();
        private void jBokActionPerformed(java.awt.event.ActionEvent evt) {                                    
               if(timertask != null) timertask.cancel(); // parar o timer 
               char car = cars.charAt(ntics);
               ntics = (++ntics) % cars.length();
               Pressed(car);
               Typed();
               Release();
         private void Typed() {                   
              KeyEvent ke = new KeyEvent(jTextField1, KeyEvent.KEY_TYPED, System.currentTimeMillis(),  0, KeyEvent.VK_UNDEFINED, last_car );
              jTextField1.dispatchEvent(ke);
         private void Release() {            
                  KeyEvent kr = new KeyEvent(jTextField1, KeyEvent.KEY_RELEASED, System.currentTimeMillis(), 0, KeyEvent.VK_UNDEFINED, last_car );            
                  jTextField1.dispatchEvent(kr);                              
        private void Pressed(char car) {
              last_car = car;
               KeyEvent ke = new KeyEvent(jTextField1, KeyEvent.KEY_PRESSED, System.currentTimeMillis(),  0, KeyEvent.VK_UNDEFINED, last_car );                
               jTextField1.dispatchEvent(ke);                      
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new DemoCaret().setVisible(true);
    }

  • Solved: InDesign CC: Problems with text in text box: text flows around invisible object

    I just upgraded from CS4 to CC. I have two problems with text in some text boxes:
    The text seems to flow around invisible object that I cannot find or delete. It's as if there is a photo or other object behind the text box; but when I press COMMAND-a to select all, I don't see any such object.
    When I move this text box, the layout of the text within changes. For example, when the box is high on my spread, the text flows correctly within the box; but when I move it down, it flows around that hidden other object. For another example, when the box is low on the page, the text starts at the top of the box; but when I move the text box up, the text starts somewhere in the middle of the box.
    I have checked margins of the text box and the paragraph options of the text paragraphs (margins, indents, alignments). They all look OK.
    If I modify the text box, checking the box "Ignore text wrap", then the problem goes away; but then the text also will not flow around a real object that I want it to flow around.
    Solution:
    There were objects in a hidden layer on that one spread. It seems that in CS4 when you "select all" you would also select objects in hidden layers; but in CC it doesn't.

    Arthur, Garry
    Would be great if you could send the files as attachment in an email to [email protected]
    Else, you may post here using these steps: http://forums.adobe.com/message/3994281
    Thanks!
    - Neeraj

  • Problem with JTextPane and StateInvariantError

    Hi. I am having a problem with JTextPanes and changing only certain text to bold. I am writing a chat program and would like to allow users to make certain text in their entries bold. The best way I can think of to do this is to add <b> and </b> tags to the beginning and end of any text that is to be bold. When the other client receives the message, the program will take out all of the <b> and </b> tags and display any text between them as bold (or italic with <i> and </i>). I've searched the forums a lot and figured out several ways to make the text bold, and several ways to determine which text is bold before sending the text, but none that work together. Currently, I add the bold tags with this code: (note: messageDoc is a StyledDocument and messageText is a JTextPane)
    public String getMessageText() {
              String text = null;
              boolean bold = false, italic = false;
              for (int i = 0; i < messageDoc.getLength(); i++) {
                   messageText.setCaretPosition(i);
                   if (StyleConstants.isBold(messageDoc.getCharacterElement(i).getAttributes()) && !bold) {
                        bold = true;
                        if (text != null) {
                             text = text + "<b>";
                        else {
                             text = "<b>";
                   else if (StyleConstants.isBold(messageDoc.getCharacterElement(i).getAttributes()) && bold) {
                        // Do nothing
                   else if (!StyleConstants.isBold(messageDoc.getCharacterElement(i).getAttributes()) && bold) {
                        bold = false;
                        if (text != null) {
                             text = text + "</b>";
                        else {
                             text = "</b>";
                   try {
                        if (text != null) {
                             text = text + messageDoc.getText(i,1);
                        else {
                             text = messageDoc.getText(i, 1);
                   catch (BadLocationException e) {
                        System.out.println("An error occurred while getting the text from the message document");
                        e.printStackTrace();
              return text;
         } // end getMessageText()When the message is sent to the other client, the program searches through the received message and changes the text between the bold tags to bold. This seems as if it should work, but as soon as I click on the bold button, I get a StateInvariantError. The code for my button is:
    public void actionPerformed(ActionEvent evt) {
              if (evt.getSource() == bold) {
                   MutableAttributeSet bold = new SimpleAttributeSet();
                   StyleConstants.setBold(bold, true);
                   messageText.getStyledDocument().setCharacterAttributes(messageText.getSelectionStart(), messageText.getSelectionStart() - messageText.getSelectionEnd() - 1, bold, false);
         } //end actionPerformed()Can anyone help me to figure out why this error is being thrown? I have searched for a while to figure out this way of doing what I'm trying to do and I've found out that a StateInvariantError has been reported as a bug in several different circumstances but not in relation to this. Or, if there is a better way to add and check the style of the text that would be great as well. Any help is much appreciated, thanks in advance.

    Swing related questions should be posted in the Swing forum.
    Can't tell from you code what the problem is because I don't know the context of how each method is invoked. But it would seem like you are trying to query the data in the Document while the Document is being updated. Try wrapping the getMessageText() method is a SwingUtilities.invokeLater().
    There is no need to write custom code for a Bold Action you can just use:
    JButton bold = new JButton( new StyledEditorKit.BoldAction() );Also your code to build the text String is not very efficient. You should not be using string concatenation to append text to the string. You should be using a StringBuffer or StringBuilder.

  • Choosing between external and partner application and problem with login

    We have an application on Oracle App Server 10.1.3.3 and we have an OID server.
    I had taken this for granted that I should define the application as 'Partner Application' and not external application for single sign on.
    Now that we need the 'PASSWORD' retrieved by application, we are considering defining it as an external application.
    There are at least two problems I have encountered defining the application as external:
    1. 'pageConfig:serverDate' is among the login form's inputs in the login page, but I can't set it in orasso 'Edit External Applications' page
    2. After login using SSO as external application and when I click on the application's new link, the login page is shown with the username and password field filled, but I have to click on login button anyway (no automatic and invisible login).
    I will be very grateful if someone gives a general view on the differences between external and partner, whether in this case external has to be used or partner and finally give some comment on my specific problem with login button and manual login.
    Thank you

    Just some information :
    - The problem with LOGIN page exists. I don't have that problem with for example GMAIL when defined as external application, but with my applications in Oracle Application Server.
    - There is also another thing I don't understand. The link to external application is something like:
    javascript:open_jwindow('../ealogin?ID=76D4766','76');
    and couldn't be executed outside pls/orasso
    in other words we can't give that to our users, can we? They should login to orassso and see that?
    We don't want to involve them in Identity Management...
    Any help is appreciated....
    Regards

  • Problem with focus and selecting text in jtextfield

    I have problem with jtexfield. I know that solution will be very simple but I can't figure it out.
    This is simplified version of situation:
    I have a jframe, jtextfield and jbutton. User can put numbers (0-10000) separated with commas to textfield and save those numbers by pressing jbutton.
    When jbutton is pressed I have a validator which checks that jtextfield contains only numbers and commas. If validator sees that there are invalid characters, a messagebox is launched which tells to user whats wrong.
    Now comes the tricky part.
    When user presses ok from messagebox, jtextfield should select the character which validator said was invalid so that user can replace it by pressing a number or comma.
    I have the invalid character, but how can you get the focus to jtextfield and select only the character which was invalid?
    I tried requestFocus(), but it selected whole text in jtextfield and after that command I couldn't set selected text. I tried with commands setSelectionStart(int), setSelectionEnd(int) and select(int,int).
    Then I tried to use Caret and select text with that. It selected the character I wanted, but the focus wasn't really there because it didn't have keyFocus (or something like that).
    Is there a simple way of doing this?

    textField.requestFocusInWindow();
    textField.select(...);The above should work, although read the API on the select(...) method for the newer recommended approach on how to do selection.
    If you need further help then you need to create a "Short, Self Contained, Compilable and Executable, Example Program (SSCCE)",
    see http://homepage1.nifty.com/algafield/sscce.html,
    that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
    Don't forget to use the "Code Formatting Tags",
    see http://forum.java.sun.com/help.jspa?sec=formatting,
    so the posted code retains its original formatting.

  • Memory problem with JTextFields

    Hello,
    I have a wierd problem with JTextField and the memory.
    I need to fill a JPanel with different Components (including JTextFields), then do some calculation, remove the Components and filling the JPanel again.
    When i so this too often my i get an OutOfMemory Exception. I narrowed to problem down and wrote a small sample program to demonstrate the problem.
    When i call the method doIT (where the Panel is repeatedly filled) from the main-function everything works fine, but when it is called as a result from the GUI-Button-Event the memory for the JTextFields is not freed (even the call of the Garbage collector changes nothing)
    When i only use JButtons to fill the Panel everything works fine.
    Has anyone an idea why this problem occurs and how i can work around it?
    [Edit] I tested it whith java 1.5.0_06, 1.5.0_11, 1.6.0_02
    Thanks
    Marc
    import java.awt.Frame;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.lang.management.ManagementFactory;
    import java.lang.management.MemoryUsage;
    import javax.swing.JButton;
    import javax.swing.JDialog;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    public class MemoryTestDLG extends JDialog {
         public MemoryTestDLG(Frame owner) {
              // create Dialog with one Button that calls the testMethod
              super(owner);
              JButton b = new JButton("doIT ...");
              b.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        doIT();
                        setVisible(false);
              getContentPane().add(b);
              pack();
         public void doIT() {
              // Testmethod that fills a JPanel 20 times with Components and clears it
              // again
              JPanel p = new JPanel();
              long memUse1 = 0;
              long memUse2 = 0;
              long memUseTemp = 0;
              for (int count = 0; count < 20; count++) {
                   // Clear the panel
                   p.removeAll();
                   // Get memory usage before the task
                   Runtime.getRuntime().gc();
                   memUse1 = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage()
                             .getUsed();
                   // Fill Panel with components
                   for (int i = 0; i < 200; i++) {
                        // The Buttons seem to be released without any problem
                        p.add(new JButton("test" + Math.random()));
                        // JTextFields are not released when used from the dialog.
                        p.add(new JTextField("test " + Math.random()));
                   // get memory usage after the task
                   Runtime.getRuntime().gc();
                   memUseTemp = memUse2;
                   memUse2 = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage()
                             .getUsed();
                   // print Memory results
                   System.out.println("Memory Usage: " + f(memUse1) + "   ->"
                             + f(memUse2) + " [ Used:" + f(memUse2 - memUse1)
                             + " ] [ Freed: " + f(memUseTemp - memUse1) + "]");
         public String f(long m) // formats the output
              String s = "" + m;
              while (s.length() < 8)
                   s = " " + s;
              return s;
         public static void main(String[] args) {
              MemoryTestDLG d = new MemoryTestDLG(null);
              System.out
                        .println("------------------ Direct Call (all is OK) -------------------");
              d.doIT(); // Memory is freed with every call to JPanel.removeAll()
              System.out
                        .println("------------ Call from Dialog (memory is not freed) -------------");
              // The Memory keeps blocked
              d.setModal(true);
              d.setVisible(true);
              System.exit(0);
    }Message was edited by:
    marcvomorc

    Thank you for your answer,
    In this sample the programm does not run out of memory. But when you look at the output you see, that in the first run (direct call) the memory ist freed immediately when tha panel is cleared but in the second run (from the Button) the memory usage is getting bigger and bigger. Wenn you change the number of components to 2000 (4000)
    // Fill Panel with components
            for (int i = 0; i < 2000; i++) {
                // The Buttons seem to be released without any problem
    //... ...and use the default memory settings (69mb heap) the programm runns out of memory.
    I get the following output:
    ------------------ Direct Call (all is OK) -------------------
    Memory Usage:   445504   -> 8121016 [ Used: 7675512 ] [ Freed:  -445504]
    Memory Usage:   617352   -> 8114336 [ Used: 7496984 ] [ Freed:  7503664]
    Memory Usage:   810488   -> 8491768 [ Used: 7681280 ] [ Freed:  7303848]
    Memory Usage:   943704   -> 8114976 [ Used: 7171272 ] [ Freed:  7548064]
    Memory Usage:   836760   -> 8505072 [ Used: 7668312 ] [ Freed:  7278216]
    Memory Usage:   978352   -> 8114784 [ Used: 7136432 ] [ Freed:  7526720]
    Memory Usage:   835552   -> 8498288 [ Used: 7662736 ] [ Freed:  7279232]
    Memory Usage:   977096   -> 8114312 [ Used: 7137216 ] [ Freed:  7521192]
    Memory Usage:   835640   -> 8498376 [ Used: 7662736 ] [ Freed:  7278672]
    Memory Usage:   977296   -> 8115000 [ Used: 7137704 ] [ Freed:  7521080]
    Memory Usage:   835392   -> 8504872 [ Used: 7669480 ] [ Freed:  7279608]
    Memory Usage:   976968   -> 8115192 [ Used: 7138224 ] [ Freed:  7527904]
    Memory Usage:   836224   -> 8501624 [ Used: 7665400 ] [ Freed:  7278968]
    Memory Usage:   977840   -> 8115120 [ Used: 7137280 ] [ Freed:  7523784]
    Memory Usage:   835664   -> 8498256 [ Used: 7662592 ] [ Freed:  7279456]
    Memory Usage:   976856   -> 8114384 [ Used: 7137528 ] [ Freed:  7521400]
    Memory Usage:   835784   -> 8502848 [ Used: 7667064 ] [ Freed:  7278600]
    Memory Usage:   977360   -> 8114592 [ Used: 7137232 ] [ Freed:  7525488]
    Memory Usage:   835496   -> 8502720 [ Used: 7667224 ] [ Freed:  7279096]
    Memory Usage:   976440   -> 8115128 [ Used: 7138688 ] [ Freed:  7526280]
    ------------ Call from Dialog (memory is not freed) -------------
    Memory Usage:   866504   -> 8784320 [ Used: 7917816 ] [ Freed:  -866504]
    Memory Usage:  7480760   ->14631152 [ Used: 7150392 ] [ Freed:  1303560]
    Memory Usage: 14245264   ->22127104 [ Used: 7881840 ] [ Freed:   385888]
    Memory Usage: 19302896   ->27190744 [ Used: 7887848 ] [ Freed:  2824208]
    Memory Usage: 27190744   ->35073944 [ Used: 7883200 ] [ Freed:        0]
    Memory Usage: 31856624   ->39740176 [ Used: 7883552 ] [ Freed:  3217320]
    Memory Usage: 39740176   ->47623040 [ Used: 7882864 ] [ Freed:        0]
    Memory Usage: 44410480   ->52293864 [ Used: 7883384 ] [ Freed:  3212560]
    Memory Usage: 52293864   ->58569304 [ Used: 6275440 ] [ Freed:        0]
    Memory Usage: 58569304   ->64846400 [ Used: 6277096 ] [ Freed:        0]
    Exception occurred during event dispatching:
    java.lang.OutOfMemoryError: Java heap spacewhen I outcomment the adding of the JButtons the amount of freed memory is 0 in the second run. So my guess is, that there is a problem with freeing the memory for the JTextFields.
    Memory Usage:   447832   -> 6509960 [ Used: 6062128 ] [ Freed:  6332768]
    Memory Usage:   722776   -> 6785632 [ Used: 6062856 ] [ Freed:  5787184]
    ------------ Call from Dialog (memory is not freed) -------------
    Memory Usage:   468880   -> 6770240 [ Used: 6301360 ] [ Freed:  -468880]
    Memory Usage:  6770240   ->13016264 [ Used: 6246024 ] [ Freed:        0]
    Memory Usage: 13016264   ->19297080 [ Used: 6280816 ] [ Freed:        0]
    Memory Usage: 19297080   ->25570152 [ Used: 6273072 ] [ Freed:        0]
    Memory Usage: 25570152   ->31849160 [ Used: 6279008 ] [ Freed:        0]
    Memory Usage: 31849160   ->38124368 [ Used: 6275208 ] [ Freed:        0]
    Memory Usage: 38124368   ->44402072 [ Used: 6277704 ] [ Freed:        0]
    Memory Usage: 44402072   ->50677928 [ Used: 6275856 ] [ Freed:        0]
    Memory Usage: 50677928   ->56955880 [ Used: 6277952 ] [ Freed:        0]
    Memory Usage: 56955880   ->63232152 [ Used: 6276272 ] [ Freed:        0]
    Exception occurred during event dispatching:
    java.lang.OutOfMemoryError: Java heap spaceAdditionally the JPanel I am using is not displayed on the screen. It stays invisible the whole time, but i cannot work around that, because the calculation is depending on the values being in components on the JPanel)
    Marc

  • Problem with columns in the middle of my book

    I am writing my second book with Pages 2.02 and have run into a problem with columns. I want to add a long list of items as a list with check boxes for readers to check off. If I paste in enough text for three or four pages of two columns it gets messed up in various ways - the text flows into the following text if I don't use section breaks at the end instead of layout breaks, if I use section breaks it solves that one, but if I add anything to the list it changes all the columns across the pages so that one or several of the pages has way less in the right column than in the left. So far the left column fills the entire page all the time, but the right column has lots of spaces. If I switch back and forth from one column to two, it fixes it. If I add text before the list section it messes everything up again and because there is a section break I end up with a little bit of text on the last page and a huge gap before the single column part that follows.
    Does anyone know how to get reliable results that will not mess me up when adding content before the list or in the list itself?
    PowerBook G4   Mac OS X (10.4.8)  

    Hi Cymru,
    Thank you for thinking about my problems. I guess I s half asleep when I posted and it didn't make sense.
    I have so far 77 pages of the book divided into several chapters via section breaks. Inside the 5th section there is almost two pages of paragraphs. Those paragraphs could become 3.75 pages or who knows how long before the list of items. The list of items is 226 items separated by carriage returns and go from one word with 5 characters to 7 words and 34 characters. It needs to be a list with check boxes before them so that the user can check off the items that apply. It is a workbook about turning bipolar into an advantage and is currently 8.5 x 11 and printed on my laser printer for now, but when completed will be more like 8 x 10, so it needs to resize without major hassles.
    I have tried every combination of breaks to get the list to flow in two columns, but perhaps have not done the correct combination. I show invisibles and layout. At the end of my paragraphs I do a paragraph return. I then do either a section break or a layout break, followed by a paragraph return and another layout or section break. I then put my curser before the paragraph break, but after the first section/paragraph break, and set columns to 2, evenly divided by default with 3.2026" columns and .3375" gutter, but I want them to change with page size in the future.
    Once set up, I copy the text out of BBEdit and paste into the left column. It takes up several pages because it is formatted to do double spaces, so I use one of my styles to make it bold and single spaces. I then apply list style with image bullets and one of the default box images that came with Pages. There are 5 items in each column on the first page because it is close to the bottom, but flows into the next two pages. (with text edits it might end up 20 items in each column on the first page) The second page has 39 items in each column and the last page has 8 items in the left column only, but if with section breaks take up the whole page and the next paragraphs start on the next page. If I then add items to the list, every page gets messed up and the second page ends up with 39 on the left column and less items in the right column for each added item.
    If I use layout breaks instead of section breaks, the paragraphs following my lists (now with only one column) end up under the list. What that means is I can see my bold items, but beneath them are my paragraphs that belong after the list. I can see the layout break at the end of the list, but the columns that are shown as part of the 'view layout' are visible right over the single column text also for the rest of the page. The only way to solve that is to go with section breaks and put up with the gap from the end of the list to the following paragraphs.
    I hope this makes more sense.
    Tom
    PowerBook G4   Mac OS X (10.4.8)  

  • Problem with JavaScript getPageNumWords

    Using AR7.0.9. I have a problem with the JavaScript method doc.getPageNumWords and the associated machinery for keeping
    track of the words on a page. And I'm wondering if it's a bug,
    or something which is not properly defined by the PDF spec.
    The situation is illustrated by the test file:
    http://www.amrita-cfd.org/4adobe/word-count/test1.pdf
    It would appear that the word machinery is aware of
    the text in the /Xform's used by /Widget annotations.
    But the text is locked in the first time the
    machinery is activated on a page i.e. visible /Widget's
    are included and invisible ones are ignored.
    But since /Widget's can be turned on and off
    it's then possible for the word-cache to become out of sync
    with respect to the visible text on the page.
    Note that a widget which is invisible when
    the document is opened, but visible when
    doc.getPageNumWords is first called is included
    in the word list i.e. the word-cache is computed
    once in a just-in-time fashion.
    Is the above a known problem, or an inconsistency that has
    not been considered before? One solution would be
    to add an optional parameter to getPageNumWords
    that would force the word-cache to be recomputed,
    when needed. Thus removing the need to keep automatic
    track of which widgets to include and exclude.
    James Quirk

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • I had a problem with my mouse double(multiple) clicking when I didn't want it to, now pressing enter in a window like this will close the current window and open one of my Taboo sites, and the cursor keys don't work.

    This happens in any text entry window, but there is no problem with Wordpad or Word or other apps, just in Firefox. It's like the keyboard mapping has gotten fouled up in Firefox, but I can't find where I might check what is going on.

    You may have '''Switched ON Caret Browsing'''. press '''F7 (on Mac: fn + F7)''' to toggle '''Caret Browsing ON/OFF'''
    * click '''Firefox''' button and click '''Options''' -> Advanced -> General -> remove
    Checkmark from '''Always use the cursor keys to navigate within pages'''
    * http://kb.mozillazine.org/Scrolling_with_arrow_keys_no_longer_works
    * http://kb.mozillazine.org/Accessibility_features_of_Firefox
    Check and tell if its working.

  • How to get exact height of HTML line with SUB tag in JTextPane?

    Hi, this is my first post. I`ve been searching forum for an answer for a week, but didn`t find one.
    I have HTMLDocument inside JTextPane(exacty inside my class that extends it - MyTextPane). I want to do some custom painting in JTextPane so I need to be able to know exact pixel witdh for each line in the document. Easy except one thing, when I use SUB tag the width of the line cannot be simply calculated using FontMetrics, because I don`t know if the text inside SUB tag has lower font size and I don`t know its Y offset to normal line.
    I tried get these information from HTMLDocument using attributes from leafElements representing lines, but there seems to be a problem too.
    I pass this text:
    "(1) Line<SUB>jW</SUB><BR>(2) TextB"
    to setText method of MyTextPane, this method is overriden so it changes text Font
    public void setText(String s) {   
      super.setText(s);   
      setJTextPaneFont(this, new Font("Arial",Font.PLAIN,36), Color.black);
    }This is how the Element Structure looks like:
    Format is Element +": "+elementText+"|"+fontFamily+" "+fontSize
    BranchElement(html) 0,22: \n(1)?LinejW (2)?TextB\n|Monospaced 12
    ---BranchElement(head) 0,1: \n|Monospaced 12
    ------BranchElement(p-implied) 0,1: \n|Monospaced 12
    ---------LeafElement(content) 0,1: \n|Arial 36
    ---BranchElement(body) 1,22: (1) LinejW (2) TextB\n|Monospaced 12
    ------BranchElement(p-implied) 1,22: (1) LinejW (2) TextB\n|Monospaced 12
    ---------LeafElement(content) 1,9: (1) Line|Arial 36
    ---------LeafElement(content) 9,11: jW|Arial 36 <-----------THIS IS THE LOWER INDEX
    ---------LeafElement(content) 11,12: |Arial 36 <-----------THIS IS just space character '\u020'
    ---------LeafElement(content) 12,21: (2) TextB|Arial 36
    ---------LeafElement(content) 21,22: \n|Arial 36
    The height of Arial 36 is according to FontMetrics 43(and it really is), but height of the lowerIndex is just 40 pixels(on the screen), not 43 as I would expect. And I still dont have offset, where does the lower index starts paint itself.
    Is there any problem with my setText method, so that it changes font style for LOWER INDEX?
    I am using JTextPane as notEditable, with just one font style for entire document.
    Any suggestion?

    Is there any other way to get these information. I just found that I need that information before I put text it in the document.
    For example I am would like to generate lines:
    paragraph1 - text1
                             text2
    paragraph2 - text1
                             text2
                             text3
    paragraph3<SUB>some note</SUB> - text1
                                                                           text2
    normal text line
    I know what font line will be and I know its AttributeSet. I am trying to get appropriate number of spaces (or left indent) for text2,text3...lines. Then I will pass that string to setText method of JTextPane.
    I am unable to get appropriate width for "paragraph3<SUB>some note</SUB> - ", since text in SUB tag uses probably different font size.
    I am really sorry to bother again. I will think twice what I need before I posting.
    You`ve been very helpful so far Stas.
    Thanks.

  • Problem with PnP devices, Unknown device, error code:28

    Hello, my USB Mass Storage Device Not Recognized( Flash drive- HP v156w, 16 GB)
     Full story : I opened flash disk,  started  to loading and opening files very slow, suddenly all writing, names of the files become unreadable. I took off the flash disk and try again. I got the message- disk have to be formated to be used
    again. After a lot of try I got this message:
     Unknown device doesn't have a driver ; and Problem with PnP devices when i run trouble shoot in devices and printers on my Sony VAIO laptop( Windows 8, 64 bit), and error code:28 for unknown device doesn't have a driver.
    Do other usb devices work ok in the same usb port? - yes
    Has someone else/or you used it on another pc?- yes
    Does it work ok on a different pc?  - the same problem
    Did you pull it out with using 'Safely Remove Hardware'? -  yes, a lot of time after its become invisible, unknoun
    Was it previously working ok with your W8 laptop? - never tried befor
    Disk Management can't see the drive.
    device manager:
    usb device with yellow sine and instead name strange sines
    divice tipe - other devices
    manufacturer - unknown
    location- on USB Mass Storage Device
    status: The drivers for this device are not installed. (Code 28)
    To find a driver for this device, click Update Driver.
    I have done that -
      "open device manager make sure show hidden devices is ticked and right click on all the USB hidden devices and unistall them. once done reboot and put in the flash drive again and see if windows finds it."
    situation the same(((( Disk Management can't see the drive.
    please if any one know the fix please help
    Its very important info for me on the flash disk.

    I'd ask them over here.
    http://answers.microsoft.com/en-us/windows/forum/windows_8?tab=Threads
    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows]
    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

  • Airport Xtreme problems with 10.5 but not 10.4.11 or 10.3.9

    I have a one-year old Airport Extreme (801.11n) that connects generally well with my Macs running 10.3.9 (an 800MHz iMac), 10.4.11 (MacBook Pro). However, it doesn't connect well with my Macs running 10.5.3 (iMac G5 and MacBook). The iMac G5 can see the base station but the connection always times out. The MacBook can see the base station, connect to it, but can't hold the connection for a long period of time and then can't reconnect after that unless I reboot the machine.
    I am beginning to think the Airport itself is getting flaky. This morning the iMac 800 MHz lost connection to the base station and couldn't get it back for about 30 min (despite repeated tries on my part). When I was troubleshooting this, my children (the iMac 800 MHz is their computer) told me that they had been having intermittent problems with wireless over the last few months...
    Any advice? Thanks to anyone who can help.

    Exactly the same problem with me.
    Mac mini (on 10.4.11) and Imac (on 10.5.2) had no problems.
    MacBook Pro (on 10.5.3) keeps dropping off the internet. I can see the network, it says I'm connected to the internet but just can't browse.
    It comes up for a few minutes - then it drops out again.
    A temp fix is by forcing the Extreme to 802.11b/g.
    It's an invisible feature in Airport Utility.
    Go to the wireless tab, and hold "control" down when clicking on the drop down menu.
    Select, restart and then it should work - admittedly at lower speeds.
    Hopefully the next Software Update will fix the problem.
    Another fix I've heard about is to let your modem control the PPoE settings rather than putting the connection details into the Extreme.
    Haven't tried it, but it's worth a shot.
    Just remember to change the internet connection settings in the Extreme to connect via ethernet rather than PPoE.
    Hope this helps.

Maybe you are looking for