Problem creating a status bar
Ok, I'm trying to make a status bar out of a label, but I want it to stick at the bottom of the Form and I DON'T want to use layouts (I'm not yet used to them).
So I did something like this:
this.addComponentListener(new ComponentAdapter() {
public void actionPerformed(ActionEvent e) {
if(e.getSource() == this){
jLabel1.setBounds(0,this.getHeight() -jLabel1.getHeight(),20,20);
}
}
});
(Actually, first I wrote the whole code to make the jLabel resize according to the Frame's size, but it didn't work, so I used the values 0,0, 20,20 and I got a nice 20x20 pixel Label, so I then learnt that the coordinates start at 0,0).
The thing is, I can't see the label and I can't understand why?
Shouldn't I see a 20x20 rectangle label in the lower left side of the Form? (I mean, this is basically the way I'd do it in C#)
Message was edited by:
daedalus_
[947 byte] By [
daedalus_a] at [2007-11-26 23:00:10]

# 3
I know what you're trying to say, but it isn't the case -- I'm doing this with jdeveloper, and the Label is initialised, so it's height isn't 0, it's 30 (the first time, and then it's 20).
And yes, you taught me a debugging lesson, one that I don't really like -- that in this case I have to use system.out... to debug my code (this really sucks) because if I set up a break-point there, the whole app freezes before I can do any debugging.
Thanks anyway :)
# 5
Yes I use it now like this:
if(e.getSource() == this){
jLabel1.setBounds(0,this.getHeight() -jLabel1.getHeight(),20,20 );
System.out.println(this.getHeight() + " " + jLabel1.getY() );
}
And I get something like (and yes, I also did a .getHeight() on the jlabel )
Debugger connected to local process.
323 293
342 322
367 347
387 367
414 394
429 409
So it's obvius it's called, and it's resized correctly on the Y axis, I just can't see the major error in my code.
# 7
> I just can't see the major error in my code.
you've added a componentListener, using the ComponentAdapter class
which provides empty methods for the ComponentListener interface, and
you override the one/s you want
this.addComponentListener(new ComponentAdapter() {
public void actionPerformed(ActionEvent e) {
actionPerformed() is not one of the methods of the interface