2 Replies Latest reply: Feb 16, 2011 9:38 AM by PhHein RSS

    CDC Application with Swing

    843849
      Hello,

      I am working on a CDC application, with Emulator platform - CDC Java(TM) Platform Micro Edition SDK 3.0, Device - SunVgaAGUIPhone1 and Device Profile - PBP-1.1. The following (Hello World app) works fine for me:

      import java.awt.*;

      public class Main extends Frame {

      public Main () {
      initComponents();
      }

      private void initComponents() {
      pack();
      }

      public static void main(String args[]) {
      java.awt.EventQueue.invokeLater(new Runnable() {
      public void run() {
      new Main().setVisible(true);
      }
      });
      }

      public void paint(Graphics g) {
      g.drawString("Hello, World!", 80, 50);
      }
      }

      My understanding is that CDC with AGUI supports swing. However, when I change the above code to the following, it does not work:

      import java.awt.*;
      import javax.swing.*;

      public class Main extends JFrame {

      public Main () {
      initComponents();
      }

      private void initComponents() {
      pack();
      }

      public static void main(String args[]) {
      java.awt.EventQueue.invokeLater(new Runnable() {
      public void run() {
      new Main().setVisible(true);
      }
      });
      }

      public void paint(Graphics g) {
      g.drawString("Hello, World!", 80, 50);
      }
      }

      Can anyone tell me what am I missing? Or is this even possible?

      Thanks!