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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:11:43+00:00 2026-06-04T20:11:43+00:00

I am struck in the Swing application. Here is brief problem. I am having

  • 0

I am struck in the Swing application. Here is brief problem. I am having a frame and then a panel. I am adding JTabbedPane to panel and adding components on the JTabbedPane. I am setting Grid Layout for the TabbedPane but it is not rendering the components in correct way.

It should render the components as A lable and then text field next to it. But it is rendering a lable and then below that lable a textfield.

Below is the code :

public static void main(String[] args) throws IOException {

     File file = new File("C:\\Documents and Settings\\rkumar\\Desktop\\IOSAutomationParameters.properties");

     if( file != null ){

         Properties property = new Properties();

         property.load(new FileInputStream(file));

          JFrame frame = new JFrame("IOSAutomationToolFourthPage");
          JPanel framePanel = new JPanel();
          framePanel.setSize(700,700);
           frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          String numberOfClients = property.getProperty("numberOfClients");
          System.out.println("number of clients: "+numberOfClients);
          if (!numberOfClients.isEmpty()) {

               int numberOfClientNumb = Integer.parseInt(numberOfClients);

                  System.out.println("numberOfClientNumb ::" + numberOfClientNumb);

                   JTabbedPane tab = new JTabbedPane();

                  // JTabbedPane tab2 = new JTabbedPane();
                for( int i=1; i<=numberOfClientNumb; i++){

                   JPanel panel = new JPanel();
                  panel.setSize(400, 400);
                  panel.setLayout(new GridLayout(10,2,1,1));

                  //Remote IP 
                  JLabel remoteIPLbl = new JLabel("Remote IP : ");
                  String remoteIPVal = property.getProperty("remoteIP_"+i);
                  JTextField remoteIPField = new JTextField(remoteIPVal);
                  remoteIPLbl.setBounds(50, 100, 2, 2);
                  remoteIPField.setBounds(200, 100, 2, 2);
                  remoteIPField.setColumns(30);


                  //Remote User Name
                  JLabel userNameLbl = new JLabel("User Name : ");
                  String userNameVal = property.getProperty("remoteUserName_"+i);
                  JTextField userNameField = new JTextField(userNameVal);
                  userNameLbl.setBounds(50, 200, 2, 2);
                  userNameField.setBounds(200, 200, 2, 2);
                  userNameField.setColumns(20);


                  //Remote Password
                  JLabel remotePasswordLbl = new JLabel("Remote Password : ");
                  String remotePasswordVal = property.getProperty("remotePassword_"+i);
                  JTextField remotePasswordField = new JTextField(remotePasswordVal);
                  remotePasswordLbl.setBounds(50, 300, 2, 2);
                  remotePasswordField.setBounds(200, 300, 2, 2);
                  remotePasswordField.setColumns(20);




                  //Remote Path
                  JLabel remotePathLbl = new JLabel("Remote Path : ");
                  String remotePathVal = property.getProperty("remotePath_"+i);
                  JTextField remotePathField = new JTextField(remotePathVal);
                  remotePathLbl.setBounds(50, 400, 2, 2);
                  remotePathField.setBounds(200, 400, 2, 2);
                  remotePathField.setColumns(100);




                  //deviceOrSimulator
                  JLabel deviceOrSimulatorLbl = new JLabel("Device or Simulator : ");
                  String deviceOrSimulatorVal = property.getProperty("deviceOrSimulator_"+i);
                  JTextField deviceOrSimulatorField = new JTextField(deviceOrSimulatorVal);
                  deviceOrSimulatorLbl.setBounds(50, 500, 2, 2);
                  deviceOrSimulatorField.setBounds(200, 500, 2, 2);
                  deviceOrSimulatorField.setColumns(1);


                  panel.add(remoteIPLbl);
                  panel.add(remoteIPField);
                  panel.add(userNameLbl);
                  panel.add(userNameField);
                  panel.add(remotePasswordLbl);
                  panel.add(remotePasswordField); 
                  panel.add(remotePathLbl);
                  panel.add(remotePathField); 
                  panel.add(deviceOrSimulatorLbl);
                  panel.add(deviceOrSimulatorField); 


                  tab.add("Client "+i,panel);
                  System.out.println(""+i);                     
               }

                framePanel.add(tab);
                frame.add(framePanel);
               // frame.setLayout(new Lay);
          }

          frame.setSize(800, 800);
          frame.setVisible(true);

     }
}
  • 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-04T20:11:46+00:00Added an answer on June 4, 2026 at 8:11 pm

    Change the number of rows from 10 to 5 (or to 0), eg:

    panel.setLayout(new GridLayout(0,2,1,1));
    

    And you will be fine, however, you will run into som trouble using the GridLayout in this problem since both columns will be the same size. I would therefor recommend you to use (and learn) GridBagLayout instead.


    Difference between GridLayout and GridBagLayout:

    gridlayout

    grigbaglayout


    Example above using GridBagLayout:

    public static void main(String[] args) throws IOException {
    
        JFrame frame = new JFrame("Test");
        frame.setLayout(new GridBagLayout());
    
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.insets = new Insets(1, 1, 1, 1);
    
        gbc.fill = GridBagConstraints.BOTH;
        gbc.weightx = 0;
        gbc.gridx = 0;
    
        frame.add(new JLabel("Remote IP : "), gbc);
        frame.add(new JLabel("User Name : "), gbc);
        frame.add(new JLabel("Remote Password : "), gbc);
        frame.add(new JLabel("Remote Path : "), gbc);
        frame.add(new JLabel("Device or Simulator : "), gbc);
    
        gbc.gridx = 1;
        gbc.weightx = 1;
    
        frame.add(new JTextField("Remote IP"), gbc);
        frame.add(new JTextField("User Name"), gbc);
        frame.add(new JTextField("Remote Password"), gbc);
        frame.add(new JTextField("Remote Path"), gbc);
        frame.add(new JTextField("Device or Simulator"), gbc);
    
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setVisible(true);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on an swing application and struck at deciding what could be
I tried performing join on three tables but i'm struck Here where condition would
I am making a JApplet and got stuck with a animation problem. Here is
I'm building a python application from some source code I've found Here I've managed
I'm making a simple Kakuro application in Java Swing and I have used JButton
i am developing a GUI using Java Swing. but i got stuck here. Is
I have this requirement for my business. We have a swing desktop application that
This struck me as really weird behaviour and I spent a while checking for
It has always struck me as strange that the C function fopen() takes a
In SQL Server 2005 I just struck the infamous error message: Introducing FOREIGN KEY

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.