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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:58:35+00:00 2026-05-14T01:58:35+00:00

I am creating a container of JComponents which will look like a piano keyboard.

  • 0

I am creating a container of JComponents which will look like a piano keyboard. The black keys look like this (Groovy)

def setBlackNotes(buttons) {
    def octaves = (int)(buttons.size() /  5)
    def gridLayout = new GridLayout(1, octaves*7);

    def blackNotePanel = new JPanel(gridLayout)
    this.add blackNotePanel
    def i = 0
    octaves.times {
        2.times {
            blackNotePanel.add buttons[i++]
        }

        blackNotePanel.add Box.createHorizontalBox()

        3.times {
            blackNotePanel.add buttons[i++]
        }

        blackNotePanel.add Box.createHorizontalBox()

    }
}



Which is just what I need, and looks like this:

alt text http://dl.dropbox.com/u/2652228/Screen%20shot%202010-03-25%20at%208.10.07%20PM.png

but then I’d like to move this over to the right by half-a-key width. All of my attempts to move the blackNotePanel over by an arbitrary width — wrapping it a BorderLayout, a MigLayout, etc. — have failed or changed the spacing of the GridLayout radically.

Any suggestions on how to move this over to the right by an arbitrary amount in pixels?

  • 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-14T01:58:36+00:00Added an answer on May 14, 2026 at 1:58 am

    Add an EmptyBorder to the panel. You can specify the left inset to be whatever you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When creating a StructureMap container, I typically do something like this: var container =
I would like two threads work like this: First thread will append values to
I'm creating a small project which will manipulate some internal components of the project(big
We're creating a desktop application which will use OLAP server to perform analysis. I'm
I'm creating HttpSession container this way: @SessionScoped @ManagedBean(name=userManager) public class UserManager extends Tools {
So I am creating a container with rounded corners using the following method: div.rounded
I have a div Container, and I am creating a dynamic textbox control when
I am creating a TableView which contains 20 rows.I have to add single labels
I am creating a registration form which contains two submit buttons. I need to
I am creating a login register page which contains two edit text boxes(one for

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.