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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:08:42+00:00 2026-05-25T14:08:42+00:00

I am working on a java gui application hard coding without any netbeans help.

  • 0

I am working on a java gui application hard coding without any netbeans help. I am using the box layout for my gui. My question is simple from what I see online boxlayout should stack elements on top of each other. However, I have a textarea(x,y) a toggle button and another textarea(x,y) when this is displayed there is a gap between my first text area and the toggle button and a gap between the toggle button and the 2nd textarea. Why are they not being stacked!
Thanks,

  • 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-25T14:08:43+00:00Added an answer on May 25, 2026 at 2:08 pm

    Here’s an example of an SSCCE that tries to demonstrate your problem. Perhaps you can modify it to show us what’s going on:

    import java.awt.*;
    import javax.swing.*;
    
    public class BoxLayoutEg {
       public static void main(String[] args) {
          JTextArea area1 = new JTextArea(10, 20);
          JToggleButton toggleBtn = new JToggleButton("Foo");
          JTextArea area2 = new JTextArea(10, 20);
    
          JPanel toggleBtnPanel = new JPanel();
          toggleBtnPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0));
          // toggleBtnPanel.setLayout(new GridLayout());
          toggleBtnPanel.add(toggleBtn);
    
          JPanel mainJPanel = new JPanel();
          mainJPanel.setLayout(new BoxLayout(mainJPanel, BoxLayout.PAGE_AXIS));
    
          mainJPanel.add(new JScrollPane(area1));
          mainJPanel.add(toggleBtnPanel);
          mainJPanel.add(new JScrollPane(area2));
    
          JOptionPane.showMessageDialog(null, mainJPanel);
    
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was making a java gui application through netbeans IDE. All was working fine
I have a simple question (working with Java). I have two classes, one represents
I am working in Java on a fairly large project. My question is about
I'm working on a java web-application, trying to be xml-friendly and writing my jsp
I'm working on a java SE 1.5+ swing application, in conjunction with others. I'm
I am developing a Java Desktop Application. In the GUI, I want that user
I'm currently rebuilding an existing PHP application using Java. I therefore have an existing
I am writing an application in java (1.6) using swing. I currently have a
I'm working in Java with XML and I'm wondering; what's the difference between an
I recently started working in Java and was introduced to the wild and crazy

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.