JCheckBox misaligned on the BASELINE using GroupLayout and Nimbus LAF

Hello

I use the Nimbus UNIFIL for a project and just noticed a big shift in the box with the rest of the text. Here is some code to reproduce the problem:
import java.awt.EventQueue;
import javax.swing.GroupLayout;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;

public class CheckboxBaseline extends JFrame {

  public CheckboxBaseline() {
    
    try {
      for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        if ("Nimbus".equals(info.getName())) {
          UIManager.setLookAndFeel(info.getClassName());
          break;
        }
      }
    } catch (Exception e) { }

    JCheckBox checkBox = new JCheckBox();
    JLabel label = new JLabel("Label");
    JTextField textField = new JTextField("TextField");
    
    GroupLayout layout = new GroupLayout(getContentPane());
    
    layout.setAutoCreateContainerGaps(true);
    layout.setAutoCreateGaps(true);
    
    layout.setHorizontalGroup(layout.createSequentialGroup()
            .addComponent(checkBox)
            .addComponent(label)
            .addComponent(textField));
    layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
            .addComponent(checkBox)
            .addComponent(label)
            .addComponent(textField));
    getContentPane().setLayout(layout);
    
    pack();
  }

  public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {

      public void run() {
        new CheckboxBaseline().setVisible(true);
      }
    });
  }
}
If I disable the Nimbus look and feel and use the default alignment seems fine. However, when I switch to Nimbus LAF, the box is placed way above and to the left of the where it should be. What would be the best solution for this? What should I put in some fake inserts or something? Or I do something wrong completely in my approach to the layout?

Thanks for any help you can provide me with! It seems very scary right now with completely misaligned checkboxes...

In the case of nimbus, the box requires some text so that there a reference level. If a solution would be to remove the labels and give the text for the check boxes. Another solution would be to use Alignment.CENTER instead of Alignment.BASELINE. In other words, if the components Center the text that is in them, and then focus components within the Group would have the desired effect, even as a REFERENCE.

Tags: Java

