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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:25:09+00:00 2026-06-14T11:25:09+00:00

I made a Java swing application. My main class does the whole SwingUtilities.invokeLater(new Runnable()

  • 0

I made a Java swing application. My main class does the whole SwingUtilities.invokeLater(new Runnable() stuff.

My second class where everything is I’ve used:

JPanel container = (JPanel) getContentPane();

Then added all the bits by calling..

container.add([name of component]

I’d now like to get this entire ‘application’ into a JSplitPane. Hence I want my application on one side and something else on the right side.

How do I do this?

    public class one{
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
            JFrame f = new App("main");
            f.setSize(1920,1080);
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setVisible(true);
}


public class App extends JFrame {
        SuppressWarnings("empty-statement")
        public App(String title) {
        super(title);
        JPanel container = (JPanel) getContentPane();

        container.setLayout(new GridBagLayout());
        GridBagConstraints c = new GridBagConstraints();
        JButton new button = new JButton("new");
        c.gridx = 0;
        c.gridy = 0;
        c.gridwidth = 2;
        //ENTER LOTS OF CONSTRAINTS
        container.add(new, c);

        JButton next to button = new JButton("next to");
        c.gridx = 1;
        c.gridy = 1;
        c.gridwidth = 2;
        //ENTER LOTS OF CONSTRAINTS
        container.add(new, c);

        //I HAVE LOTS OF SWING COMPONENTS AND BUTTONS about 30

}

I want all of this in the left of the split pane?

how do I do this?

  • 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-14T11:25:11+00:00Added an answer on June 14, 2026 at 11:25 am
    1. Don’t extend from JFrame, you’re not adding any functionality to, instead, move all you application components and logic to a separate JPanel
    2. Create an instance of a JSplitPane, add the “main” panel to it, add you secondary pane to it
    3. Create an instance of a JFrame, add the split pane to it…

    UPDATED

    enter image description here

    public class TestSplitPane {
    
        public static void main(String[] args) {
            new TestSplitPane();
        }
    
        public TestSplitPane() {
            EventQueue.invokeLater(new Runnable() {
                @Override
                public void run() {
                    try {
                        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
                    }
    
                    JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
                    pane.setLeftComponent(new MainPane());
                    pane.setRightComponent(new JLabel("On the right"));
    
                    JFrame frame = new JFrame();
                    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    frame.setLayout(new BorderLayout());
                    frame.add(pane);
                    frame.pack();
                    frame.setLocationRelativeTo(null);
                    frame.setVisible(true);
                }
            });
        }
    
        public class MainPane extends JPanel {
    
            public MainPane() {
                setLayout(new GridBagLayout());
                GridBagConstraints c = new GridBagConstraints();
                JButton newButton = new JButton("new");
                c.gridx = 0;
                c.gridy = 0;
                c.gridwidth = 2;
                //ENTER LOTS OF CONSTRAINTS
                add(newButton, c);
    
                JButton next = new JButton("next to");
                c.gridx = 1;
                c.gridy = 1;
                c.gridwidth = 2;
                //ENTER LOTS OF CONSTRAINTS
                add(next, c);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I made a java swing application, and it needs to run on Windows as
I have made a Java Swing application. Now I would like to make it
I had made one Java Swing based application. On my application,if i click anywhere
I had made one application in java-swing, Now what i am getting problem is,
Hi I made a java swing application. Also created jar of that file. Now
I made a java swing application, but now I need some functionality for backup
I have made a small java swing application that I want to share with
I have made a java swing GUI. Now I want to display a static
In the Java Swing app I made it seems to me that all the
I have made a java application and have packed it into an executable jar

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.