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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T03:16:32+00:00 2026-05-17T03:16:32+00:00

I have a JInternalFrame that I am applying a custom UI to. The UI

  • 0

I have a JInternalFrame that I am applying a custom UI to. The UI paints the component, but when I add a JPanel to the JInternalFrame it doesn’t show up. I think the UI is paining over the whole component, but how do I paint the UI THEN paint the components?

But if anyone has a better way of doing this, please let me know! Thanks!

public class ClassInternalFrame extends JInternalFrame {
    public static Color currentColor;
    public static final Color CLASS_TYPE = new Color(148, 227, 251);

    public ClassInternalFrame(String title, Color classType) {
        super(title, true, true, false, true);
        currentColor = classType;
        super.setUI(new ClassFrameUI());

        Container pane = super.getContentPane();
        pane.setLayout(new BorderLayout());

        JPanel titlePanel = new JPanel();
        titlePanel.setPreferredSize(new Dimension(0, 20));
        pane.add(titlePanel, BorderLayout.NORTH);

        titlePanel.setBorder(new MatteBorder(1, 1, 1, 1, Color.yellow));
    }

}

class ClassFrameUI extends InternalFrameUI {
    private final static ClassFrameUI frmUI = new ClassFrameUI();

    public static ComponentUI createUI(JComponent c) {
        return frmUI;
    }

    @Override
    public void paint(Graphics g, JComponent c)
    {
        Graphics2D g2d = (Graphics2D) g;

        g2d.setColor(Color.LIGHT_GRAY);
        g2d.fillRect(0, 0, c.getWidth(), c.getHeight());

        g2d.setColor(ClassInternalFrame.currentColor);
        g2d.fillRect(0, 0, c.getWidth(), 20);

        g2d.setColor(Color.DARK_GRAY);
        g2d.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 1, 0 }, 0));
        g2d.drawRect(0, 0, c.getWidth()-1, c.getHeight()-1);
        g2d.drawLine(0, 20, c.getWidth(), 20);


    }
}
  • 1 1 Answer
  • 1 View
  • 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-17T03:16:32+00:00Added an answer on May 17, 2026 at 3:16 am

    The problem is not that you’re painting over anything, but that InternalFrameUI does absolutely nothing (if it did, you would also need to call super.paint(g, c);). Normally, painting of the components is done by a subclass such as BasicInternalFrameUI. It looks like you’re trying to paint a custom title bar, a task that BasicInternalFrameUI delegates to BasicInternalFrameTitleBar.

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

Sidebar

Related Questions

I have a JInternalFrame inside a JPanel, all is working great, but when I
I have a JInternalFrame window that needs to popup a modal dialog box when
I have a JInternalFrame as shown below. Are there properties that allow for? coloring
I have a JInternalFrame class with a constructor that looks like this: public MyInternalFrame()
I have a JInternalFrame and I need to get some Information from user (a
I have a JInternalFrame painted with a BufferedImage and contained in the JDesktopPane of
I have a strange problem... I have a JFrame and added two JInternalFrame I
I have an ArrayList that needs to be read from and written to from
I Intend to Display student results in a JTable that I have Created in
I have an application which opens multiple JIFs, But I only want to create

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.