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 7770955
In Process

The Archive Base Latest Questions

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

my application layout is something like: custom JFrame (which just handles the creation of

  • 0

my application layout is something like:
custom JFrame (which just handles the creation of the gui) which contains a standard JPanel which contains a custom JPanel

Inside the custom JPanel, which is called MinimapPanel, I changed the paint method:

    //in a constructor:
    scaledTransform = new AffineTransform(); = new AffineTransform();
    scaledTransform = new AffineTransform();
    scaledTransform.scale(scaleAmount, scaleAmount);
    //...
@Override
public void paintComponent(Graphics g) {
    super.paintComponent(g);

    Graphics2D g2d = (Graphics2D) g;
    g2d.setTransform(scaledTransform);
    mapDrawer.paintMinimap(g, seatMap, miniViewHandler);//it just calls a bunch of fillRect

    if (viewRect != null) {
        g.setColor(new Color(255, 0, 0));
        int x = viewRect.x;
        int y = viewRect.y;
        g.drawRect(x, y, Math.abs(viewRect.width), Math.abs(viewRect.height));
    }
    g2d.setTransform(plainTransform);
}

Everything works fine if I don’t apply the trasform, or if the scaling is by 1.0 (none), but if I scale, everytime the JFrame repaints, the MinimapPanel stays blank.

Any ideas on what I could be doing wrong?

  • 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-01T16:31:55+00:00Added an answer on June 1, 2026 at 4:31 pm

    Don’t use clear transforms. Previous components add their own transformations e.g. translate() to child position etc. Rather call the code like this

    AffineTransform old=g2d.getTransform();
    //do your changes here
    g2d.scale(scaleAmount, scaleAmount);
    //paint
    g2d.setTransform(old);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have something like this in my application layout: <title> <%= @page_title
How could I create a mixin for action controller, which does something like: layout
I just created a new rails app in Rails 3.1.1, and my application layout
I have a Silverlight 3 application the inside of whose grid layout root looks
My first application will just be a kind of launcher that I would like
I have a MVC3 application, based on default layout from VS 2010, which I
I have created for my application, some custom GUI component and used them. Now
I have an application layout in my rails app to give a default header/footer
I'm trying to add a css file in my zend application layout.php the problem
Here I've a controller with 4 actions and i wanna apply application layout (

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.