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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:05:57+00:00 2026-05-24T04:05:57+00:00

I am trying to align 2 JPanles in a big panel. I am not

  • 0

I am trying to align 2 JPanles in a big panel. I am not able to align them properly. I am giving the link to the source code here. If you run the source code, you can see that the New Payment Method Radio Button is at the centre and and not just below the payment options panel. How do i get it there. I am extremely sorry for not able to post the screenshot and also for the long code. THANKS A TON IN ADVANCE.

  • 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-24T04:05:58+00:00Added an answer on May 24, 2026 at 4:05 am

    As an alternative, consider BoxLayout, shown below.

    enter image description here

    import java.awt.EventQueue;
    import javax.swing.Box;
    import javax.swing.BoxLayout;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JRadioButton;
    
    /** @see http://stackoverflow.com/questions/6911309 */
    public class PaymentPanel extends Box {
    
        public PaymentPanel() {
            super(BoxLayout.Y_AXIS);
            this.add(new JLabel("Payment Setup"));
            this.add(Box.createVerticalStrut(10));
            this.add(new JRadioButton("New payment Method", true));
            this.add(Box.createVerticalStrut(10));
            this.add(new JLabel("Invoice"));
        }
    
        private void display() {
            JFrame f = new JFrame("PaymentPanel");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.add(this);
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
        }
    
        public static void main(String[] args) {
            EventQueue.invokeLater(new Runnable() {
    
                @Override
                public void run() {
                    new PaymentPanel().display();
                }
            });
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to align an image link next to a textbox. Here's my markup:
I'm trying to align a form element (search form) and an img link inside
I am trying to right-align the output of some PL/SQL code, but dbms_output.put_line is
I'm trying to align a div horizontally, but for some reason it's not working
I was trying to align doubles using string.format and display them on a tooltip.
I'm trying to align an input button with a link (class button), but in
I am trying to align text fields in a div and make them float
i am trying to vertically align the table present in the panel but i
I'm trying to align 2 sets of buttons to the panel in the div
I'm trying to align the values. The code is, <section class=message success> Variable1: Value1<br/>

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.