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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:19:27+00:00 2026-05-13T08:19:27+00:00

So I have created some demo code, see below. What I am seeing is

  • 0

So I have created some demo code, see below.

What I am seeing is that if a JScrollPane is within a JInternalFrame and component orientation is set to right-to-left, when minmising the frame, the scroll bar stays to the left of the content. I would expect, seeing as RtL, that it would stay to the right of the content, which is true if the scroll pane is not added to an internal frame (see both frames – one appears behind the other in the demo).

So is this a Java bug or have I forgotten to do something?

Here’s the demo code:

import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.WindowConstants;
import java.awt.ComponentOrientation;
import java.awt.Dimension;


public class JScrollBarTest
{
    public static void main(String[] a)
    {
        try
        {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        }
        catch (Exception e) { }

        runInternalFrameDemo();
        runNormalDemo();
    }

    private static void runInternalFrameDemo()
    {
        // Frame...
        final JFrame frame = new JFrame("Internal Frame Demo");
        frame.setSize(new Dimension(500, 500));
        frame.setLocationRelativeTo(null);
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

        // Desktop pane...
        JDesktopPane desktopPane = new JDesktopPane();

        // Table...
        JTable table = getTable();

        // Scroll pane...
        JScrollPane scrollPane = new JScrollPane();

        // Internal frame...
        final JInternalFrame internalFrame = new JInternalFrame("Test Internal Frame", true, true, true, true);
        internalFrame.setSize(400, 300);
        internalFrame.setLocation(50, 50);
        internalFrame.setVisible(true);

        // Add everything...
        frame.setContentPane(desktopPane);
        desktopPane.add(internalFrame);
        internalFrame.setContentPane(scrollPane);
        scrollPane.setViewportView(table);

        SwingUtilities.invokeLater(new Runnable()
        {
            public void run()
            {
                internalFrame.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
                frame.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
                frame.setVisible(true);
            }
        });
    }

    private static void runNormalDemo()
    {
        // Frame...
        final JFrame frame = new JFrame("Normal Demo");
        frame.setSize(new Dimension(500, 500));
        frame.setLocationRelativeTo(null);
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

        // Table...
        JTable table = getTable();

        // Scroll pane...
        JScrollPane scrollPane = new JScrollPane();

        // Add everything...
        frame.setContentPane(scrollPane);
        scrollPane.setViewportView(table);

        SwingUtilities.invokeLater(new Runnable()
        {
            public void run()
            {
                frame.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
                frame.setVisible(true);
            }
        });
    }

    private static JTable getTable()
    {
        final String[] columns = { "test 1", "test 2", "test 3", "test 4" };
        final Object[][] data = { { "1", "2", "3", "4" }, { "1", "2", "3", "4" } };
        final JTable table = new JTable(data, columns);
        table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        return table;
    }
}

Thanks in advance.

EDIT:

Apologies for the lack of clarity – written in quite a rush.

The issue is that when I reduce the width of the table, the ‘Normal Demo’ (not contained within a JInternalFrame) the horizontal scroll bar starts on the right, where as, doing the same for the ‘Internal Frame Demo’, the horizontal scroll bar starts on the left.

Any ideas?

  • 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-13T08:19:28+00:00Added an answer on May 13, 2026 at 8:19 am

    As discussed, with Java 1.6 there does not seem to be a difference in the behaviors of internal and standard frames.

    Bug "JScrollPane ignores ComponentOrientation" describes your problem, but it has been fixed long time ago.

    Bug "JScrollPane does not layout properly with RTL (RIGHT_TO_LEFT)" is still open and could cause your problem.

    I found a solution in Sun Forums that made it work for me, although the problem was slightly different. Vertical scrollbar is displayed on the right side instead of the left.

    scrollPane.setLayout(new ScrollPaneLayout() {
        
        @Override
        public void layoutContainer(Container parent) {
            JScrollPane scrollPane = (JScrollPane) parent;
            scrollPane.setComponentOrientation(
              ComponentOrientation.LEFT_TO_RIGHT);
            super.layoutContainer(parent);
            scrollPane.setComponentOrientation(
              ComponentOrientation.RIGHT_TO_LEFT);
        }
    });
    

    The current behavior sounds like a bug to me, since the bug (see above) has been fixed.

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

Sidebar

Related Questions

I'm using SQL*Plus 9.2 on Oracle 10g enterprise. I have created some scripts that
I have created an application that writes some data to the root folder of
I have created a report in MS Access report and write some VBA code
I've created some MbUnit Test Fixtures that have SetUp methods marked with the SetUp
I have created a class library in VB .NET. Some code in the library
I have created some extra functionality on my Linq-to-SQL classes to make things easier
I have created some rounded navigation tabs using CSS and am having trouble when
I m new to use ankhSVN and having issues. I have created some new
I have created a .NET DLL which makes some methods COM visible. One method
I have created an item swapper control consisting in two listboxes and some buttons

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.