How to make JLabel Left Justified in Gridbag Layout?

Hi Govind here I am using Gridbag layout and having Labels and TextBox . i want my All my Labels Left Justified (Currently they are RightJustified),I tried JLabel.Left but not working so any help most welcome............
JLabel startDateLabel      = new JLabel("STARTDATE ",JLabel.LEFT);
          startDateLabel.setBorder( border );                                   
          //set the position of the label               
          gbc.fill = GridBagConstraints.NONE;
          usingGBC(startDateLabel,gbc,3,0,1,1.0);
               //text field for start dat
txtStartDate                = new JTextField();
          txtStartDate.setMinimumSize(minSize);
          txtStartDate.setPreferredSize( longField );
          txtStartDate.setEnabled( true);                    
          txtStartDate.setEditable(false);
          txtStartDate.setBackground(Color.WHITE);          
          gbc.fill = GridBagConstraints.HORIZONTAL;
          usingGBC(txtStartDate,gbc,4,0,2,1.0);
     here usingGBC is method as follows
protected void usingGBC(Component com,GridBagConstraints gbc,int gx,int gy,int gwidth,double wx)
               gbc.gridx = gx;
               gbc.gridy = gy;
               gbc.gridwidth = gwidth;
               gbc.weightx = wx;
               add(com,gbc);

It seems you set the fill of the GridBagConstraints after you add the label. Either specify HORIZONTAL fill before adding the label or specify alignment for the constraints.
Mike

