Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7723237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:23:31+00:00 2026-06-01T04:23:31+00:00

im developing an GUI Application, using JSWing, i load XML file, then deserialize it,

  • 0

im developing an GUI Application, using JSWing, i load XML file, then deserialize it, then i add all created object to the JPanel.
However, until i move the window, or click on the panel, this is how they looks like

enter image description here

After i move the window, they look correctly, so how to fix this issue <

I looked at this link
http://docs.oracle.com/javase/6/docs/api/javax/swing/JComponent.html#paintComponent(java.awt.Graphics)
and it might be the answer, since in the constructor of the JComponent i use

setOpaque(true);

but im still not sure how to fix the issue since that part of documentation is very hard to understand (it somehow just does not make any sense to me 😀 )

by the way, the painting itselfs goes something like this

for (NetObject o : objects) {

                addNewObject(o);
            }

and addNewObject (not whole code)

public void addNewObject(NetObject o) {



         DraggableComponent object = new DraggableComponent(o, editorIndex); //Creates a draggableComponent
        this.add(object);//Adds this component to main container

        object.setOverbearing(true); //On click ,this panel gains lowest z-buffer


            object.setSize(48, 48);
            object.setLocation(o.x - 23, o.y - 23);
            object.setBackground(Color.WHITE);
            this.repaint(); //this = JPanel

}

and the overriden paintComponent code

@Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        if (isOpaque()) {
            if (object.type == 2) { //tarnsition
                g.drawImage(transition, 0, 0, this);

            } else if (object.type == 1) {
                boolean test = g.drawImage(place, 0, 0, this); //place
                g.drawString(object.loadTokens(), 3, 27); // 1,2,3,4...
            }
        }

    }

i tried to call this.revalidate – after FOR EACH LOOP – didnt help, the only way that works is to move somehow with the window, strangely, this problem exists only @ Windows, my collegue is developing this exact same application under Linux, and he does not experience ani graphical issues.

I know that there been an awfully lot of topics like this, but i honestly was not able to figure out the solution.

Thanks for the answer,
OSiRiS

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T04:23:32+00:00Added an answer on June 1, 2026 at 4:23 am

    The setBackground() API mentions that “It is up to the look and feel to honor this property, some may choose to ignore it.” Set the graphics context’s color explicitly in paintComponent() and invoke fillRect().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a GUI application in C# using the design mode in VS2008.
I am developing a j2me application using LWUIT as GUI .... how can I
I am developing desktop GUI application using java swing. And I want to show
I'm currently developing a GUI for a Java-application that I've created. I would like
I'm developing a GUI application rapidly using a GUI buidler (Netbeans). I am frustrated
XulRunner/Gecko seems to be really interesting for developing GUI-intensive applications (by using widely used
I am developing WTL GUI application. I want to print something on console. How
I'm developing a C++ application that needs a GUI. I would like to use
I'm developing Swing application, and everything works fine usually. But I have an GUI
Currently developing an application using the newest version of symfony, obtained through PEAR. This

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.