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

The Archive Base Latest Questions

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

I am using GroupLayout for my main layout, and baseline alignment works fine, until

  • 0

I am using GroupLayout for my main layout, and baseline alignment works fine, until I add internal panels. It seems the baseline is not propagated through these panels: While all buttons, labels, etc. directly added to the panel with GroupLayout are properly aligned with respect to their baseline, the components inside the inner panels are not.

Since Scala Swing surprisingly doesn’t have a GroupPanel, I am using the one from Andreas Flierl, but that shouldn’t be important, as I am sure it’s an issue of the underlying swing classes and how to condition them.

import swing._
import eu.flierl.grouppanel.GroupPanel

val f = new Frame {
  contents = new GroupPanel {
    val but = new Button { text = "button" }
    val lb  = new Label  { text = "label"  }
    val inner = new FlowPanel {
       contents += new Button { text = "ibut" }
       contents += new Label  { text = "ilab" }
    }
    theHorizontalLayout is Sequential        (but, lb, inner)
    theVerticalLayout   is Parallel(Baseline)(but, lb, inner)
  }
  centerOnScreen()
  pack()
  open()
}

Note in the screenshot, how the inner panel is aligned with the bottom and not baseline. This problem is independent of the layout manager used for the child panel (it could be another group layout).

screenshot

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

    It seems, getBaseline of the underlying peer must be overridden. Too bad there is no hook for that in Scala Swing (perhaps because it would make it rely on Java 1.6?)

    val f = new Frame {
      contents = new GroupPanel {
        val but = new Button { text = "button" }
        val lb  = new Label  { text = "label"  }
        val inner = new FlowPanel {
          val b = new Button { text = "ibut" } 
          override lazy val peer: javax.swing.JPanel =
            new javax.swing.JPanel(new java.awt.FlowLayout(1)) with SuperMixin {
              override def getBaseline(w: Int, h: Int): Int =
                b.peer.getBaseline(w, h) + getInsets().top
            }
          // vGap = 0
          contents += b
          contents += new Label { text = "ilab" }
        }
        theHorizontalLayout is Sequential(but, lb, inner)
        theVerticalLayout is Parallel(Baseline)(but, lb, inner)
      }
      centerOnScreen()
      pack()
      open()
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using the C# Facebook SDK 5.0.3 everything works fine whit the client.Get(/me). But when
using php, i have a sql query which works fine, dateentry only has the
I have panel that is using group layout to organize some label. I want
I have a doubt in layouts.I have designed one layout using group layout using
I'm creating a cross platform application using Swing and Netbeans (Group Layout). Is there
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
using a binary search tree I need to add to a vector all int
I'm using GroupLayout to manage components in some dynamically generated data input forms. The
Something wrong, I can't choose GroupLayout in NetBeans 7, I'm using Java 1.6 java
Using Browserlab, it appears that the background image is not centred in Firefox7 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.