error in JFrame?

Hi

Is this error only happening at my pc? When I create a new JFrame, it starts with a little border showing nonsense. And if I drag something like another window over it, it does not correctly repaint it contents. Only if I manually resize or maximize the JFrame, it handles paintings correct. This error happens with all JFrames, I tried official Java codes, so it's not a programming error from me.

This problem is hard to explain, so I hope that there is somebody else having it, knowing how to solve.

Greetings,
Feanor's Curse

[size=1][Blue]For our true nature is sin
[B]Cradle of Filth[/b]

«1

Comments

  • hi, i get the same problem all the time.
    i dont know how 2 fix it though sorry.
    It really annoys me when im in an ide or any type of java application, the graphics get messed up and dont repaint. I find the best way to deal with it is to minimize and then maximize again so its forced to repaint. Doesnt fix the problem though :-(

  • : ...a new JFrame, it starts with a little border showing nonsense. And if I drag something like another window over it, it does not correctly repaint it contents.

    Would you mind posting a [b]very short[/b] sample of some code? And by that i mean the most cut-down version that still produces the error. Chances are that it is something you have missed and yet believe that you haven't.

    Still, that might depend on your machine. What OS and JVM do you use?


    Kind Regards
    Konrad
    ----------------------------
    (+46/0) 708-70 73 92
    chamster@home.se
    http://konrads.webbsida.com

  • : : ...a new JFrame, it starts with a little border showing nonsense. And if I drag something like another window over it, it does not correctly repaint it contents.
    :
    : Would you mind posting a [b]very short[/b] sample of some code? And by that i mean the most cut-down version that still produces the error. Chances are that it is something you have missed and yet believe that you haven't.
    :
    : Still, that might depend on your machine. What OS and JVM do you use?
    :
    :
    : Kind Regards
    : Konrad
    : ----------------------------
    4 me it doesnt matter what program it is. IE i use bluj for an ide, it does the same thing often. Im currently running win98SE with jdk1.3.1
    : (+46/0) 708-70 73 92
    : chamster@home.se
    : http://konrads.webbsida.com
    :
    :

  • I'm running Windows XP with J2SDK 1.4.0. I'll give an Code-Example soon, but I'm not at home at the moment, so you have to wait until Tuesday / Wednesday. Thanks to the both of you for your answers!

    : : : ...a new JFrame, it starts with a little border showing nonsense. And if I drag something like another window over it, it does not correctly repaint it contents.
    : :
    : : Would you mind posting a [b]very short[/b] sample of some code? And by that i mean the most cut-down version that still produces the error. Chances are that it is something you have missed and yet believe that you haven't.
    : :
    : : Still, that might depend on your machine. What OS and JVM do you use?
    : :
    : :
    : : Kind Regards
    : : Konrad
    : : ----------------------------
    : 4 me it doesnt matter what program it is. IE i use bluj for an ide, it does the same thing often. Im currently running win98SE with jdk1.3.1
    : : (+46/0) 708-70 73 92
    : : chamster@home.se
    : : http://konrads.webbsida.com
    : :
    : :
    :
    :


    [size=1][Blue]For our true nature is sin
    [B]Cradle of Filth[/b]


  • That's very interesting, actually. The question that i'm most curious about is wheter it's software thing (which would be solved pretty easy by installing a newer version of something) or hardware (in which case we'd have hardware that is not Java-capable).


    Kind Regards
    Konrad
    ----------------------------
    (+46/0) 708-70 73 92
    chamster@home.se
    http://konrads.webbsida.com

  • Well, I installed the new J2SDK1.4.1 and the error no longer occurs, so it seems like there has been a bugfix :-).

    : That's very interesting, actually. The question that i'm most curious about is wheter it's software thing (which would be solved pretty easy by installing a newer version of something) or hardware (in which case we'd have hardware that is not Java-capable).
    :
    :
    : Kind Regards
    : Konrad
    : ----------------------------
    : (+46/0) 708-70 73 92
    : chamster@home.se
    : http://konrads.webbsida.com
    :
    :


    [size=1][Blue]For our true nature is sin
    [B]Cradle of Filth[/b]


  • That's good to hear. Although, my curiosity remains unsettled...


    Kind Regards
    Konrad
    ----------------------------
    (+46/0) 708-70 73 92
    chamster@home.se
    http://konrads.webbsida.com

  • [b][red]This message was edited by teekay at 2002-9-19 4:35:26[/red][/b][hr]
    If I understand correctly,
    I got that rubish frame too.
    But if I add :

    this.setSize(new Dimension(300, 267));

    in order to set new frame size
    I get the frame perfect.

    Try that

    Teekay


  • : But if I add this.setSize(new Dimension(300, 267));

    So, the above makes the frame look normal. How did you use to set the size before (when the mysterious rubbish appeared)? I'm very curious how that may happen.


    Kind Regards
    Konrad
    ----------------------------
    (+46/0) 708-70 73 92
    chamster@home.se
    http://konrads.webbsida.com

  • I simply used [italic]pack[/italic], but if I think, I also used [italic]setSize[/italic] without any effect, but I'm not that sure.

    : : But if I add this.setSize(new Dimension(300, 267));
    :
    : So, the above makes the frame look normal. How did you use to set the size before (when the mysterious rubbish appeared)? I'm very curious how that may happen.


    [size=1][Blue]For our true nature is sin
    [B]Cradle of Filth[/b]


  • So what you mean is that setting size by creating a new instance of Dimension-class was what solved the problem. Is that correct?



    Kind Regards
    Konrad
    ----------------------------
    (+46/0) 708-70 73 92
    chamster@home.se
    http://konrads.webbsida.com

  • : : But if I add this.setSize(new Dimension(300, 267));
    :
    : So, the above makes the frame look normal. How did you use to set the size before (when the mysterious rubbish appeared)? I'm very curious how that may happen.
    :
    Normally I work in Jbuilder enviroment. So the frame is created automatically when one creates new application.
    I only get the error Frame when I try to create a new frame Class myself and not an application.
    That is when I have to use the "setSize " procedure.


    Else this is how jbuilder creates the frame;

    //Validate frames that have preset sizes
    //Pack frames that have useful preferred size info, e.g. from their layout
    if (packFrame) {
    frame.pack();
    }
    else {
    frame.validate();
    }
    //Center the window
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension frameSize = frame.getSize();
    if (frameSize.height > screenSize.height) {
    frameSize.height = screenSize.height;
    }
    if (frameSize.width > screenSize.width) {
    frameSize.width = screenSize.width;
    }
    frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
    frame.setVisible(true);



    Teekay


  • OK, i get it. I refuse to use JBuilder for GUI (i'm bone-headed as a donkey, you know) which gives me possibility of blaming the IDE. (Note - it doesn't have to be logical or truthfull blame.)

    I'd like you to run this and see if you get any "rubbish".

    [code]
    import javax.swing.*;
    import java.awt.*;

    public class Temp extends JFrame
    {
    public Temp ()
    {
    this.getContentPane ().add (new JButton ("north"), BorderLayout.NORTH);
    this.getContentPane ().add (new JButton ("south"), BorderLayout.SOUTH);
    this.pack ();
    this.setVisible (true);
    }

    public static void main (String[] arg)
    {
    new Temp ();
    }
    }
    [/code]


    Kind Regards
    Konrad
    ----------------------------
    (+46/0) 708-70 73 92
    chamster@home.se
    http://konrads.webbsida.com

  • [b][red]This message was edited by teekay at 2002-9-19 6:38:31[/red][/b][hr]
    : OK, i get it. I refuse to use JBuilder for GUI (i'm bone-headed as a donkey, you know) which gives me possibility of blaming the IDE. (Note - it doesn't have to be logical or truthfull blame.)
    :
    : I'd like you to run this and see if you get any "rubbish".
    :
    : [code]
    : import javax.swing.*;
    : import java.awt.*;
    :
    : public class Temp extends JFrame
    : {
    : public Temp ()
    : {
    : this.getContentPane ().add (new JButton ("north"), BorderLayout.NORTH);
    : this.getContentPane ().add (new JButton ("south"), BorderLayout.SOUTH);
    : this.pack ();
    : this.setVisible (true);
    : }
    :
    : public static void main (String[] arg)
    : {
    : new Temp ();
    : }
    : }
    : [/code]
    :
    No it runs perfectly !
    What's your point ?

    TK


    I forgot to mension that
    it resized it automatically
    to fit the frame

    TK


  • : No it runs perfectly !
    : What's your point ?

    In that case my point would be that the JFrame is fine and the strange "thingies" come up because of something else; most likely something stupid JBuilder adds (since, as everybody knows, JBuilder is to be blame for everything from my misspelled code to world hunger and Kennys death in every episode of South Park).



    Kind Regards
    Konrad
    ----------------------------
    (+46/0) 708-70 73 92
    chamster@home.se
    http://konrads.webbsida.com

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories