Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

JTextField hangs and freezes program when using active rendering.



Hi all,
    I saw something in a forum that was posted about a year ago, but there weren't any replies. I'm hoping that someone might know why this is happening and perhaps a way to fix it.

http://lists.apple.com/archives/Java-dev/2007/Feb/msg00286.html

This seems to work fine in Windows (XP - JDK 1.5_14) but freezes almost immediately on my mac. I'm running intel mac (mini) with:
java version "1.5.0_13"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_13-b05-241)
Java HotSpot(TM) Client VM (build 1.5.0_13-121, mixed mode, sharing)

Here is my test code:
[code]
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Toolkit;
import java.awt.image.BufferStrategy;

import java.util.logging.Level;
import java.util.logging.Logger;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;


public class ActiveRenderingTestFrame extends JFrame implements Runnable {

   /**
    *
    */
   private static final long serialVersionUID = 4891533187219820999L;

   private Logger logger = Logger.getLogger(getClass().getName());
   private boolean running;

   private Thread thread;

   public ActiveRenderingTestFrame() {

   }

   /**
    * @param args
    */
   public static void main(String[] args) {
      ActiveRenderingTestFrame test = new ActiveRenderingTestFrame();
      test.init();
      test.setVisible(true);
      test.start();
   }

   public void init() {
      Toolkit toolkit = Toolkit.getDefaultToolkit();
      Dimension screenSize = toolkit.getScreenSize();
      int winW = 800;
      int winH = 600;
      int winX = (screenSize.width - winW) / 2;
      int winY = (screenSize.height - winH) / 2;

      setBounds(winX, winY, winW, winH);
      setDefaultCloseOperation(EXIT_ON_CLOSE);
      setTitle("Test Active Rendering");
      setIgnoreRepaint(true);
      thread = new Thread(this);
      running = true;

      // initialize components
      initializeComponents();
   }

   public void run() {

      while (running) {

         BufferStrategy bufferStrategy = getBufferStrategy();
         Graphics graphics = null;

         if (bufferStrategy != null) {
            graphics = bufferStrategy.getDrawGraphics();
         } else {
            graphics = getGraphics();
         }

         paintComponents(graphics);

         if (bufferStrategy != null) {
            bufferStrategy.show();
         }
      }
   }

   public void start() {

      try {
         createBufferStrategy(2);
      } catch (Exception e) {
         logger.log(Level.SEVERE, "Error creating buffer strategy", e);
      }

      thread.start();
   }

   private void initializeComponents() {
      Container contentPane = getContentPane();
      contentPane.add(new JLabel("Label"), "North");
      contentPane.add(new JButton("Button"), "South");
      contentPane.add(new JTextField(), "Center");
   }

}
[/code]


I have a feeling that there's something with the event queue that's deadlocking, but I'm unable to see where.

Please, if anyone has any idea as to why this is locking up I'd greatly appreciate any help.

Thanks,
Eric

--
Learn from the past. Live in the present. Plan for the future.
11101000
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.