Similar Messages

  • How to make a left side menu?

    I need to know how to make a left side menu for my site,  can anyone help me? I am new to macromedia dreamweaver MX. Thanks

    I prefer to use CSS styled lists for menus.  Very easy to edit later.  Web friendly for people and search engines.
    EXAMPLE:
    http://alt-web.com/TEMPLATES/3-col-fixed-layout.shtml
    Several FREE CSS menu systems here.
    CSS Express Drop-Down Menus  (tutorial)
    http://www.projectseven.com/tutorials/navigation/auto_hide/
    CSS Tab Designer creates 60+ CSS Styled Button and Tab Menus  (download)
    http://www.highdots.com/css-tab-designer/
    List-O-Rama  (DW Extension)
    http://www.dmxzone.com/go?5618
    CSS  Menu Maker (On-Line Menu Generator)
    http://www.cssmenumaker.com/
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists
    www.alt-web.com/
    www.twitter.com/altweb
    www.alt-web.blogspot.com

  • How to make a left slider?

    The link below contains a slider on the left with title called "Menu" which can be clicked to make it go away and then back on.
    http://apex.oracle.com/pls/otn/f?p=65555:54:289368566520602::NO:
    How do I make it?

    That one is done with ExtJS.
    You can also do someting similar using jQuery Layout Plugin (see http://layout.jquery-dev.net/). An APEX demo is available at http://apex.oracle.com/pls/apex/f?p=41715:60. All panels are resize-able and you can click on a panel separator to show/hide a panel.

  • How to make fixed width size on grid layout managers.,

    hiya,
    my gird contains labels but whenever the labels has different width on their texts, the grid adopts to the width of the text, how not to?
    many thanks! :)

    Thats the way the GridLayout works, each cell is the same size. The size is determined by the largest component added to the grid.
    Here is the Swing tutorial on "Using Layout Managers".
    http://java.sun.com/docs/books/tutorial/uiswing/layout/using.html

  • How to make "two column & one column" mixed layout?

    When writing a review, I want the main article part to be "two column layout" while the topic and abstract to be "one column layout". How could I do that?
    THX

    Another possible, less elegant solution working in a Word Processing (text based) template, rather than a Page Layout template, is to insert the "Layout Break" function, which drops down from insert. That allows a new "section" to be set up. Each section can be formated for the number of columns you choose. This allows you to switch back and forth without going to a new page.
    If you are familiar with MS Word, this function is similar to the "section break" command in Word.

  • Excel output Left justified using OLE

    Hi,
    Can anyone please let me know how to align all the cells in the excel sheet as LEFT JUSTIFIED using OLE? I have few numeric values and by default it will be on the right side, i want to make it left justified.
    Edited by: Pradeep Kumar on Jan 19, 2011 1:36 PM

    Its obvoius that you will always find numeric values of right aligned.
    I had faced a similar kind of issue while downloading PSTLZ  US Postal Codes. You can try this way:
    Place a apostrophe to the field you need to be left aligned
    ' ' ' '           " This  defines your apostrophe
    You can check this in excel. Just place a equal sign and apostrophe infront of the value and press enter. The value will be left aligned.
    Try the same thing in your code.
    It was a very old change for me. Trying to get some sample code snippet for referance.
    Here it goes:
    CONSTANTS: c_prefix VALUE '='.
        CONSTANTS: c1_prefix VALUE ' " '.
        CONCATENATE  c_prefix
                   c1_prefix
                   i_lfa1-pstlz
                   INTO i_lfa1-pstlz
    ~ Last edited for adding the code snippet
    Edited by: K.Manas on Jan 19, 2011 9:35 AM

  • FCP title tool - left justified text

    I'm just generating basic titles within FCP using the built in title tool (not Motion or Live), and need to make some left justified title cards. Centering the text works fine, everything fits on screen. But, when I select "left" justification, the font STARTS in the center of the screen and I lose the last few words off the right side of the screen! When I try to move the font with wireframe, I can place the text manually where I want it, but the words are still cut off on the right side. I know there must be a simple solution to this... right?

    Don't move the text by using the wireframe. This just moves the whole layer and you will see the text being but at the border. You need to use the "Origin" parameter to position the text.

  • How to use left-justified with Move command??

    Hi,
    I have a field BKPF-XBLNR which I have to download to an final output table. I am using the command "Move"...
    Move T_BKPF-XBLNR to T_OUTPUT-XBLNR.
    My problem is that for some records this field is a combination of characters and numbers ... but some are purely numbers ... The records which are a combination of character & numbers are left justified where as the numeric one's are getting right justified once I get the output in the excel sheet ... How do I make these numeric ones left justified ... ??
    Thank You,
    SB.

    You can use this:
    shift T_BKPF-XBLNR left deleting leading space.
    Move T_BKPF-XBLNR to T_OUTPUT-XBLNR.
    if it does not work then
    data : temp_xblnr type char16.
    Move T_BKPF-XBLNR to temp_XBLNR.
    shift temp_XBLNR left deleting leading space.
    Move temp_XBLNR to T_OUTPUT-XBLNR.
    I am sure it will work.

  • How to make numbers in message text input  fields left aligned?

    Hi Friends
    I have completed one of my task .but getting result right side of the field.
    how to make numbers in message text input  fields left aligned?
    Thanks
    Aravinda

    Hi ,
    Sorry for late replay i am trying this alos not set that page....
    pageContext.forwardImmediatelyToCurrentPage(null, true, null);
    and one more that kff field working is fine for ex display any text pled displayed properly and only problem is not set the value and HrSitKeyFlex6 and HrSitKeyFlex7 fields are perfectly get the values but not pront HrSitKeyFlex8 that only my issue....
    Regards,
    Srini

  • How do I left justify the text in the tabs of a JTabbedPane.

    In 1.3.1 this used to work by supplying an HTML string with <div align="left"> but when I run with 1.4.1 this is now broken and I get center justification.
    Does anybody know a way to get the text in the tabs to be left justified.
    Thanks,
    Philip

    First, I found while using JTabbedPane that the "standard" behavior is to allow to a tab the exact space needed to display the tab text. Hence with this behavior, there is actualy no difference of "left" or "center" aligned text. So I assumed that you found a way or another to make your tabs wider than the "string width"...
    Here is a solution:
    You can override the TabbedPaneUI class and ajust the "layoutLabel()" method. Here is the code..
    //Your code using the tabbedPane
    JTabbedPane tp = new JTabbedPane();
    tp.setUI(new LeftTabbedPaneUI());
    //File containing the overrided TabbedPaneUI
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import javax.swing.text.View;
    class LeftTabbedPaneUI extends javax.swing.plaf.metal.MetalTabbedPaneUI {
            //I also overrided this function just to force tabs wider than
            //the displayed "String Width". I asume that you found another
            //way to do this so you can delete this function in your
            //implementation
         protected int calculateTabWidth(int tabPlacement, int tabIndex, FontMetrics metrics){
              return 150;
        protected void layoutLabel(int tabPlacement,
                                   FontMetrics metrics, int tabIndex,
                                   String title, Icon icon,
                                   Rectangle tabRect, Rectangle iconRect,
                                   Rectangle textRect, boolean isSelected ) {
            textRect.x = textRect.y = iconRect.x = iconRect.y = 0;
         View v = getTextViewForTab(tabIndex);
         if (v != null) {
             tabPane.putClientProperty("html", v);
         //This Line is added to avoid writing on tab border while aligned to left.
         //You can comment this line to test and or adjust the "5" pixel space
         Rectangle rec = new Rectangle(tabRect.x+5,tabRect.y,tabRect.width,tabRect.height);
            SwingUtilities.layoutCompoundLabel((JComponent) tabPane,
                                               metrics, title, icon,
                                               SwingUtilities.CENTER,
                                               SwingUtilities.LEFT,
                                               SwingUtilities.CENTER,
                                               SwingUtilities.TRAILING,
                                               rec,
                                               iconRect,
                                               textRect,
                                               textIconGap);
         tabPane.putClientProperty("html", null);
         int xNudge = getTabLabelShiftX(tabPlacement, tabIndex, isSelected);
         int yNudge = getTabLabelShiftY(tabPlacement, tabIndex, isSelected);
         iconRect.x += xNudge;
         iconRect.y += yNudge;
         textRect.x += xNudge;
         textRect.y += yNudge;
    }Here I overrided the "Metal" implementation of the tab but you must override the implementation of the used Look And Feel,
    ex. "com.sun.java.swing.plaf.window.WindowsTabbedPaneUI" for the windows LAF.

  • How to make an object or a menu to stick to the left edge of the screen?

    I want the left menu to look like here http://muserocket.com/tf/bonesa/  how to make it stick to the left on any monitor?

    Use the Pinning control in the Control Strip to pin your sidebar to the top left of the browser window.

  • How to make those shadowed borders left and right of your page?

    Hi, Can someone tell me if I am on the right track? Here's what I've done so far. I've specified the background colour in the properties section. I've set up a 3 column table (fixed size) that has small columns left and right and a big one in the middle. For those small columns I've pickwhipped to 2 small gifs with the shadow. Previewed in Safari and everything looks ok.
    My question: is this the best way to do this? Or does it need a CSS approach? And if so, how?
    Now I want to give the bottom a shadow as well. Do I proceed in the same way? So make a left corner, right corner and a bottom? I'm working with GL CS2.

    The best way to slice things up depends on how the page is layed out. If the content area has a fixed width that centers (or doesn't), then might make more sense to have 3 vertically stacked divs with the background and drop shadows, then nest another div in the middle with margins for the actual content. Or, if the content size is completely fluid, the same structure could still work with floating divs (or absolutely positioned relative to a single container?) holding the corner images. Or there's always the old-school tables way of slicing things up (though I'd avoid that).
    There's more than one way to do it, and I don't know that any single option is necessarily the "right" way to go... as long as it works and validates?

  • How to left justified the value of the field in script

    hai
    how to left justified the field in script
    for example i am having a field &wa-netwr& , how to left justified the value of this field in scripts
    thank u in advance

    one way is define a paragraph format P1 and in that attributes,you can give LEFT justified(by creating TABS).
    and give that paragraph format in the script editor.
    P1   ,,text
    here ,, denotes tab position.
    or
    use  &wa-netwr(C)& <--for condensing .
    Regards
    Srikanth

  • JLabel in JTextPane - how to make the JLabel be highlightable

    Hi,
    This follows on from this post :
    http://forum.java.sun.com/thread.jspa?threadID=741036&tstart=0
    I'm inserting a JLabel into a JTextPane, and want it to look like the other text there. However when you select the text, the JLabels don't have the highlight painted on them. Does anyone know how to make the highlight be painted over the label?
    I've tried looking at the Highlighter, HighlightPainter classes but as yet no joy.
    thanks a lot,
    Tom

    If I understand what you're after you may find the following will achieve it:
    ((DefaultHighlighter)textPane.getHighlighter()).setDrawsLayeredHighlights(false);Don't ask me why, though!!
    Hope this helps.

  • Flash cs3: how to make moving/scrolling photo menu left and right?

    http://media.moma.org/subsites/2008/miro/flashsite/index.html
    - click continue, then relative size link
    How can I do this with lash cs3: how to make moving/scrolling
    photo menu left and right?
    When you move left and right and paintings move. and when you
    click on a painting, you see the the title and it links to another
    page on the site.

    scene_mc start at x = -550... x wide is 2164 px
    now I have this and its working...
    navL_mc.addEventListener(MouseEvent.MOUSE_OVER, navL_Over);
    navL_mc.addEventListener(MouseEvent.MOUSE_OUT, navL_Out);
    function navL_Over(e:MouseEvent){
              if(scena_mc.x == 0){
                                  scena_mc.x == 0;
              else if(scena_mc.x <= -10){
                                  scena_mc.x += 10;
                                  navL_mc.addEventListener(Event.ENTER_FRAME, runL);
    function runL(e:Event):void{
              if(scena_mc.x == 0){
                                  scena_mc.x == 0;
              else if(scena_mc.x <= -10){
                                  scena_mc.x += 10;
    function navL_Out(e:MouseEvent){
              navL_mc.removeEventListener(Event.ENTER_FRAME, runL);
    navR_mc.addEventListener(MouseEvent.MOUSE_OVER, navR_Over);
    navR_mc.addEventListener(MouseEvent.MOUSE_OUT, navR_Out);
    function navR_Over(e:MouseEvent){
              if(scena_mc.x == -1164){
                                  scena_mc.x == -1164;
              else if(scena_mc.x >= -1154){
                                  scena_mc.x -= 10;
                                  navR_mc.addEventListener(Event.ENTER_FRAME, runR);
    function runR(e:Event):void{
              if(scena_mc.x == -1164){
                                  scena_mc.x == -1164;
              else if(scena_mc.x >= -1154){
                                  scena_mc.x -= 10;
    function navR_Out(e:MouseEvent){
              navR_mc.removeEventListener(Event.ENTER_FRAME, runR);

Maybe you are looking for

  • Unable to run the CODED UI in visual studio 2012 on windows 8

    Hi, I have recorded my first program (i.e Open windows calculator using Windows +R and typing calc in it) using CODED UI in visual studio 2012. I have create the new solution using CODED UI project. I have use the Recorded the steps using UImap- Code

  • Using OS X Install CDs/DVDs On Multiple Macs

    Using OS X Install CDs/DVDs On Multiple Macs The question of using system/software install CDs/DVDs on more than one machine is frequently asked. So, FYI: System software installation CDs/DVDs, that come with a particular Mac model, are hardware spec

  • Output Type Determination

    Hi experts, I have a requirement wherein if an EDI invoice output type is selected during the creation of the billing document, then all the remaining output types below that should not be selected. Please find below the screen shot of the output pro

  • Music in Safari

    I've recently put up a web-site and my music pops when I listen to it in Safari, but it doesn't in Firefox or IE. Does anyone know what's causing this?

  • CAS Policy Manager error when installing Server SQL express 2012

    Hello everyone, I was wondering if anyong can help me with this. I am trying to install SQL server express 2012 on a windows 7 computer and am unable to install it. When I try to start the installer I get the error "Microsoft .NET Framework CAS Polic