|
The reason it returns null is because the componants havent been initialized by the time init() is called.
Solution: Don't call componente=this.getComponents(); from within init.
Have a look at this[^] for an explanation.
My failometer is detecting vast quantities of FAIL!
"Its SQL - hardly programming..." (Caslen)
|
|
|
|
|
I suspected that was it, i made my gui using netbeans IDE and it generates an initComponents method , and even tho i used getComponents inside this method afetr it instances the componenets i still get null
|
|
|
|
|
I presume you have something like this:
public GUIView(SingleFrameApplication app) {
super(app);
initComponents();
//TRY IT HERE
}
Personally I hate NetBeans and normally write it all by hand.
This is for a JFrame Application, apologies.
My failometer is detecting vast quantities of FAIL!
"Its SQL - hardly programming..." (Caslen)
modified on Saturday, May 9, 2009 12:29 PM
|
|
|
|
|
i really don't have a choice aside from working with netbeans sice my deadline is close and it could never be done in time if i learned how to do it by hand
the call is like this :
public void init() {
try {
initComponents();
initMyComponents();
} catch (Exception ex) {
ex.printStackTrace();
}
}
is there any other way to tell when the initialization is over, or when initComponenets is done executing?
|
|
|
|
|
Try this:
@Override
public void start()
{
}
I haven't used Applets in years, I'm a bit rusty.
My failometer is detecting vast quantities of FAIL!
"Its SQL - hardly programming..." (Caslen)
|
|
|
|
|
tried that , even inside the paint method , nothing works
btw thanks for all your time fly904
|
|
|
|
|
i am doing a project which is students‘Experiment management system.
then one function of it is teachers' modify students' experiment report.
so i need to add a online word editor to my project.
i hava tried to use dosframer and javascript.but the activex is only available in ie6.so it brings me a lot of trouble!
who can help me and give me some useful suggestions?oh ,my project is based on j2ee. also ,you can visit my website to give me some good suggestions.
if you visit my website ,the userid is 02910 password is 8764321 .you have to choose the category and the category is 教师.then you can try to test it!
the website is http://kforce.vicp.net:1013/ProjectX/[^]
thank you !
modified on Saturday, May 9, 2009 3:58 AM
|
|
|
|
|
0) Don' hand out your username and password, that's not a clever thing to do.
1) Your site is all in chinese(???), not many people here speak or read chinese so this is less than helpful.
2) Be more specific, just say you want to edit a Word file (*.doc) on a web page.
The only two useful bits in your post were:
qiuxumin1 wrote: so i need to add a online word editor to my project.
and
qiuxumin1 wrote: i hava tried to use dosframer and javascript.but the activex is only available in ie6.
The rest is unessesary and irrelevant.
3) Have a look at this[^].
My failometer is detecting vast quantities of FAIL!
"Its SQL - hardly programming..." (Caslen)
|
|
|
|
|
thank you very much!
yes,i am from china!i will improve my english!
i hope i can keep in touch with you and learn java from you !
i know using dosframer will lower its security but i hava no other ways!
|
|
|
|
|
Hy guys ! i've been using netbeans to make a GUI, and i'm having rpoblems figuring out how to draw stuff using the canvas object, i've created a canvas object but it needs a graphics object in order to draw stuff, and that's where my problems start, for the life of me i can not understand how to use one of these
this is what i've tried so far :
Graphics g=null;
g.setColor(new Color(255,0,0));
canvas1.paint(g);
when i run this java flares up with null pointer exceptions altho the canvas itself has been instantiated
i've looked on the sun homepage for guidance but there is no hint on how to use an instance of a canvas object, they way they show is by creating a class that inherits Canvas and overwriting it's paint method, but that's no use to me
|
|
|
|
|
I'm not a professional Java programmer, but
g=null; immediately followed by
g.setColor(... doesn't quite look right.
I'd follow the advice of Sun's documentation. Generally the people who made the language know how it's supposed to be used. I found lots of information with a simple google search of "Java Graphics class".
|
|
|
|
|
i hear what you're saying, but i can't instace it like
g=new Graphics();
because it's abstract, the null thing is automated correction from netbeans, it's the only way it will let me use g
the problem i have with sun's exmaple is that i see no point in defining an object that inherits the Canvas to do nothing different that what canvas is supossed to do, it would also render my canvas objects useless and the ability to drag and drop canvas stuff from the IDE pointless
|
|
|
|
|
In my limited time as a Java developer (the last 15 minutes) it sounds like extending the Canvas class in order to draw things on it is it's intended usage. If the IDE has defined a new class for you that extends from it then shouldn't it be as simple as overriding it's paint method?
|
|
|
|
|
[quote]If the IDE has defined a new class for you that extends from it then shouldn't it be as simple as overriding it's paint method?
[/quote]
the IDE creates an instance of the class Canvas, the class that extends Canvas part was in the sun example
|
|
|
|
|
I found in Netbeans in the "Inspector" you can select a GUI element, right click on it and go to "Customize Code". That allows you to change the variable from a standard Canvas to your custom type that extends from Canvas that does the drawing.
|
|
|
|
|
That's an awesome tip Jimmanuel thanks
|
|
|
|
|
What I normally do is to override the default paint method in the Canvas class.
Have a look at this[^]. The SweepCanvas class is the basic principle, just remove the threading obviously.
My failometer is detecting vast quantities of FAIL!
"Its SQL - hardly programming..." (Caslen)
|
|
|
|
|
[quote]What I normally do is to override the default paint method in the Canvas class.
Have a look at this[^]. The SweepCanvas class is the basic principle, just remove the threading obviously. [/quote]
good tip thank you, what i don't understand is where the run method gets invoked ( and as a consequence the repaint method), If anyone could explain this i think i could get the hang of how this class works. I see that the trick to making this work is calling the paint method using repaint() which saves you from making a Graphics instance( not the most obvious solution but i cant afford to be picky right now).
|
|
|
|
|
I'm not great at explaining things, but have a look at this[^] and this[^].
My failometer is detecting vast quantities of FAIL!
"Its SQL - hardly programming..." (Caslen)
|
|
|
|
|
Aaah i see now , but if i don't implement the class with threading(which i'm trying to avoid just because it would add more complexity ), what would be a good mechanism to call the repaint method ?
btw thanks for your patience, and sorry for all the noobie questions but my deadline is closing in fast and i haven't even gone into the difficult part of the project
|
|
|
|
|
If you don't want to use threading then simple use canasVariableName.repaint(); . I think that's what you mean but I'm not sure.
If you do want to use threading then this method is the simplest way.
My failometer is detecting vast quantities of FAIL!
"Its SQL - hardly programming..." (Caslen)
|
|
|
|
|
Thank you soo much, you're a life saver
|
|
|
|
|
any body have code for berlekamp massey algoithm in java
|
|
|
|
|
You had an answer to the same question yesterday. If you want it in java then I suggest you rewrite the C# code into java rather than being lazy and asking for someone else to do it.
My failometer is detecting vast quantities of FAIL!
"Its SQL - hardly programming..." (Caslen)
|
|
|
|
|
hey guys..i m building a motion detector in java....the problem is this, i have two bufferedimages from webcam...these are consecutive images taken from webcam...i need to compare these two images to check for any changes....i have no idean how to do this...i m trying getRGB() method for this purpose but i think i m not correctly applying it....
so if anyone have any idea how to do this..plzz reply...
|
|
|
|