Skip to Main Content

Embedded Technologies

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

CDC Application with Swing

843849Feb 22 2010 — edited Feb 16 2011
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!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 16 2011
Added on Feb 22 2010
2 comments
1,728 views