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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:05:54+00:00 2026-06-17T10:05:54+00:00

I have a horizontal panel and 2, sometimes 3 buttons. Button btn1 = new

  • 0

I have a horizontal panel and 2, sometimes 3 buttons.

Button btn1 = new Button("Ok");
Button btn2 = new Button("Cancel");
HorizontalPanel panel = new HorizontalPanel();
panel.setWidth(100%);
panel.add(btn1);
panel.add(btn2);
panel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);

But only cancel button is in the center then. But how to align both…or even any number of buttons to the center on one horizontal panel?

  • 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-17T10:05:56+00:00Added an answer on June 17, 2026 at 10:05 am

    You can place those buttons in a smaller panel, add that panel to the larger panel, and then align the smaller panel:

    Button btn1 = new Button("Ok");
    Button btn2 = new Button("Cancel");
    JPanel buttonPanel = new JPanel();
    buttonPanel.add(btn1);
    buttonPanel.add(btn2);
    panel.add(buttonPanel);
    panel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a button in a horizontal panel. Both the button and panel have
I have to add an onLoad event handler to a Horizontal Panel. I have
First of all i have to disable the Horizontal panel . I tried with
I have a set of buttons inside a stack panel. I want them all
I have a Horizontal Panel, when I click anywhere in that panel, I want
I have a button nested inside an update panel which has a CommandArgument tied
I have a splitContainter control with two horizontal panels. The top panel holds a
How do I set my panel so it will only scroll horizontal? I have
I have a panel containing a button as well as another panel which itself
I have a horizontal layout with width: auto and height: 100%, but the body

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.