Similar Questions

  • IPhone 7, there will be an adapter jack allowing the two using headphones AND charger?

    IPhone 7, there will be an adapter jack allowing the two using headphones AND charger?

    Hello

    Apple has not yet announced a.

    You can submit your comments and suggestions to Apple here:

    https://www.Apple.com/feedback/iPhone.html

  • How to insert image from mysql into the table using php and create the checkbox in the table?

    How can I insert image from mysql into the table using php and create the checkbox for each data as a vote? Here is my code...

    WELCOME

    connect_error) {die ("connection failed:".)} $conn-> connect_error); } $sql = "SELECT no, Calon, ID, of course, the Image OF THE candidates." $result = $conn-> Query; If ($resultat-> num_rows > 0) {echo ' '; export data of each line while ($row = $result-> fetch_assoc()) {"echo"}}
    NO Candidate INFO Vote
    " . $row ["no"]. "-" . $row ["Calon"]. "
    -" . $row ['ID']. "
    -" . $row ['class']. "
    "; } ECHO ' ' ;} else {echo '0 results' ;} $conn-> close();?} >

    hope someone can help me because I am a newbie in this program... need to finish this project... Thank you.

    If you have saved the file name in the database, it's pretty simple.

    echo '' . $row['description'] . '';
    

    Is the same for the box:

    echo '';
    

    If you have saved the image file in the database, it is much more complicated. I recommend you store only the file name in the database.

  • the tag of 'mode' in the editable using getconfig() and setconfig() vhost.xml file?

    the tag of 'mode' in the editable using getconfig() and setconfig() vhost.xml file?

    Use the same code I gave before, simply replace:

    admin_nc. Call ("setConfig2", new Result1 (), "Proxy/Mode", "remote", "Adaptor:_defaultRoot_ / VHost:_defaultVHost_");

    by

    admin_nc. Call ("getConfig2", new Result1 (), "Proxy/Mode", "Adaptor:_defaultRoot_ / VHost:_defaultVHost_");

    Redefine Result1() as:

    function Result1() {}

    this.onResult = {function (info)}

    If (info.code == "NetConnection.Call.Success") {}

    for {(i in info.data)

    trace (info. Data [i]);

    }

    }

    }

    }

  • How to paste some data from numbers to some placeholders in the Pages using AppleScript and Automator?

    Hello AppleScript and Automator Pros!

    Unique ID Elements Quantity Unit of measure Sum, $ Color Dark?
    1 Pencil 1 Agenda 90.50 P Yes
    2 Pen 150 Agenda 300.23 THERE NO.
    3 Pillow 2 Agenda 400.01 B NO.
    4 Toy 114 Agenda 500.30 R Yes
    5 Repair service N/A N/A 1.00 N/A NO.
    6 Phone 98 Agenda 1986.10 W NO.

    P = purple

    Y = yellow

    B = black

    R = red

    W = white

    It was an example of Document numbers


    Now the example of Document Pages

    [PH for Unique ID] - Ben got: [PH for element], [PH for quantity] [PH for unit of measure], [dark or not PH] [PH for color] for [PH for sum before the comma] $ [PH cents] c.

    When Ben had [PH for quantity] [dark or not PH] [PH for Color] [PH for item tiny first character and changeable if necessary end], he became happy

    Example 1: Allows you to take data from line with Unique ID 1 and that's what it takes to go:

    1 - Ben got: pencil, 1 point, violet dark 50 ° c for $ 90.

    When Ben had 1 Purple Pencil dark, he became happy

    Example 2: Now data row with Unique ID 3 and it is what to get:

    3 - Ben got: Pillow, 2 pieces, blue for $ 400 01b

    When Ben had 2 blue pillows he became happy

    Example 3: Now the data used to row with Unique ID 5 and this is what it takes to get:

    5 - Ben got: repair service, 1 service, for 1$ 00 c complete

    When Ben had 1 repair service complete, he became happy

    Here, I have to change given n/d of the table in numbers and replace quantity with 1 PH, PH for unit of measure with service (no point as in the previous examples) and the PH for color with plenty of example.

  • Satellite L300D-10U - unable to connect to the internet using LAN and Win XP

    Hi all

    I had a very big problem with my card.
    I can t connect to the internet.
    I searched the forum but without any determination :(

    I did everything. I have checked ipconfig nothing, check the mode safe mode with local network nothing.
    Someone said too
    "(1) once the Ethernet is connected, power of the DSL Modem. Cycle." ("Some Modem picks up the MAC ADDRESS of the network card on where it was previously connected and restarting it redétecte this new")

    How to disable the modem?
    And another question: can someone tell me what works of LAN drivers in Sat L300D-10U on XP?
    I put t even know that :(

    Help me

    Hello

    The Satellite L300D-10U belongs to the series of PSLC0E and it supports the Realtek LAN card.
    LAN driver can be found on the page of Realtek.

    You ask how to disable the modem? I think you mean how to reset modem DSL
    Well, usually your modem should support an ON / OFF button simply turn it off and then turn it back on.

    If you are unable to access the internet then you should first check if your modem is properly configured and that the right data ISP (internet service provider) was used.

    Sorry, but that's all I can say right now I think you should just check your modem settings, make sure that the NIC is properly recognized and connect the model of the laptop using a LAN cable.

    All that s

  • explain the plan using plan_hash_value and runtime

    Hello

    Please let me know the syntax to get the plan to explain using sql_id and plan_hash_value.

    Also let me know how to find out the same sql execution times in the previous months. I have the ID value of sql.

    Kind regards

    VN

    > Is it possible to check how long the sql finished in the previous months?

    Of AWR / StatsPack reports.

    Or use awrsqrpt.sql which can query the repository for a single SQL_ID AWR.

    However, you must have the AWR data kept for 4 months.  The default retention is 7 days.

    Hemant K Collette

  • Window pop-up with a message to the user using ADF and Java bean

    Hello

    I am able to download the file using the 'fileDownloadActionListener '. In case if I could not find the file to the location of the server, and then must show an error to the client using a popup.

    Can you provide links, if available.


    Kind regards
    Stalin

    See http://tompeez.wordpress.com/2011/07/14/validate-data-before-export-via-afexportcollectionactionlistener-or-affiledownloadactionlistener/ which describes a similar use case.

    Timo

  • When I am browsing the internet using Safari and I'm looking for something like a plumber he gives met with responses from an area not my own.  How can I change this?

    When I'm surfing the internet using Safari looking for a product (like a plumber) all my suggestions come from the vicinity of Tyler, Texas.  I live much closer to Dallas.  How can I change that.  Thank you!

    You have location services? Are you allowing access from Safari to your location? You must check in the settings > privacy > Location Services > Safari Web sites. If she knows exactly where you are, then you can get these errors.

    I'm sorry, I just realized that you were referring to the Mac computer. My answer was for an iPhone. I can't help you with the Mac.

  • Helps the query using case and County

    Hello!

    I have problems with a small part of a query below that finally can settle the invoice price.

    (count (distinct spm97.sample_id) * 36.1) as "PROFILE."
    case count (distinct spm33.sample_id)
    When (count (distinct spm97.sample_id) = 0) then (count (distinct spm33.sample_id) * 26)
    another (count (distinct spm33.sample_id) * 4.75)
    put an end to 'CC ',.

    The first line works - 0 or 36.10 is returned depending on whether or not a profile has been ordered for the sample.

    The cost of CC is 4.75 if a profile was also sentenced, if it isn't then the cost is 26. The case statement is supposed to verify this and return the exact amount, but I can't make it work... I get the error message that a closing parenthesis is missing somewhere in the middle of line 3, if that helps.

    Any advice would be much appreciated! Of course, this isn't the entire query - joins and all are all working well, it's just this little section with the County that I can't just.

    Thank you

    JO

    the piece of code below, seems to me is incorrect

        CASE COUNT(DISTINCT spm33.sample_id)
            WHEN
                (
                    COUNT(DISTINCT spm97.sample_id) = 0
                )
            THEN (COUNT(DISTINCT spm33.sample_id) * 26)
            ELSE (COUNT(DISTINCT spm33.sample_id) * 4.75)
        END AS "CC"
    

    It seems that the requirement here is that if * 'COUNT (DISTINCT spm97.sample_id) = 0' *, then * "CC" * should be ' COUNT (DISTINCT spm33.sample_id) (* 26) "ELSE, it should be" COUNT (DISTINCT spm33.sample_id) (* 4.75)»
    If this is the case, the statement must include:

        CASE COUNT(DISTINCT spm97.sample_id)
            WHEN
                0
            THEN (COUNT(DISTINCT spm33.sample_id) * 26)
            ELSE (COUNT(DISTINCT spm33.sample_id) * 4.75)
        END AS "CC"
    
  • I accidentally typed my password and e-mail together on a Web site, and now you can see under the thing "used emails" and wants to go

    you know how you type and then you goof and accidentally don't press tab between the two? I did but don't want other users on my desk to see this password that I use and I don't want to change because of my screw up.
    usually, he ends up looking like this: [email protected]

    someone wants to give me a helping hand?

    Hi sKarletBlu, you can remove an entry of a suggestion of filling auto-dropdown emphasizing with the arrow keys and press the delete key.

    Check if Firefox automatically fills in forms

  • Failed to open all the links using safari and mail

    I can't open all links by safari and by e-mail. When I try to open the link it does not work and it will freeze. then I touch the original key two times to close the safari and the e-mail. How can I remedy this?

    Already, I erase history and Web site data and restart my phone.

    Please help me and give me a useful way! Thank you very much!

    As you can see if you read the forum, this is a known issue. Apple is working on a fix.

  • I am trying to create a photo book in Australia, but the College uses French and Euros. Can I convert in English and AUD?

    I'm about to order a photo book that I created in Photos. When I use the tab book buy the cost is in Euros and the information is in French. How I got all the English version and AUD?

    Do you live permanently in Australia?   Are - this Apple based on the use of an Australian bank with a supported by this bank credit card account?

  • The FPGA using mathematics and analysis of VI

    When I'm programming on our FPGA (in one OR cRIO-9004) my code will not compile when I use the VI in the calculation tab and analyze FPGA. The code will stop compilation and just say idle in the status area.

    I can't undewrstand it.

    If someone could help me it would be great. I'm looking to perform FFT analysis on sgnals.

    I discovered that it was because I was not logged as an administrator on the computer. Therefore, necessatry files could not be written.

    Problem solved now so just a heads - if you see something similar

  • How to display dynamic menu with the parent and the child using c# and sql server

    Hello

    Can you tell me

    What is menu given Dynamics example

    How can u use my dynamic menu added project in c#

    This menu is display with only the data from sql database.

    Menu with the help of a parent node and a child.

    check the element all in sql server and adding one by a dynamic menu.

    Hello

    Thank you for writing to Microsoft Communities.

    I recommend you post your query in the following forum.

    http://social.msdn.Microsoft.com/forums/en/category/SQLServer/

    Hope this information is useful.

Maybe you are looking for