Results 1 to 8 of 8
Thread: How do i call display.setcurrent
- 11-03-2008, 06:09 PM #1
Member
- Join Date
- Oct 2008
- Posts
- 40
- Rep Power
- 0
How do i call display.setcurrent
Hi. I have the midlet class like this in a.java
public class a extends MIDlet{
....
}
now i want to create a static method in this class for changing the current display. How do i do that?
Static Display k= new Display.getDisplay() gives an error
. Please dont just give me links.
- 11-03-2008, 06:31 PM #2
Please copy and paste the full text of the error message.gives an error
- 11-04-2008, 10:37 AM #3
Member
- Join Date
- Oct 2008
- Posts
- 40
- Rep Power
- 0
error- non-static variable cannot be referenced from a static method
- 11-04-2008, 10:51 AM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
So avoid that and code it in different way.
- 11-04-2008, 11:51 AM #5
Member
- Join Date
- Oct 2008
- Posts
- 40
- Rep Power
- 0
how? i cant make a new iinstance of a MIDlet, since it will give a security error. and i need to call the display.setcurrent from another class. how can i do that if the methos is not made static?
- 11-04-2008, 12:06 PM #6
the keyword new is used in conjunction with a constructor. not with a static method. This is how you get a reference to the Display associated with a currently running MIDlet from within the class:
This cannot be executed in a static method or block as it references the instance alias this.Java Code:Display display = Display.getDisplay(this);
dbLast edited by DarrylBurke; 11-04-2008 at 12:09 PM.
- 11-04-2008, 12:32 PM #7
Member
- Join Date
- Oct 2008
- Posts
- 40
- Rep Power
- 0
ok, then plz suggest me another method to call "Display display = Display.getDisplay(this);" from a class outside the midlet class.
if the midlet class is like:class a extends MIDlet{} can i replace "this" with something else, like the class name so that i can use it from an outside class?
- 11-04-2008, 09:00 PM #8
Three ways:
1) Pass a reference to the MIDlet to the constructor of the other class
2) Pass a reference to the MIDlet's Display.getDisplay(this) to the constructor of the other class
3) Provide a method in your MIDlet that returns Display.getDisplay(this)
No. Read the API.if the midlet class is like:class a extends MIDlet{} can i replace "this" with something else, like the class name so that i can use it from an outside class?
db
Similar Threads
-
How to display information about the display device in SWT
By Java Tip in forum SWTReplies: 0Last Post: 06-28-2008, 09:26 PM -
How to call the input value from different file?
By xiongling in forum NetworkingReplies: 6Last Post: 04-07-2008, 10:05 AM -
how to call a dll from java
By katie in forum Advanced JavaReplies: 3Last Post: 12-10-2007, 10:34 AM -
I need to call and run another program
By coco in forum Advanced JavaReplies: 1Last Post: 07-31-2007, 05:47 AM -
How To Call EJB From Eclipse IDE
By JavaForums in forum EclipseReplies: 0Last Post: 04-26-2007, 10:15 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks