Wrong alignment in nested GridbagLayout

Hi!
I'd like to nest one Panel to another both using GridbagLayout. In the inner panel, which is streched over the complete frame, I want to add a Label, which should align to the left side. However,
the following code results in a centered Label. Why is this the case?
public class TestFrame extends JFrame{
     public static void main (String[] args){
     TestFrame tf = new TestFrame();
     tf.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
     tf.setSize(new Dimension(200, 200));
     JLabel lTest = new JLabel("test");
     JPanel testPanel = new JPanel();
testPanel.setLayout(new GridBagLayout());
testPanel.setBackground(Color.red);
JPanel testPanel2 = new JPanel();
testPanel2.setLayout(new GridBagLayout());
testPanel2.setBackground(Color.yellow);
GridBagConstraints gbConstraints = new GridBagConstraints();
gbConstraints.anchor = GridBagConstraints.WEST;
testPanel2.add(lTest, gbConstraints);
gbConstraints.anchor = GridBagConstraints.WEST;
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
gbConstraints.weightx = 1.0;
testPanel.add(testPanel2, gbConstraints);
tf.getContentPane().add(testPanel);
     tf.show();
Thx in advance

Hi,
Goto  Tcode SE71(If u are checking for sapscript) and put the name of layout for form 12A
that is HR_IN_EPF12A_99M. U can copy this into a customer name range and modify that
to get the desired output.
If you are creating a customer layout then please pass the same name at the time of the
execution of the report in the Name of the Layout Set.
let me know if u r using PDF layout.
regards,
Praveen

Similar Messages

  • A bug using nested GridBagLayouts ?

    Hallo,
    if I am nesting JPanels using the GridBagLayout the component width are not calculated correctly. In the following example the component width is not evenly distributed:
    Any hints to solve this?
    best Regards,
    Thomas
    import java.awt.GridBagConstraints;
    import java.awt.GridBagLayout;
    import javax.swing.JButton;
    import javax.swing.JDialog;
    import javax.swing.JPanel;
    public class GridPanelTest {
    public static void main(String[] args) {
    GridBagConstraints gbc = new GridBagConstraints();
    JPanel pane = new JPanel(new GridBagLayout());
    JPanel pane1 = new JPanel(new GridBagLayout());
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    JPanel fix = new JPanel(new GridBagLayout());
    fix.add(new JButton("test1"), gbc);
    pane1.add(fix, gbc);
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.weightx = 0.5;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    pane.add(pane1, gbc);
    JPanel pane2 = new JPanel(new GridBagLayout());
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.weightx = 0.5;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    pane2.add(new JButton("test2"), gbc);
    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.weightx = 0.5;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    pane2.add(new JButton("test3"), gbc);
    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.weightx = 0.5;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    pane.add(pane2, gbc);
    JDialog dlg = new JDialog();
    dlg.setContentPane(pane);
    dlg.pack();
    dlg.setVisible(true);
    }

    java Version 1.5.0_3
    The right panel should divided half the size of the left panel but the size in the example is not distributed correctly if i am using nested GridBagLayouts. Here is a tidy version of the code:
    import java.awt.GridBagConstraints;
    import java.awt.GridBagLayout;
    import javax.swing.JButton;
    import javax.swing.JDialog;
    import javax.swing.JPanel;
    public class GridPanelTest {
    public static void main(String[] args) {
    // left panel
    JPanel left = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 1.0;
    left.add(new JButton("left"), gbc);
    // right panel
    JPanel right = new JPanel(new GridBagLayout());
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 0.5;
    right.add(new JButton("right1"), gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 0.5;
    right.add(new JButton("right2") , gbc);
    // main panel
    JPanel mainPanel = new JPanel(new GridBagLayout());
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 0.5;
    mainPanel.add(left, gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 0.5;
    mainPanel.add(right, gbc);
    JDialog dlg = new JDialog();
    dlg.setContentPane(mainPanel);
    dlg.pack();
    dlg.setVisible(true);
    }

  • What is wrong with my Nested Style?

    Hi guys,
    Frustrating times in InDesign when Nested Styles do not behave as i would like to. I would like to have a highlited text after the Hard Return or ":" a simple Character style Helvetica Bold like here.
    http://www.pixentral.com/show.php?picture=1gFC1qoFDCNkgJy3BmxEYZc3ZEAE0
    I don´t know what i am doing so wrong i get this Morse Code. The highlight stuff is mixing up everything. The highlight is deselected in the character style but keeps appearing...
    Any idea?
    Thanks
    Sebastian
    pd: i know the palettes are in Spanish but i guess is mostly understandable since the locations of things are the same.

    You are totally misunderstanding how nested styles work. Once hit the
    return key you're starting a new paragraph. If you want your text to
    pick up a character style after the colon then use a soft return instead.
    Bob

  • Wrong Alignment of data in the HTML CSS format

    hi,
    i generated a report in both HTMLCSS & in PDF
    in the PDF all the headers & the fields alignment are alright
    but if i am generating it in HTML CSS the format is collapsed
    can anyone tell me what is the issue while generating it in HTML format
    Thanks

    Hi,
    I am not sure are you using spring framework or what. if yes you can populate data in command object in referenceData method of simpleformcontroller and that data will be available to the UI.

  • Wrong alignment on 8 by 10, white space on 4 by 6

    My machine prints landscape instead of portrait view on 8 by 10 paper; cuts off pic, leaves white space on borderless 4 by 6 paper.

    Please read this post then provide some details.  What printer model? What operating system? What settings do you have for media type?  Have you set the driver to print with the proper orientation?  What program are you printing from?
    Bob Headrick,  HP Expert
    I am not an employee of HP, I am a volunteer posting here on my own time.
    If your problem is solved please click the "Accept as Solution" button ------------V
    If my answer was helpful please click the "Thumbs Up" to say "Thank You"--V

  • Do nested tables conflict with ?split-by-page-break:? -getting blank pages

    I have an RTF template with multiple levels of groupingwith sub-totals and pagebreaks at several levels. I'm using nested tables to keep the lowest level group together. The nested table works fine as far as keeping the rows together - if a group doesn't fit on a page, it is pushed to the next page; however, it has created some blank pages in the report. The first time I report the lowest level group details, if they don't fit on one page, I get a blank page followed by the data. Each time the lowest level group changes, this may or may not occur depending on the amount of data.
    If you have come across this before or have some suggestions, I would really appreciate a response. I've been working on this for quite some time and have run out of things to try.
    The template is quite complex and the XML very long, so I won't post. However I can email them to you if you'd like to take a look.
    Thank you for your help,
    Tam
    Edited by: Tam_11 on Nov 19, 2009 2:42 PM

    Thanks for replying.
    Yes, I tried removing the <?split-by-page-break:?> and using MS hard page break (ctrl-enter) and that doesn't work either. My totals moved to a separate page by themselves and I'm still getting the blank pages.
    <?split-by-page-break:?> did exactly what it was supposed to until I added in the nested tables. It's very possible that I did something wrong with my nested tables (only my second XML report). Does anyone have a sample with nested tables that they would be willing to share?

  • Trouble with nested foreach loop

    I got 3 nested foreach loop but the 2nd and the third one outputs no data.
    $vss = "vSwitch3"
    $vmhost_array = @("host1,host2,host3")
    $vss_vlan_array = @("vlan50")
    $dvs_vlan_array = @("n1kv_vms_vlan50")
    foreach ($vmhost in $vmhost_array) {
    foreach ($vss_vlan in $vss_vlan_array) {
    foreach ($dvs_vlan in $dvs_vlan_array) {
    Get-VMHost $vmhost | Get-VirtualSwitch -Name $vss | Get-VirtualPortGroup -Name $vss_vlan | Get-VM | Get-NetworkAdapter | Set-NetworkAdapter -Portgroup $dvs_vlan -Confirm:$false
    I get runtime error at Get-VirtualSwitch -Name $vss 
    $vss says vlan50 not found. but its there. anything wrong with this nested foreach?

    hi
    I am actually getting an error on 
    Get-VirtualPortGroup -Name $($vss_vlan_array[$i])
    Its trying to give me the whole array instead of the 1st item in the array. so get-virtualportgroup will fail.
    I checked it with $vss_vlan_array[0] and gives me 
    "vlan50","vlan49"
    how do one item at a time instead of the whole array?

  • Nested XML from recordset problems.

    Hi
    I have been struggling with this for a while now and desperatley need som help!
    I'm trying to create a nested spryregion that looks like this:'
    http://www.soulkompetens.se/utbildningar.php#
    Problem with that page is that it only works in Safari (mac). Firefox the encoding does not work (questionmarks instead of åäö).
    Windows explorer does not work at all .
    So I started to work wit the http://labs.adobe.com/technologies/spry/samples/utils/query2xml.html page to try to generate the xml.
    The XML should be something like:
    <DOCUMENT>
      <ROW0>
        <UTBILDNING_ID>22</UTBILDNING_ID>
        <RUBRIK>Värdegrunden som bas för affärsutveckling</RUBRIK>
        <ROW1>
          <INGRESS>Värdegrunden som bas för affärsutveckling, diskrimineringsgrunderna</INGRESS>
          <ID>17</ID>
         <TEXT></TEXT>
          <DATUM>0000-00-00</DATUM>
        </ROW1>
        <ROW1>
          <INGRESS>Västra Götaland 3:e september</INGRESS>
          <ID>34</ID>
          <TEXT></TEXT>
          <DATUM>2009-06-21</DATUM>
        </ROW1>
      </ROW0>
      <ROW0>
        <UTBILDNING_ID>25</UTBILDNING_ID>
        <RUBRIK>Omvärldsanalys</RUBRIK>
        <ROW1>
          <INGRESS>Mellersta Norrland 11:e december</INGRESS>
          <ID>35</ID>
          <TEXT></TEXT>
          <DATUM>0000-00-00</DATUM>
        </ROW1>
    </ROW0>
    </DOCUMENT>
    I get the XML from two joined Tables in the database.
    Sql looks like:
    select utbildning_rubrik.utbildning_id, utbildning_rubrik.rubrik, utbildning.ingress, utbildning.ID, utbildning.text, utbildning.datum
    from utbildning_rubrik, utbildning where utbildning_rubrik.utbildning_id = utbildning.utbildning_id
    order by utbildning_rubrik.utbildning_id, utbildning.ingress
    Now! How do I generate the XML with "query to xml".
    I have been trying a lot of things an my head is spinning around
    Can anybody help me please.
    Regards
    Olle

    Thank you for the answer.
    I think I am close. But there is something wrong wit the nesting of the nodes and repeating.
    Here is the code:
    <?php
    mysql_select_db($database_SOUL, $SOUL);
    $query_rsImages = "SELECT utbildning_rubrik.utbildning_id, utbildning_rubrik.rubrik, utbildning.ingress, utbildning.ID, utbildning.text, utbildning.datum FROM utbildning_rubrik, utbildning WHERE utbildning_rubrik.utbildning_id = utbildning.utbildning_id ORDER BY utbildning_rubrik.utbildning_id, utbildning.ingress";
    $rsImages = mysql_query($query_rsImages, $SOUL) or die(mysql_error());
    $row_rsImages = mysql_fetch_assoc($rsImages);
    $totalRows_rsImages = mysql_num_rows($rsImages);
    // Send the headers
    header('Content-type: text/xml');
    header('Pragma: public');       
    header('Cache-control: private');
    <?php echo('<?xml version="1.0" encoding="ISO-8859-1"?>'); ?>
    <DOCUMENT>
      <?php if ($totalRows_rsImages > 0) { // Show if recordset not empty ?>
        <ROW0>
        <UTBILDNING_ID><?php echo $row_rsImages['utbildning_id']; ?></UTBILDNING_ID>
        <?php do { ?><RUBRIK><?php echo $row_rsImages['rubrik']; ?>
      <ROW1>
            <?php do { ?><INGRESS><?php echo $row_rsImages['ingress']; ?></INGRESS>
            <TEXT><![CDATA[<?php echo $row_rsImages['text']; ?>]]></TEXT><?php } while ($row_rsImages = mysql_fetch_assoc($rsImages)); ?>
            </ROW1>
            </RUBRIK><?php } while ($row_rsImages = mysql_fetch_assoc($rsImages)); ?>
            </ROW0>
       <?php } // Show if recordset not empty ?>
    </DOCUMENT>
    In the other php document consuming the xml I have
    ds1.setColumnType("RUBRIK", "html");
    So the main problem with this is I dont know php so good that I can repeat the nodes to my choise.
    I neew it to be
    ROW0>
      <UTBILDNING_ID></UTBILDNING_ID>
      <RUBRIK></RUBRIK>
      <ROW1>
        <INGRESS></INGRESS>
        <TEXT></TEXT>
        <DATUM>/DATUM>
      </ROW1>
      <ROW1>
        <INGRESS></INGRESS>
        <TEXT></TEXT>
        <DATUM></DATUM>
      </ROW1>
    </ROW0>
    <ROW0>
      <UTBILDNING_ID></UTBILDNING_ID>
      <RUBRIK></RUBRIK>
      <ROW1>
        <INGRESS></INGRESS>
       <ID></ID>
        <TEXT></TEXT>
        <DATUM></DATUM>
      </ROW1>
      </ROW1>
    </ROW0>
    Can you help?
    Regards
    Olle

  • Alignment of objects

    Following situation: I got, like, 10 objects in vertical aligment, all have the same width. Now I want their center point to align on X = 7.5mm. So I select them all, use "Align on vertical axis" (or so, got german Indesign) and then set the top-middle reference point
    and set X to 7.5mm with all 10 objects selected. After this, when selecting a single object, the X value is not 7.5, it is some higher or lower (like in the small image).
    But for all objects, the average of the 10 X values will still be 7.5mm.
    How to get rid of this? Do I have to select every single object and set X = 7.5mm manually?

    Problem solved. Sorry for the confusion. I just used the wrong alignment tool, instead of , though it worked somehow, but not correctly.

  • Output could not be issued - VT03n

    Hi,
    There is an issue with a few shipping documents when trying to print : Transaction VT03n
    When you choose 'Shipment --> Issue output to --> Screen, message number VW086 appears:
    "Output could not be issued"
    For output type ZDG1.
    Can any one suggest what could be the reason for this message as it is not happening for all documents except a few.
    Thanks & Regards,
    MK
    Edited by: MK18774 on Sep 3, 2009 6:06 PM

    i mean, like Condition records, sequences etc. But, i guess, they are fine.
    Some times the reason could be: If the text is over flowing than window size or word wrapping or window size is bigger than the specified page size, over lapping text contained windows, wrong alignment etc..........so, reduce the content of the text in each window, then try. Also pls. wait for replies from other experts, before re-sizing the windows
    thanq
    Edited by: SAP ABAPer on Sep 3, 2009 6:26 PM

  • HP Laserjet 2820 - print spooler was unable to connect

    Working in Microsoft 2003 and printer is on a wireless network. In over a year - never had a problem until 5 days ago an error message appeared when I attempted printing which stated... print spooler was unable to connect to your printer. This can be caused by your printer being turned off, the cable being unplugges, or being connected to a VPN, which will block your access to your local network.
    Also, when I attempted accessing the Print Settings from HP Director, it would not open and gave an error message...An unknown error occurred. Make certain that the device's power cord is plugged in, the power is turned on, and that all cables are properly connected. Check the Troubleshooting tab or product documentation for more information.
    Next, I thought I would delete the software and re-install.  However - I no longer have the installation disk for the printer.I then tried changing the printer port to a standard port. That did not work.
    Help would be greatly appreciated.
    Thank you.

    hi everyone
    i have same problem on hp clj2820, half page printed, half page
    1)  i cleaned laser mirrors and verify conectors and wires of laser scanner unit ... the problem persist
    2) i inspected carousel assembly, a small plastic gear on the upper left side was wrong aligned, 1 tooth scrolled up or down, i fit this tooth in correct position ... the problem persist
    what is happening?, regards

  • HP LaserJet 2820 All-in-One fails to print on right side of the page

    I have HP LaserJet 2820 All-in-One for 1.5 years now and before the first set of cartridges run out of ink, the printed page comes out blur or no printing on the right side of the page. No smear on the right page.  It doesn't matter if I used color or black printout, the right page still come out blur or prints.
    I replaced all new HP OEM cartridges, I then replaced HP OEM fuser RG5-7602 located on the bottom back of the printer, reset the page setting menu and as a result the problem still exists.  In one year and half, the total cost for the printer and replacement of cartridges and fuser came out to be almost $1407 and now I can't use the printer.  I don't want to junk the printer or spent hundred of dollars more to resolve this problem.  If any one encountered this issue before, I appreciate if you can guide me to resolve this problem.   Thank you so much

    hi everyone
    i have same problem on hp clj2820, half page printed, half page
    1)  i cleaned laser mirrors and verify conectors and wires of laser scanner unit ... the problem persist
    2) i inspected carousel assembly, a small plastic gear on the upper left side was wrong aligned, 1 tooth scrolled up or down, i fit this tooth in correct position ... the problem persist
    what is happening?, regards

  • Dreamweaver fails to boot up. page links will not open in explorer

    i have the current dreamweaver as part of my cretive cloud subscription. i have a mac, os 10.8.5. for months after i subscribed to creative cloud, dreamweaver worked fine. then, after doing a CC update about two weeks ago, dreamweaver refused to load. it still fails to load despite numerous sessions with adobe tech support since the initial failure.
    something else has been happening since that CC update. immediately before the update, i added some links to my website. i repeatedly have heard from people telling me they get bad link messages when trying to use those links. yet every time i test those links using safari or firefox, they work fine. last night, i talked to someone who had an interesting experience while trying to use the "faulty" links. he received the "bad link" message when trying to go in via internet explorer. when he switched browsers to chrome, the links worked just fine. has adobe created an internet program that is toxic to explorer?

    YIKES!
    You have over 259 html errors on your home page alone.
    You also have a lot of weird <div align="center"> nesting going on.
    With all of those errors and structural defects, it's hard to know what exactly may be causing the link issue in IE. IE is the single worst browser for display/behavior problems when it runs into html errors.
    Those have to be cleaned up. Visit the validator at http://validator.w3.org to see them
    Looks like there may be some issues in your .asp since it's writing the & symbol into your links and under the html 4.01 doctype, that's a no-go. I'm not an .asp coder, but I imagine there is a much better way to display those links so it doesn't throw errors. 
    All told, the code of that page is roughly 20 times longer than it should be with all the redundant and unnecessary <div align="center"></div> tags. Looks like they're even put into blank table cells for some reason? CSS would be a much, much more efficient way to center text there.

  • Problem with number-fields in csv-Export-Files

    Hello,
    the export with the csv option works fine and our users like this export-function.
    But Unfortunatelly we have some problems with the exported number fields. In my region I defined the field with a format mask.
    On the screen it looks fine but when I change to csv the values are exported as text-values.
    So in excel the columns are shown with left alignment.
    When I try to change the format in excel to number, excel change the column type but not the value inside.
    On this account we cannot use the sum-function and the display of the value is wrong (alignment).
    Which possibilities do I have to resolve that problem?
    Thanks in advance
    Ulrike

    I have the same issue - Anyone any ideas on how to export currency values in a report to excel as numbers?

  • Headless problems

    Hello, guys!
    I'm very tired of headless mode...
    I have to create image from JComponent (a big chart inside JPanel) at the server side.
    I've started with simple test progrmam:
    ===========================
    public static void makeTestImage() throws Exception {
    System.out.println("Headless? " + GraphicsEnvironment.isHeadless());
    JPanel panel = new JPanel();
    panel.addNotify(); // Since we have no pack
    panel.setOpaque(true);
    panel.setPreferredSize(new Dimension(300,300));
    panel.add(new JButton("Test"));
    BufferedImage image = new BufferedImage(300,300,BufferedImage.TYPE_INT_ARGB);
    Graphics g = image.createGraphics();
    panel.print(g);
    ImageIO.write(image, "png", new File("test.png"));
    =============================
    I'm running it with : -Djava.awt.headless=true
    Here is output, "Headless? true"
    But new image is just black panel 300x300
    I've tried open exist image and printString there: no problem. But i can not
    export JComponent into image...
    Surprisely, when i've add new method:
    ============================
    public static void paintMe(JComponent comp, Graphics g) {
    int count = comp.getComponentCount();
    comp.paint(g);
    for(int i=0;i<count;i++) {
    if( comp.getComponent(i) instanceof JComponent) {
    paintMe((JComponent)comp.getComponent(i),g);
    else {
    comp.getComponent(i).paint(g);
    ============================
    and insteam of panel.paint(g), calling paintMe(panel,g), sometimes it works!!!
    But not always. And it worked only for 1 panel. If I add new JPanel with some components inside panel,
    I've got HadlessException. It could be fix with set doubleBuffer(false) for new JPanel, but as result: wrong alignment (one component under second...) And it doesn't work always!
    I'me so tired with this task, but it is impossible to ask admin for instaling and running X-server at the UNIX box...
    Could anybody say me, how i can fix my problem ? Or headless is real Head Less for Java 1.4 and i have to use X-emulator or pja lib ?
    Tested platform:
    WindowsNT
    java version "1.4.2_03"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_03-b02)
    Java HotSpot(TM) Client VM (build 1.4.2_03-b02, mixed mode)
    Solaris
    java version "1.4.1_01"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
    Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)

    I've used headless graphics too; 1.4 should be ok with them
    Though what I haven't done is to use JComponents in headless. I've just created a BufferedImage and drawn to that. Are you sure you need to draw GUI components?
    <guessing mode on>GUIs tend to run in their own threads. The GUI thread gets a repaint event, at which point it redraws. The random behaviour could be from that: sometimes the GUI thread manages to run and repaint, sometimes not. Maybe put a bit of Thread.sleep() in there -- though this would not be an industrial strength solution, as it very much creates a race condition. But if you need to create a few one-off "screen shots" of a program for a manual or something you might get away with it.

Maybe you are looking for