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

  • Home
  • SEARCH
  • 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 7514429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:29:39+00:00 2026-05-30T00:29:39+00:00

Basically, I want a Java GUI with multiple frames, so I’m using JInternalFrame ,

  • 0

Basically, I want a Java GUI with multiple frames, so I’m using JInternalFrame, but when I add my chart (created from JFreeChart) to one of the frames, it gave me an exception.

Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: javax.swing.plaf.ColorUIResource cannot be cast to java.util.List
at javax.swing.plaf.metal.MetalUtils.drawGradient(Unknown Source)
at javax.swing.plaf.metal.MetalInternalFrameTitlePane.paintComponent(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintToOffscreen(Unknown Source)
at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(Unknown Source)
at javax.swing.RepaintManager$PaintManager.paint(Unknown Source)
at javax.swing.RepaintManager.paint(Unknown Source) ....

This is the code :

public class immobile extends JFrame {

    JDesktopPane desktop;

    public immobile() {
        desktop = new JDesktopPane();
        desktop.setDesktopManager(new No1DragDesktopManager());
        getContentPane().add(desktop);

        desktop.add(createInternalFrame(30, 50, Color.WHITE));
        desktop.add(createInternalFrame(30, 360, Color.WHITE));
        desktop.add(createInternalFrame(630, 50, Color.WHITE));
        desktop.add(createInternalFrame(630, 360, Color.WHITE));
    }

    private JInternalFrame createInternalFrame(
            int location1, int location2, Color background) {
        JInternalFrame internal =
            new JInternalFrame("Frame" + location1, true, true, true, true);
        internal.setBackground(background);
        internal.setVisible(true);
        internal.setResizable(false);
        internal.setBounds(location1, location2, 600, 310);
        internal.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
        return internal;
    }

    public static void main(String args[]) {
        immobile frame = new immobile();
        frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
        frame.setSize(1280, 720);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
        frame.setResizable(false);
        try {
            JInternalFrame[] frames = frame.desktop.getAllFrames();
            JInternalFrame f = frames[0];

            String url = "http://www.cophieu68.com/export/excel.php?id=ABT";
            //create the chart from JFreechart//
            JFreeChart chart = garch_project.garch_chart(url);

            JPanel chartPanel = new ChartPanel(chart);
            f.add(chartPanel);
            f.putClientProperty("dragMode", "fixed");
            JInternalFrame f3 = frames[2];
            f3.putClientProperty("dragMode", "fixed");
            JInternalFrame f4 = frames[1];
            f4.putClientProperty("dragMode", "fixed");
            JInternalFrame f2 = frames[3];
            f2.putClientProperty("dragMode", "fixed");
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    class No1DragDesktopManager extends DefaultDesktopManager {

        public void beginDraggingFrame(JComponent f) {
            if (!"fixed".equals(f.getClientProperty("dragMode"))) {
                super.beginDraggingFrame(f);
            }
        }

        public void dragFrame(JComponent f, int newX, int newY) {
            if (!"fixed".equals(f.getClientProperty("dragMode"))) {
                super.dragFrame(f, newX, newY);
            }
        }

        public void endDraggingFrame(JComponent f) {
            if (!"fixed".equals(f.getClientProperty("dragMode"))) {
                super.endDraggingFrame(f);
            }
        }
    }
}

How could I handle them? Thanks. (I’m using Eclipse, latest version).

  • 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-05-30T00:29:41+00:00Added an answer on May 30, 2026 at 12:29 am

    Here’s a simplified sscce that shows how JFreeChart may be used with JInternalFrame. Note that you should pack() (and optionally size) the internal frame before making it visible. A related example may be found here.

    enter image description here

    /** @see https://stackoverflow.com/questions/9338466 */
    public class InternalFreeChart {
    
        private static final Random rnd = new Random();
    
        public InternalFreeChart() {
            JFrame frame = new JFrame();
            JDesktopPane desktop = new JDesktopPane();
            frame.add(desktop);
            for (int i = 1; i < 9; i++) {
                desktop.add(createInternalFrame(i));
            }
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.pack();
            frame.setSize(640, 480);
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
        }
    
        private JInternalFrame createInternalFrame(int n) {
            JInternalFrame jif = new JInternalFrame(
                "Frame" + n, true, true, true, true);
            jif.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
            JFreeChart chart = ChartFactory.createTimeSeriesChart(
                "Test", "Time", "Value", createDataset(), true, true, false);
            JPanel chartPanel = new ChartPanel(chart);
            jif.add(chartPanel);
            jif.pack();
            jif.setBounds(n * 25, n * 20, 400, 300);
            jif.setVisible(true);
            return jif;
        }
    
        private static XYDataset createDataset() {
            TimeSeries series1 = new TimeSeries("Series 1");
            TimeSeries series2 = new TimeSeries("Series 2");
            SerialDate sd = SerialDate.createInstance(new Date());
            for (int i = 1; i < 16; i++) {
                Day d = new Day(SerialDate.addDays(i, sd));
                series1.add(d, 100 + rnd.nextGaussian() / 2);
                series2.add(d, 101 + rnd.nextGaussian() / 2);
            }
            TimeSeriesCollection dataset = new TimeSeriesCollection();
            dataset.addSeries(series1);
            dataset.addSeries(series2);
            return dataset;
        }
    
        public static void main(String args[]) {
            EventQueue.invokeLater(new Runnable() {
    
                @Override
                public void run() {
                    InternalFreeChart ifc = new InternalFreeChart();
                }
            });
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I basically want to set up a proxy server using Java which will capture
Is there an equivalent to Java's null layout in Android? Basically I want to
I basically want to be able to deploy multiple versions of the same EAR
I just basically want to add about 20 and sometimes 80 Proximity Alerts with
What i basically want to do is to get content from a website and
I basically want to do a complement set operation in SQLite but not sure
I want to execute a external .exe program from within java. The .exe is
I'm working on a simple calculator program using java and javax.swing Basically, when you
I basically want to make a clone of the classic game Pacman using Python.
Basically I want to add my application to the application chooser list for files

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.