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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:54:45+00:00 2026-06-09T23:54:45+00:00

EDIT: I DO the same thing here but problem does not occur. import java.awt.Color;

  • 0

EDIT:

I DO the same thing here but problem does not occur.

    import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.border.Border;


public class MainFrame extends JFrame implements KeyListener {
static long start;
MyPanel right, left;
    public MainFrame() {

    }

    public void go(){
        setUndecorated(true);
        setLocation(0, 0);
        Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setSize(screenSize);
        addKeyListener(this);
        setLayout(new GridLayout(1,0));

        Border b = BorderFactory.createLineBorder(Color.black, 4);
        Border b1 = BorderFactory.createLineBorder(Color.blue, 4);
        right = new MyPanel();
        left = new MyPanel();
        right.setBorder(b); left.setBorder(b1);

        add(left);add(right);


        setVisible(true);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
    }


    public void update() {
        left.update();
        right.update();
}

    @Override
    public void keyPressed(KeyEvent arg0) {
        if (arg0.getKeyCode() == KeyEvent.VK_ESCAPE)
            System.exit(1);
        else if (arg0.getKeyCode() == KeyEvent.VK_RIGHT){
            start = System.currentTimeMillis();
            update();
        }

    }



    @Override
    public void keyReleased(KeyEvent arg0) {}

    @Override
    public void keyTyped(KeyEvent arg0) {}

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                new MainFrame().go();
            }
        });

    }

}
import java.awt.Graphics;

import javax.swing.JPanel;


public class MyPanel extends JPanel {
    MyPanel(){
        super();
    }
    public void update(){
        repaint();
    }

    public void paintComponent(Graphics g){
        super.paintComponent(g);
        System.out.println(System.currentTimeMillis() -  MainFrame.start);
    }


}

First of all I want to say that I’ve prepared little example which suppose to show my problem but the problem didn’t occured in this example code it is only in the original program. I know it is horrible to read but it will help a lot, because problem is in exact particular place and you don’t need to understand rest of the code or even polish only a few lines.

  1. GlowneOkno is main class with a main method which starts it all.
  2. Glowne okno is KeyListener and Extends JFrame it contains 3 extended JPanels: MapaPanel, InfoLiniaPanel, KursPanel.
  3. When you press “right arrow” on keyboard it suppose to run akutalizuj(it means update) method which calls akutalizuj method(update method) in those 3 extended JPanels. In those methods there is repaint() called.
  4. I used static long start in class GlowneOkno to see when the method GlowneOkno:Aktualizuj is called and then I println(currentTime – GlowneOkno.start) in paint method() from InfoLiniaKurs(this is that one where the time is displayed -> you will see). And this interval is enermous it is so slow, I don’t know why, if I block in method akutalizuj Mapa Panel

I know this is big thing I am asking, but this is fith day I can’t find reason and I am unable to form question and put there everything you should know without giving all project in Eclipse and I have like 5 more hours.

Program works in 1680 x 1050

Copyrights Robert Kilar 2012 ; ) But if you wanna use it somehow just ask me. I will be glad to help.

The main main is in GlowneOkno class.

ESC to close the app.

enter image description here

  • 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-09T23:54:47+00:00Added an answer on June 9, 2026 at 11:54 pm

    Take a long hard look at each individual step required to do a repaint.

    1. InfoLinePane needs to render the text and time. While this itself is not a difficult process, you could consider offloading some of it to a buffered image instead, cause lets face it, only the time changes. When the other details change, you could invalidate the buffer and repaint it again.
    2. You update the InfoLinePane again…?
    3. You assign the map name to the mapaPanel without any consideration as to whether it needs to changed or not
    4. You load the map. You scale said map. You change the preferred size of the map panel to match the size of the scaled image
    5. You scale the map (again)
    6. You paint the station stops. I’m pretty sure the stops don’t change that match, you should consider buffering this result. Unless the time has actually changed, it’s probably no point in updating progress bar.

    Image loading and scaling is expensive. You should consider caching these results if memory allows. Scaling is best achieved in the background. Use a low quality to scale to start with and offload the high quality scale to a separate thread

    Consider what actually changes. Render everything that doesn’t change (often) to buffer instead.

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

Sidebar

Related Questions

I am trying something very simple, but for some reason it does not work.
Edit: It turns out I missed something obvious, but I'm going to leave the
EDIT: It does work (sorry). Something in this script is causing it to stop
At the moment, my footer ( found here ) is the same width as
Edit: After getting five downvotes but no comments saying anything about why, I've tried
(Someone edit the title if you can understand and define my problem better.) The
The question is in the title... I searched but couldn't find anything. Edit: I
Hy There I'v seen alot of admob topics on stackO, but unfortunutaly not for
Greetings, Here's the problem I'm having. I have a page which redirects directly to
EDIT i have something like this in a file: imagecolor=0 arrayimagecolorcopy=0 arrayimagecolorcopy3d=0 when i

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.