JRadioButton/JCheckBox and text alignement

Hi all,
It is possible only using JRadioButton and JCheckBox to have when using several
of these elements to have text on the left aligned to left and the button right aligned
with the gap in between being variable so that start of text and buttons are aligned.
I would like to have that
Text of my fist button    0
2nd text                  0
3rd text                  0                        
^--- text left aligned    ^---- here the radiobuttons/check boxes right alignedI know how to set text on the left side: myRadioButton.setHorizontalTextPosition(myRadioButton.LEADING).
This is not a problem.
Thanx,
Xavier.

Looking at this, I can't see an easy way. Using the
components you specified, I guess I would set the font
to a fixed size font, and pad the labels with spaces.
If I was going it, I would make each label a JLabel,
not assign a label to a checkbox, and put them
together with a GridLayout. Hope this helpsWell this can be a solution but I would like two things:
-1 be able to use any font
-2 have the default behaviour of RadioButton or Checkbox
that is text also selectable not only the button itself.
I tried another solution: working the FontMetrics and
defined gap between text and icon. But it must be buggy
because it is look and feel (L&F) dependant. In my example,
it only works as expected for motif L&F (i'm running under XP).
And funny enough in my real application, it also works on XP.
Metal that should be the most portable is the worse! :(
I tried J2SE 1.4.3_02 and 1.5.0beta1: same result reagding
alignement.
Is it a bug or a mistake from my side?
Here is my code:
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
public class DoubleAligned extends JFrame {
  protected JMenu lookAndFeelMenu;
  protected Action metalAction;
  protected Action motifAction;
  protected Action windowsAction;
  public static final String METAL_LOOK_AND_FEEL = "javax.swing.plaf.metal.MetalLookAndFeel";
  public static final String MOTIF_LOOK_AND_FEEL = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
  public static final String WINDOWS_LOOK_AND_FEEL = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
  protected JPanel singleAlignementPane;
  protected JPanel doubleAlignementPane;
  protected ButtonGroup singleBG;
  protected JRadioButton jRadioButton_s1;
  protected JRadioButton jRadioButton_s2;
  protected JRadioButton jRadioButton_s3;
  protected JRadioButton jRadioButton_s4;
  protected JCheckBox jCheckBox_s1;
  protected Set buttonSet;
  protected ButtonGroup doubleBG;
  protected JRadioButton jRadioButton_d1;
  protected JRadioButton jRadioButton_d2;
  protected JRadioButton jRadioButton_d3;
  protected JRadioButton jRadioButton_d4;
  protected JCheckBox jCheckBox_d1;
  /** Creates a new instance of JSCResultModePanel */
  public DoubleAligned(String title) {
    super(title);
    lookAndFeelMenu = createLookAndFeelMenu();
    JMenuBar mb = new JMenuBar();
    mb.add(lookAndFeelMenu);
    setJMenuBar(mb);
    JPanel jPanel = new JPanel();
    jPanel.setLayout(new BorderLayout());
    singleAlignementPane = createSingleAlignPane();
    doubleAlignementPane = createDoubleAlignPane();
    jPanel.add(singleAlignementPane,BorderLayout.WEST);
    jPanel.add(doubleAlignementPane,BorderLayout.EAST);
    setContentPane(jPanel);
  private JPanel createSingleAlignPane() {
    JPanel jPanel = new JPanel();
    jPanel.setBorder(BorderFactory.createTitledBorder("Single aligned (swing default)"));
    // Creation of the layout
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    c.weighty = 1.0;   //request any extra vertical space
    c.weightx = 1.0;   //request any extra horizontal space
    c.gridwidth = 1;
    c.insets = new Insets(2,2,2,2);
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.BOTH;
    jPanel.setLayout(gridbag);
    // Creation of sub elements
    singleBG = new ButtonGroup();
    jRadioButton_s1 = new JRadioButton("First radio button long text");
    jRadioButton_s1.setHorizontalTextPosition(JRadioButton.LEADING);
    jRadioButton_s1.setBackground(Color.PINK);
    jRadioButton_s2 = new JRadioButton("2nd is shorter");
    jRadioButton_s2.setHorizontalTextPosition(JRadioButton.LEADING);
    jRadioButton_s2.setBackground(Color.GREEN);
    jRadioButton_s3 = new JRadioButton("shortest");
    jRadioButton_s3.setHorizontalTextPosition(JRadioButton.LEADING);
    jRadioButton_s3.setBackground(Color.RED);
    jRadioButton_s4 = new JRadioButton("4th");
    jRadioButton_s4.setHorizontalTextPosition(JRadioButton.LEADING);
    jRadioButton_s4.setBackground(Color.MAGENTA);
    singleBG.add(jRadioButton_s1);
    singleBG.add(jRadioButton_s2);
    singleBG.add(jRadioButton_s3);
    singleBG.add(jRadioButton_s4);
    jCheckBox_s1 = new JCheckBox("Check box is also taken into account");
    jCheckBox_s1.setHorizontalTextPosition(JCheckBox.LEADING);
    jCheckBox_s1.setBackground(Color.YELLOW);
    // Layout of all the components (components added column by column)
    c.gridx = 0;
    c.gridy = 0;
    jPanel.add(jRadioButton_s1,c);
    c.gridy = 1;
    jPanel.add(jRadioButton_s2,c);
    c.gridy = 2;
    jPanel.add(jRadioButton_s3,c);
    c.gridy = 3;
    jPanel.add(jRadioButton_s4,c);
    c.gridy = 4;
    jPanel.add(jCheckBox_s1,c);
    return jPanel;
  private JPanel createDoubleAlignPane() {
    JPanel jPanel = new JPanel();
    jPanel.setBorder(BorderFactory.createTitledBorder("Double aligned"));
    // Creation of the layout
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    c.weighty = 1.0;   //request any extra vertical space
    c.weightx = 1.0;   //request any extra horizontal space
    c.gridwidth = 1;
    c.insets = new Insets(2,2,2,2);
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.BOTH;
    jPanel.setLayout(gridbag);
    // Creation of sub elements
    doubleBG = new ButtonGroup();
    buttonSet = new HashSet();
    int largerButtonSize = 0;
    jRadioButton_d1 = new JRadioButton("First radio button long text");
    jRadioButton_d1.setHorizontalTextPosition(JRadioButton.LEADING);
    jRadioButton_d1.setBackground(Color.PINK);
    buttonSet.add(jRadioButton_d1);
    jRadioButton_d2 = new JRadioButton("2nd is shorter");
    jRadioButton_d2.setHorizontalTextPosition(JRadioButton.LEADING);
    jRadioButton_d2.setBackground(Color.GREEN);
    buttonSet.add(jRadioButton_d2);
    jRadioButton_d3 = new JRadioButton("shortest");
    jRadioButton_d3.setHorizontalTextPosition(JRadioButton.LEADING);
    jRadioButton_d3.setBackground(Color.RED);
    buttonSet.add(jRadioButton_d3);
    jRadioButton_d4 = new JRadioButton("4th");
    jRadioButton_d4.setHorizontalTextPosition(JRadioButton.LEADING);
    jRadioButton_d4.setBackground(Color.MAGENTA);
    buttonSet.add(jRadioButton_d4);
    singleBG.add(jRadioButton_d1);
    singleBG.add(jRadioButton_d2);
    singleBG.add(jRadioButton_d3);
    singleBG.add(jRadioButton_d4);
    jCheckBox_d1 = new JCheckBox("Check box is also taken into account");
    jCheckBox_d1.setHorizontalTextPosition(jCheckBox_d1.LEADING);
    jCheckBox_d1.setBackground(Color.YELLOW);
    buttonSet.add(jCheckBox_d1);
    // Layout of all the components (components added column by column)
    c.gridx = 0;
    c.gridy = 0;
    jPanel.add(jRadioButton_d1,c);
    c.gridy = 1;
    jPanel.add(jRadioButton_d2,c);
    c.gridy = 2;
    jPanel.add(jRadioButton_d3,c);
    c.gridy = 3;
    jPanel.add(jRadioButton_d4,c);
    c.gridy = 4;
    jPanel.add(jCheckBox_d1,c);
    return jPanel;
  private JMenu createLookAndFeelMenu() {
    JMenuItem menuItem = null;
    JMenu jMenu = new JMenu("Look and feel");
    // *** Metal menu item ***
    metalAction = new AbstractAction("Metal", null) {
      public void actionPerformed(ActionEvent e) {
        updateLookAndFeel(METAL_LOOK_AND_FEEL);
    menuItem = jMenu.add(metalAction);
    // *** Motif menu item ***
    motifAction = new AbstractAction("Motif", null) {
      public void actionPerformed(ActionEvent e) {
        updateLookAndFeel(MOTIF_LOOK_AND_FEEL);
    menuItem = jMenu.add(motifAction);
    // *** Windows menu item ***
    windowsAction = new AbstractAction("Windows",null) {
      public void actionPerformed(ActionEvent e) {
        updateLookAndFeel(WINDOWS_LOOK_AND_FEEL);
    menuItem = jMenu.add(windowsAction);
    return jMenu;
  private int getMax(int item1, int item2) {
    return item1<item2 ? item2 : item1;
  public void paint(Graphics g) {
    FontMetrics fm = getFontMetrics( g.getFont( ) );
    String stringButton;
    AbstractButton myButton;
    int maxWidth;
    Iterator i;
    maxWidth = 0;
    i = buttonSet.iterator();
    // Hack to have text on the left and left aligned with the buttons themselves
    // on the right and right aligned to.
    // WARNING: Do not use HTML button because Button.getText will return the
    // HTML source not the result. Note also that it's not possible to use
    // Button.getSize().width because it returns the size after the layout process
    // it for display.
    while (i.hasNext()) {
      stringButton = ((AbstractButton)i.next()).getText();
      maxWidth = getMax(maxWidth, fm.stringWidth(stringButton));
    i = buttonSet.iterator();
    int currentWidth;
    int newGap;
    while (i.hasNext()) {
      AbstractButton currentButton = (AbstractButton)i.next();
      stringButton = currentButton.getText();
      currentWidth = fm.stringWidth(stringButton);
      newGap = maxWidth - currentWidth + 10;
      currentButton.setIconTextGap(newGap);
    super.paint(g);
  public void updateLookAndFeel(String lookAndFeel) {
    try {
      UIManager.setLookAndFeel(lookAndFeel);
      SwingUtilities.updateComponentTreeUI(this);
    } catch (Exception e) {
      // log an error
  public static void main(String []args) {
    DoubleAligned frame = new  DoubleAligned("A solution to have double alignemnt of several radio buttons/check boxes");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);
}

Similar Messages

  • Main window Boxes and text alignment

    Dear all,
    please  correct me .........i am displaying line items (materials) with their material code,description,quantity etc in the main window of a invoice.now my requirement is i have to create boxes and display each field in a box in main window,and  in each box the field value or text shud be aligned properly.......means it shud not cross the box.
    for this im following dis sequence .
    1. box command (for creating boxes)
    2. protect....end protect ......in between the heading and value to be populated
    i ve executed but iam able to display only 1 line item.please correct me

    quite a difficult task.
    At first you need either items of fixed height, or you need to create those boxes dynamically. Since you dont know how much items will get printed you need to create them half dynamically anyway.
    I´d strongly recommend you to do this is SMARTFORMS rather than in sap-script. Cause smartforms got the tools for such tasks, and makes it quite easy while in SAP-SCRIPT it is one of the hardest requirements to come by.

  • Adobe Captivate - Multiple Choice Quiz Question - Radio Button and Text Alignment

    I have created a quiz with multiple choice questions.
    No matter what I do I cannot align the radio button and the text for the choices (see below).
    I would like to align the center of the radio button with the center of the letter A) and B).
    I have tried every option that I can think of in the Properties options.
    Please let me know if anyone has a solution for this.
    Thank you

    Thanks for the reply.
    Previously I tried several different combinations of fonts and font sizes, but didn't see any change.
    Does anyone else know of anything else that could effect this situation?

  • Image and Text Alingment

    I am trying to build a site and know little about coding. I
    want my pictures and text to line up accordinly with whatever size
    window I have open. I heard of a relative percentage code like
    image resizes to 75% of the screen but I dont know how this works.
    Is there any other way to keep everything on page aligned with the
    changing screen size that Im not thinking of and how do I do it?
    Thanks

    Hello,
    It's difficult to imagine what type of alignment you are
    referring to.
    Do you mean to align the top of the image with the first line
    of text?
    Keep text and images the same distance from each other?
    Keep the image and text aligned in the center of the page?
    Remember that text will be different sizes depending on the
    text setting in
    the users browser, but the image will be the same size.
    It's virtually impossible to keep text aligned with an image
    unless the text
    is an image, too. You don't want that though.
    You could apply a % to image size, but that usually makes the
    image look
    terrible, and might not be affected by or be the same ratio
    as text size
    determined by a browser setting..
    Can you post a link to a picture of what you are trying to
    do, or a link to
    a site that has the same type of alignment you are trying to
    have?
    Take care,
    Tim
    "JaguarLips" <[email protected]> wrote in
    message
    news:fqg535$q1j$[email protected]..
    >I am trying to build a site and know little about coding.
    I want my
    >pictures
    > and text to line up accordinly with whatever size window
    I have open. I
    > heard
    > of a relative percentage code like image resizes to 75%
    of the screen but
    > I
    > dont know how this works. Is there any other way to keep
    everything on
    > page
    > aligned with the changing screen size that Im not
    thinking of and how do I
    > do
    > it? Thanks
    >

  • New to CSS, text-align and line-height ok in 'Design', but not in browsers (IE 10 & Chrome) on Win8

    [DREAMWEAVER CC]
    I'm now learning CSS, and find that where I specify in an external style sheet
    h1 {
              font-family:Baskerville, "Palatino Linotype", Palatino, "Century Schoolbook L", "Times New Roman", serif;
              text-align:center;
              color: black;
              font-size: 1em;
              font-weight: normal;
              font-style: normal;
              line-height: 3.0;
              letter-spacing: 0px;
              word-spacing: 10px;
    text-shadow: 3px 3px 5px #333;
    text-decoration: none ;
    text-transform: none;
    That, in DW Design, they look fine, but in Windows 8, IE 11 and ChromeVersion 31.0.1650.63 m   that the text-align: center; and the line-height: 3.0;  are ignored.
    I work around by specifying <tr align="center" height = "77">   shouldn't the text-align: center; and the line-height: 3.0;  be specifiable in my CSS??
    Thanks for any help!
    <tr height="77" align="center">
            <h1>
                <td bgcolor="CornSilk">1/28/2014</td>
                <td>the Sky</td>
                <td>Fate is the Hunter</td>
              <td >Ernest Gann</td>
                <td >John</td>
                <td >Jessica</td>
              <td><a href="http://www.amazon.com/FATE-HUNTER-Ernest-K-Gann/dp/0671636030/ref=sr_1_1?s=books&ie=UTF8&q id=1387462831&sr=1-1&keywords=ernest+gann">Learn More</a></td>
            </h1>
        </tr>

    hemmi1 wrote:
    [DREAMWEAVER CC]
    I'm now learning CSS, and find that where I specify in an external style sheet
    Not sure what it is you are trying to do but what you have at the moment is invalid code which is most likely why it doesn't work cross browser. (of cousre this css does not help  - line-height: 3.0; - 3.0 what? - px, ems?)
    Here's an example below of how you could do it. Give your table a class (below it is called .myTable) then you can start styling the <td> cell, and anything inside it by appending the element like an <h2> tag to the class name - .myTable h2
    <!DOCTYPE HTML>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Untitled Document</title>
    <style>
    .myTable {
        width: 900px;
        margin: 0 auto;
    .myTable td {
    font-family:Baskerville, "Palatino Linotype", Palatino, "Century Schoolbook L", "Times New Roman", serif;
    width: 150px;
    .myTable h2 {
        margin: 0;
        padding: 0;
    text-align:center;
    color: black;
    font-size: 1em;
    line-height: 50px;
    word-spacing: 10px;
    text-shadow: 3px 3px 5px #333;
    .myTable a {
        display: block;
        text-align: center;
    </style>
    </head>
    <body>
    <table class="myTable" cellpadding="0" cellspacing="0" border="0">
    <tr>
    <td><h2>1/28/2014</h2></td>
    <td><h2>the Sky</h2></td>
    <td ><h2>Ernest Gann</h2></td>
    <td ><h2>John</h2></td>
    <td ><h2>Jessica</h2></td>
    <td><a href="http://www.amazon.com/FATE-HUNTER-Ernest-K-Gann/dp/0671636030/ref=sr_1 _1?s=books&ie=UTF8&qid=1387462831&sr=1-1&keywords=ernest+gann">Learn More</a></td>
    </tr>
    </table>
    </body>
    </html>

  • Sync Text alignment in HTMLEditor and a PDF generated using FOP

    Hi,
    How to sync text alignment in HTMLEditor and a PDF generated using FOP ?
    I tried setting the dimensions of HTMLEditor and PDF in pixels by calculating the size in Pixels for A4 paper size with a particular dpi value.
    Have done the font settings as well. The problem is I see uneven line cuts in the PDF as compared to HTMLEditor.
    Thanks.

    It's not a realistic expectation. You are expecting the PDF produced by whoever provided your FOP implementation to observe exactly the same typographical rules as HTMLEditor. Basically it won't, and there is no way to enforce it. Line breaking/hyphenation/word spacing algorithms can be of great complexity. You are expecting two systems that aren't specified to agree, to agree.

  • Align Image and Text Problem

    I have DW CS4 and Windows XP with plenty of memory and have used this method before to align text with an image.  I insert the image on the page and then type in the text beside the image that I want.  If the text is long, then the second line of text will wrap below the image.  I select the image so the properties show.  In the align box, I select how I want the text to align (Top for example).  What is happening is that the first line of text aligns as I want, but all the other text stays below the image. 
    I have tried selecting the alignment first then type the text in and results is the same.
    I am not sure what is causing this.   I have checked properties and unless I am missing something, there is nothing there to make this happen.
    Any suggestions would be greatly appreciated.

    Use CSS floats and padding.  See demo below for details.
    http://alt-web.com/DEMOS/CSS2-Captions-on-floated-images.shtml
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists
    www.alt-web.com/
    www.twitter.com/altweb
    www.alt-web.blogspot.com

  • Regarding JCheckBox and JRadioButton

    hi,
    I have a screen which contains JCheckBox and JRadioButton component on it. when focus is on checkbox i wanted the background color to be green. But once the focus is lost, the background color should be changed to normal.
    Is it possible? Please help me out.. I need it very urgently.
    regards,
    Deepa Raghuraman

    Hello!
    If you mean keyboard focus:
    yourCheckBox.addFocusListener(new FocusListener() {
            public void focusGained(FocusEvent e) {
                 // change color to green
            public void focusLost(FocusEvent e) {
                 // change color to 'normal'
    });I hope it helps you.
    regards
    Feri

  • Text Align and Other annoyances

    I have upgraded from CS3 to CS5 and while i am mostly happy there are some really annoying bugs, features, or pieces of ill thought out logic in Dreamweaver.
    I might be wrong but by default Dreamweaver is a a WYSIWYG editor. Therefore this should make it ideal for editing websites which have text in them. Lets assume that websites include single email campaigns, small static HTML brochure sites, through to large scale CMS websites. In each of these cases i might have the need to align a single piece of text to the right.
    Now DW suggests everything like this should be driven by CSS. In in 90% of cases for general text layout i would agree i.e. default paragraph text size, default alignment, default line spacing, etc. These can then easily be adjusted throughout the website large or small by changing a simple bit off CSS in your style sheet.
    But what if you just need 1 line of text to be different from "default" - CSS is not approrpiate here, and infact it would result in more code to achieve the same goal. why should i have to write a new style into my style sheet, and then link it with a class name, when a simple align="right" will work in that instance. In fact in all instances the chances are that piece of code will be shorter than the class="text-right" definition to apply the CSS (ignoring the CSS code too).
    So why take the align buttons off the property inspector bar? Why make the developers life harder when he is using a tool to make it easier?
    Another issue - which probably is more of a bug than anything. In code, Shift + Tab should outdent the code right. Highlight a block of code and this works. Why then does doing this for a single line of code delete the code?
    I upgraded from CS3 because i was told that was the worst performing version of creative suite out there. And it was buggy as hell. But i am now finding that CS5 is not a great deal better - this applies through the other products too with Illustrator crashing as much as it ever did, il thought out removed features, etc. I am appalled by the quality of the new CS5 - especially as in my upgrade the fee was a good 30% more expensive than the american alternative.
    And before you ask - the machine where i am experiencing this is more than adequate, Quad Core, 6gig of Ram, and on a fresh install of Windows 7.
    An unhappy customer.

    You may need to adjust your workflow to get the most out of CSS.
    I find it works much better to identify the CSS IDs, selectors and class names I will be using in the site.  This bit of pre-planning gives me a basic stylesheet from which I can grab styles at will and add more to as needed.
    /**BASIC LAYOUT**/
    #wrapper { }
    #header { }
    #content { }
    #footer { }
    /**TEXT STYLES**/
    #header h1 { }
    #content h2 { }
    #content h3 { }
    #content p { }
    #footer p { }
    /**RE-USABLE CLASSES**/
    .floatLt {float:left; width: 40%;}
    .floatRt {float:right; width: 40%}
    .clearing {clear:both}
    .center {text-align:center}
    .right {text-align:right}
    /**LINKS**/
    a { }
    a:link { }
    a:visited { ]
    a:hover,
    a:active,
    a:focus { }
    And if you plug all this into an external CSS file to which your HTML documents are linked, sitewide style changes take a minute or two instead of weeks and hours.
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists
    http://alt-web.com/
    http://twitter.com/altweb

  • Text that is both centered and left aligned

    I have many text frames that contain 2 or 3 paragraphs. The paragraphs need to be left aligned. However, they also need to be centered horizontally within their respective text frames (like the example on the right in the picture below). Each set of paragraphs has different lengths, so it would be tedious to have to change the indent on each one or change tabs for each one.
    Is it possible to do this in InDesign CS4 without having to manually position each one?

    jay fresno wrote:
    Peter,
    A table is a great idea. However, I don't think it will work in this case because of other layout considerations. I'm doing a layout that consists of picture frames and text frames. Each picture frame and text frame are grouped together. On each page I'm planning to have a large text frame that contains multiple groups of picture frames and text frames. In the image below there are 9 groups within a single text frame.The large text frames that contain all the groups are threaded to another large text frame on the next page, which also contains sets of grouped picture and text frames.
    The reason for this type of layout is so that a user can insert a new picture/text frame group and all the other groups will automatically move to the right. Or, if a group is deleted, all the other groups will move to the left.
    On some of the pages, there will be a different layout with large group in the lower part of the page (as in the bottom image). At this time, in the bottom image, there are 3 groups in the top row, and there is a single group in the bottom row that contains 3 sets of picture/image groups.
    I am really wrestling with this layout. How the text aligns is a minor consideration. The main challenge is how to make it easy for the user to insert and delete groups of picture/text frames so that all the groups flow the way they should.
    I hope I've described this understandably. I'm open to any suggestions that will make this layout easier to use.
    Hi, Jay:
    Pictures are worth zillions of words, didn't you hear?<G>
    I'm not a designer or layout production guy, so I'm just speculating. If I understand your need to add or delete one or more picture/caption items and have others fill in, horizontal threaded frames may work. For the first page, three horizontal frames, threaded from top-right to middle-left, mid-right to bottom-left. Delete any unit and others flow back; add any unit(s) and the other flow forward - you'd need Smart Text Reflow to flow to a new page.
    Something similar might work for the second page's layout.
    HTH
    Regards,
    Peter
    Peter Gold
    KnowHow ProServices

  • How to add EOL(new line char) to JCheckBox's text??

    I need to add new line char to JCheckBox's text.
    I have a string and I am adding new line char("\n") to that. Then I set that string as the text for JCheckBox. But it is not adding a new line. If you know the solution to this problem, please let me know.
    thanks
    amit

    hi artntek,
    thanks works well. However Since I have 3 or 4 lines (might have even more) of text for JCheckBox, JCheckBox is aligned to middle of text. Is there any way to align it with the top of the text??
    amit

  • Text alignment "Justify" is not aligned in Crystal Viewer.

    Hi,
    I am having a text field in report like paragraph format in Detail section and I have setting the text alignment as u201CJustifyu201D. If I launch the report through dhtml viewer the text is not aligned in justify format, it is getting aligned as left alignment, but it is working properly while exporting to PDF and Design Preview panel.
    This problem is occurs in Crystal Report XI Release 2 and Crystal Report 2008 also.
    This has been already posted and the link is Text Alignment - Justification Problem
    Please help me to overcome this issue.
    Thanks in Advance.

    With CR 2008, make sure you are on SP4:
    SP4
    https://smpdl.sap-ag.de/~sapidp/012002523100008782452011E/cr2008sp4.exe
    SP4 MSI
    https://smpdl.sap-ag.de/~sapidp/012002523100008782532011E/cr2008sp4_redist.zip
    SP4 MSM
    https://smpdl.sap-ag.de/~sapidp/012002523100008782522011E/cr2008sp4_mm.zip
    If that does not help, please provide a link to screen shots of the issue.
    Ludek
    Follow us on Twitter http://twitter.com/SAPCRNetSup
    Got Enhancement ideas? Try the [SAP Idea Place|https://ideas.sap.com/community/products_and_solutions/crystalreports]

  • Table layout w.r.t other tables and text while inserting/deleting rows.

    I have 3 tables in a single page. One is left aligned and other two are right aligned. Then there is some text below the tables. 
    Now when I delete some rows from Table-1 the left aligned one, the Table 2 and text shift up filling the space below Table1.
    Now I don't want the text/table to shift up/down when I add/delete rows from Table1 i.e Table1  should expand/contract in the empty space below it.
    Now If I do the same thing for Table3 (Right aligned one) i.e add/delete rows there is no effect on text as shown :
    All 3 tables are same and have exact positioning and other properties.
    Please suggest any solution as I would be populating the table through word automation service (interop).

    Another approach would be to use nested tables, with your 'outer' table having two columns and the inner tables going into different columns. You can hide the outer table's cell borders so its presence is less apparent. If the Outer table has auto row
    height, it will adjust to accommodate whatever row addition/deletion you do to the inner tables. The only proviso is that the inner tables shouldn't have 'around' text wrapping. The two rhs tables can go into the same cell - all they need is a separating paragraph.
    With this layout, the text will always remain below the outer table.
    Cheers
    Paul Edstein
    [MS MVP - Word]

  • How to change the text alignment of an adf table column

    Hi everyone
    I have a read only adf table that uses banding. What I want to do is change the text align property of one of it's columns but the task seems not at all trivial.
    I tried entering a value for the text-align property in the inline style of the specific af:column tag and failed. I then tried to do the same for the af:outputText element inside the column but still nothing worked. I even created a css style and changed the StyleClass attribute on each or both elements without any luck.
    Can anybody shed some light here ...
    Thanassis

    Specify the text-align in a css.
    Re: styling column headers in adf table

  • JTable text alignment issues when using JPanel as custom TableCellRenderer

    Hi there,
    I'm having some difficulty with text alignment/border issues when using a custom TableCellRenderer. I'm using a JPanel with GroupLayout (although I've also tried others like FlowLayout), and I can't seem to get label text within the JPanel to align properly with the other cells in the table. The text inside my 'panel' cell is shifted downward. If I use the code from the DefaultTableCellRenderer to set the border when the cell receives focus, the problem gets worse as the text shifts when the new border is applied to the panel upon cell selection. Here's an SSCCE to demonstrate:
    import java.awt.Color;
    import java.awt.Component;
    import java.awt.EventQueue;
    import javax.swing.GroupLayout;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JTable;
    import javax.swing.border.Border;
    import javax.swing.table.TableCellRenderer;
    import javax.swing.table.TableColumn;
    import sun.swing.DefaultLookup;
    public class TableCellPanelTest extends JFrame {
      private class PanelRenderer extends JPanel implements TableCellRenderer {
        private JLabel label = new JLabel();
        public PanelRenderer() {
          GroupLayout layout = new GroupLayout(this);
          layout.setHorizontalGroup(layout.createParallelGroup().addComponent(label));
          layout.setVerticalGroup(layout.createParallelGroup().addComponent(label));
          setLayout(layout);
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
          if (isSelected) {
            setBackground(table.getSelectionBackground());
          } else {
            setBackground(table.getBackground());
          // Border section taken from DefaultTableCellRenderer
          if (hasFocus) {
            Border border = null;
            if (isSelected) {
              border = DefaultLookup.getBorder(this, ui, "Table.focusSelectedCellHighlightBorder");
            if (border == null) {
              border = DefaultLookup.getBorder(this, ui, "Table.focusCellHighlightBorder");
            setBorder(border);
            if (!isSelected && table.isCellEditable(row, column)) {
              Color col;
              col = DefaultLookup.getColor(this, ui, "Table.focusCellForeground");
              if (col != null) {
                super.setForeground(col);
              col = DefaultLookup.getColor(this, ui, "Table.focusCellBackground");
              if (col != null) {
                super.setBackground(col);
          } else {
            setBorder(null /*getNoFocusBorder()*/);
          // Set up our label
          label.setText(value.toString());
          label.setFont(table.getFont());
          return this;
      public TableCellPanelTest() {
        JTable table = new JTable(new Integer[][]{{1, 2, 3}, {4, 5, 6}}, new String[]{"A", "B", "C"});
        // set up a custom renderer on the first column
        TableColumn firstColumn = table.getColumnModel().getColumn(0);
        firstColumn.setCellRenderer(new PanelRenderer());
        getContentPane().add(table);
        pack();
      public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
          public void run() {
            new TableCellPanelTest().setVisible(true);
    }There are basically two problems:
    1) When first run, the text in the custom renderer column is shifted downward slightly.
    2) Once a cell in the column is selected, it shifts down even farther.
    I'd really appreciate any help in figuring out what's up!
    Thanks!

    1) LayoutManagers need to take the border into account so the label is placed at (1,1) while labels just start at (0,0) of the cell rect. Also the layout manager tend not to shrink component below their minimum size. Setting the labels minimum size to (0,0) seems to get the same effect in your example. Doing the same for maximum size helps if you set the row height for the JTable larger. Easier might be to use BorderLayout which ignores min/max for center (and min/max height for west/east, etc).
    2) DefaultTableCellRenderer uses a 1px border if the UI no focus border is null, you don't.
    3) Include a setDefaultCloseOperation is a SSCCE please. I think I've got a hunderd test programs running now :P.

Maybe you are looking for

  • Changing default open with for file type for all users

    hello can I change the default app to open a specific file type for all users and not juist for my user? i am admin for my mac mini. tnx gil

  • I need help getting my IPhone 5 to work in Mexico

    So I'm in La Paz and found a Telcel customer service center that had the small SIM card required for the IPhone 5.  I checked with Verizon twice and they tell me it is unlocked.  Telcel say my account is activated but my phone says no service.  When

  • HT4847 How to restore from the cloud?

    I need to restore pictures from the cloud to my ipad.  I had pictures on my computer stored and the hard drive crashed.  Help?

  • BPC7.5NW: How to increase default Dimension Properties length

    Hi Experts, May I know if it is possible to increase the maximum length of default dimension properties, such as ID and EvDescription? I know we can set the property length in "Modify Dimension Property". However, I don't see those default dimension

  • Start Date, End Date Validation ?

    Hi I am new to OA framework world. I created a page and i have 2 columsn start date, end date I want to display msg to user, if start date greater than end date . My question is 1) how to grab the values? or where do i need to write a validation code