Top.Mail.Ru
June 22nd, 2006 - Java developers — LiveJournal
? ?

Java developers

June 22nd, 2006
Image

01:56 pm - Imagechris61182 - Another GUI question...

Does anyone know if there is a way to add either a Shape or an Image to a Component with out over-riding the paint method? I don't want to do anything fancy that would justify the extra work, I simply want an Image to be drawn at a certain location on a Panel. This seems like such a simple concept, but sadly I know next-to-nothing about either awt or swing.
 

10:00 pm - Imagealbatordomi - Strange Javabeans behaviour

I'm attempting to write a MIDlet for wireless devices using Netbeans IDE and the Wireless Toolkit.
I've come across some strange behaviour when compiling and running the MIDlet, even though there are no errors in the compiling itself.
For instance, any code in the initializer MIDlet() function seems to be completely overlooked as if there were nothing there.
Also, I get a Null pointer error message when referencing the Canvas object even though the object is declared and instantiated.

Has anyone else encountered any such behaviour? I'm at my wit's end with this one.

Here's the code:
-------------------------------------

package Lines2;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

/**
*
* @author Dominic Pukallus
* @version
*/
public class Lines2MIDlet extends MIDlet implements CommandListener {

private Command exitCommand = new Command("Exit", Command.EXIT, 1); // The exit command
private Display display = Display.getDisplay(this); // The display for this MIDlet
private Lines2Canvas canvas = new Lines2Canvas();

public Lines2MIDlet() {
######################## Everything in this constructor method is overlooked
}

public void startApp() {

canvas.addCommand(exitCommand);

display.setCurrent(canvas); ############### This throws a Null pointer error
canvas.setCommandListener(this);

canvas.go();

}

public void pauseApp() {
}

public void destroyApp(boolean unconditional) {
}

public void commandAction(Command c, Displayable s) {
String label = c.getLabel();

if (label.equals("Exit")) {
destroyApp(true); // Exit the app
}
}

}
Powered by LiveJournal.com
Image