How to prevent a JButton in a Table Cell from stretching its size.

Hi,
I have JButton added to a Table Cell. But the button is filled up by covering the whole area of the cell and when I go for increase the width of the Table column, the button size is also stretched up along with the column's increasing width. How can I implement a solutiong so that I have a preferred size for the button so that when I go for stretch the column, the button should retain its preferred size. That mean it should not be stretched.
I hereby added the code for a reference,
    // ButtonEditor
    class ButtonEditor extends DefaultCellEditor {
        private static final long serialVersionUID = 42L;
         private String    label;
         private boolean   isPushed;
                protected JButton button;
         public ButtonEditor(JCheckBox checkBox) {
              super(checkBox);
              button = new JButton();
              button.setOpaque(true);
              button.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        fireEditingStopped();
          * Override the DefaultCellEditor inbuilt method
         public Component getTableCellEditorComponent(JTable table, Object value,
                   boolean isSelected, int row, int column) {
              if(value.equals(AdminToolsRes.resBundle.getString("nei.label.blockSync"))){
                   label = (value == null) ? "" : value.toString();
                   button.setText( label );
                   isPushed = true;
                   return button;
              else
                   return null;
          * Stop cell editing
         public boolean stopCellEditing() {
              isPushed = false;
              return super.stopCellEditing();
          * call the fireEditingStopped method
         protected void fireEditingStopped() {
              super.fireEditingStopped();
          * sets the cell editable to True
          * @return
         public boolean isCellEditable(){
              return true;
    //ButtonRenderer
    class ButtonRenderer extends JButton implements TableCellRenderer {
        private static final long serialVersionUID = 42L;
         public ButtonRenderer() {
              setOpaque(true);
          * Override the TableCellRenderer inbuilt method
         public Component getTableCellRendererComponent(JTable table, Object value,
                   boolean isSelected, boolean hasFocus, int row, int column) {
              if (isSelected) {
                 setBackground(table.getSelectionBackground());
             } else{
                 setForeground(table.getForeground());
                 setBackground(table.getBackground());
              if(value.equals(AdminToolsRes.resBundle.getString("nei.label.blockSync"))){
                   setText( (value == null) ? "" : value.toString() );
                   return this;
              }else{
                   JTextField txtFld = new JTextField();
                   txtFld.setBorder(null);
                   txtFld.setText((value ==null) ? "" : value.toString());
                   if(isSelected){
                        txtFld.setForeground(table.getSelectionForeground());
                        txtFld.setBackground(table.getSelectionBackground());
                   return txtFld;
    }Please help me in answering the question.
SumodeV

I feel, here the JPanel also might get stretched up.All renderers are sized to fill the entire area of the cell, so yes, the panel will get stretched, but the button won't. That is why the suggestion was made.
All renderers are sized to fill the entire area of the cell.
Not sure, but you might be able to override the JTable.prepareRenderer(...) method to reset the size of the button back to is preferred size. I have no idea how this will affect the rendering.

Similar Messages

  • How is it possible to split the table cells in Pages, Version 5.1

    How is it possible to split the table cells in Pages, Version 5.1?

    This is a feature removed in the change from Pages 09 to Pages 5.0.1.
    If you need this facility, revert to Pages 09.  If you upgraded to 5.0.1, then the earlier version is still in your Applications folder in a folder called iWork.

  • How can I copy and paste table cells from Pages into InDesign with minimum reformating?

    How can I copy and paste table cells from Pages into InDesign with minimum reformating?

    Do you mean you want to retain the formatting from Pages, or retain formatting already applied in ID?

  • HT3349 How do you select a sub-set of cells from the entire document so you can print only those specific cells?

    How do you select a sub-set of cells from the entire document so you can print only those specific cells?

    There is no analog to MS Excels print range.  So the next best thing is to plan your data so that you don't need to use print range.  The next best thing after that is to select the range of cells you want to print, then copy, the switch to the application Preview, and create a new document from the clipboard (select the menu item "File > New from Clibboard") then select all, copy then paste to the destination (maybe an email) .
    You can also paste that portion of the table into another table (or a new table) by pasting values only

  • How to insert  jRadioButton/jCheckBox/jButton etc into table cell?

    Please! Please! Please!

    Inserting UI elements into database columns? (That's what "table cell" means, right?) No, bad idea. Don't do that.

  • How to wrap a line in a table cell in adf

    How do I wrap a line of text in a table cell?

    Yes, I tried that. But I have 2 sets of information. I want it to wrap exactly at the start of the second piece of information
    So I am trying to use noWrap in combination with width. How else can I do this. appending \n does not work

  • How to write text vertically in an table cell?

    Is it possible to make a table cell where the
    text would be written along a vertical base line?
    I found how to make a text box and rotate it
    vertically.
    How may I place such a text box in a table cell?
    dan    

    Hello daniel,
    if the table will not be resized or repositioned a lot, the best way to display what you want to have is to create a textbox with the styles and adjustments you need, rotate it and place it over the table cell. Be sure to make the cell big enough to pretend the text of the textbox would be inside of it. The textbox has to be a fix positioned object in the top layer.
    It's only a work-around, but the best you can achieve.
    Frank.

  • How to control the force return in table cell data?

    I have some xml format files.When I import them into FrameMaker,They display as table data.but when the data is very long in table cell,I want to control the new line by myself.for example,I add some \r\n in my xml file data,then in FrameMaker,It can identify the \r\n, force return.In framemaker I don't know the actual symbol that means the newline.How Can I deal with the problem?thank you!

    Hi Russ,
    yes, but you have to agree that forcing a return in the SOURCE content is really not a wise thing to do - It would be better to break the content into multiple paragraphs or used an XSLT to determine the column width and insert your own breaks in a version of the XML for rendering in Frame. If, at a later date, your templates in Frame change to allow wider columns in your table, then you'd have to go back into the source code and change every occurrence of the c/r in the data - Yeuch! Better to transform the data once, before importing into Frame and then if the col-width changes it is a simple task to change the width in the XSLT - personally, I would make sure the EDD and DTD allows multi-lines in the table cell and then break-up the data to fit the table cell size in an XSLT before importing. Then you don't taint your source code...and it is quite easy to do this is an XSLT...

  • How to use 'Execute Procedure' to retrieve table data from an ext. MS SQL ?

    Hi,
    We have to call a stored procedure from an external MS SQL database . We are able to connect to the database and are able to successfully do a SQL (Select ) on the SQL tables. However to maintain data integrity and other security issues, we have to call a stored procedure on that database  from SAP. The stored rocedure will return a table which will contain multiple records .
    We have tried using the EXECUTE PROCEDURE command. However it returns SQL errors?
    Our SAP instance is on MS SQL.
    Please note we have gone through all SAP notes and SDN already. The query is not about connecting to the database. It is solely to find out the correct way for calling the stored procedure. The example in the SAP help documentation is for single IN and OUT parameters. We are able to do that successfully. Our requirement is to get a table back from the stored procedure.
    Please help with the correct syntax and code example if you have one.
    I would be glad to provide any other information that may be helpful.
    Thanks in advance.

    Hi,
    I too have a similar issue, I have a stored procedure written in MS SQL and it executes but I need the result in an internal table; How do I get it into an internal table?
    Following code is being used. Now the output of the query that is being executed, I need it in my internal table
    EXEC SQL.
      EXECUTE PROCEDURE d01.Z_PRICINGREPORT ( IN :i_mandt,
                                              IN :i_kschl,
                                              IN :i_vkorg,
                                              IN :i_vtweg,
                                              IN :i_matkll,
                                              IN :i_matklh,
                                              IN :i_matnrl,
                                              IN :i_matnrh,
                                              IN :i_inco1,
                                              IN :i_inco2,
                                              IN :i_zsalel,
                                              IN :i_zsaleh,
                                              IN :i_kunnrl,
                                              IN :i_kunnrh,
                                              IN :i_chargl,
                                              IN :i_chargh,
                                              IN :i_vkburl,
                                              IN :i_vkburh,
                                              IN :i_vkgrpl,
                                              IN :i_vkgrph,
                                              IN :i_wrkstl,
                                              IN :i_wrksth,
                                              IN :i_mtf,
                                              IN :i_mtt,
                                              IN :i_datbi,
                                              IN :i_werks,
                                              IN :i_stock
    ENDEXEC.
    CATCH cx_sy_native_sql_error.
        MESSAGE `Error in procedure handling` TYPE 'I'.
    endtry.
    Warm Regards,
    Abdullah

  • How to get information of 'include file', 'table', 'function' from the prog

    Hi all.
    I wanna know which 'include file', 'table', 'function' is used in the program.
    Firstly, I prepared user interface for entering the name of program.
    Secondarly,
    I made the way to confirm whether the program is exising or not by using TADIR.
    And I must use CROSS for getting information of function.
    But at the same time, I will use 'RS_GET_ALL_INCLUDES', 'RS_GET_TABLE_REFERENCES' for getting information of include file or table.
    After that, I have to report by using ALV.
    Then, I will use both of string getting from function by using above function and internal table getting from CROSS.
    How do I put together in  INTERNAL TABLE.

    hi,
    look F1 to abap command <b>scan</b> and <b>read report</b>
    A.

  • How to change the colour of the table cell editor on some condition?

    Hi all,
    I have a requirment acco which i need to make the colour of the tableceleditor ias RED and font color white when the data in that is < 0.please tell me how is this possible and its urgent..
    regards
    Sharan

    If you are using release NW04 and have a TextView as table cell editor, you can do this:
    Add a calculated attribute "Color" of DDIC type "com.sap.ide.webdynpro.uielementdefinitions.TextViewSemanticColor" under the data source node of the table.
    Bind the "semanticColor" of the cell editor to this context attribute.
    Implement the get-method for the calc. attribute like this
    WDTextViewSemanticColor get<DataSourceNode>Color(I<DataSourceNode>Element element)
      return element.getValue() < 0 ? WDTextViewSemanticColor.NEGATIVE : WDTextViewSemanticColor.STANDARD;
    Armin

  • How do with change table cells from staticText1 to button1 in run time?

    I have two question:
    first: I think change table's cells from staticText to button in run time?
    how do?
    second: I think change table column's order in run time?how do?
    ex:
    =============change before===========
    name age
    wtu 22
    =============chnage after=============
    age name
    22 wtu
    thanks

    Try something like this:
    1. Drop a Table. By default it has three columns.
    2. Drop a button inside the third column. Set its id property to buttonInColumn3, and set its rendered property to false.
    3. Drop another button, this time outside the table. Set its id property to buttonOutsideTable.
    4. Double-click the buttonOutsideTable and make the method look as follows:
    public String buttonOutsideTable_action() {
    //switch the first two columns
    List cols = tableRowGroup1.getChildren();
    Object col = cols.remove(0);
    cols.add(1, col);
    //toggle between showing staticText3 and buttonInColumn3 (in the third column)
    staticText3.setRendered(!staticText3.isRendered());
    buttonInColumn3.setRendered(!buttonInColumn3.isRendered());
    return null;
    5. Run the application and click the button outside the table several times.

  • How to change the colour of a table cell boder?

    I have just changed from Dreamweaver MX t CS5 and cannot find how to add a colour to the borders of a table and table cells.  In the old MX it was easy just selected the colour for border in properties but in CS5 this option is not availble.  Have tried formatting with CSS but this only colurs the outer boarder can anyone help?

    Not sure what you mean by a custom class would it be possible to give me an example?

  • How to update a Z d/b table record from report - urgent

    Dear SDN Team Members,
    I have created a ztable for list of all active customers. 
    This ztable has link with other SAP Standard D/b tables and I need to compare the entries with my ztable. 
    After doing so, I need to update a DATE field (called last_req_date) from the program.
    Until now, i only worked on internal tables and update the fields in internal table.  But this time I need to update my zTable and i've not updated any records of the database tables directly from the program.
    Please kindly provide the complete syntax and procedure on how to update z database table.
    Your help will be appreciated and points will be awarded for the same.
    Thanks in Advance.
    Best Regards!
    Krishna.

    Hi,
    To update or Insert fields into teh dbase table.
    INSERT INTO dbtab [CLIENT SPECIFIED] VALUES wa.
    INSERT INTO (dbtabname) [CLIENT SPECIFIED] VALUES wa.
    2. INSERT dbtab [CLIENT SPECIFIED] FROM TABLE itab. oder
    INSERT (dbtabname) [CLIENT SPECIFIED] FROM TABLE itab.
    3. INSERT dbtab [CLIENT SPECIFIED]. oder
    INSERT *dbtab [CLIENT SPECIFIED]. oder
    INSERT (dbtabname) [CLIENT SPECIFIED] ...
    1.TABLES SCUSTOM.
    SCUSTOM-ID        = '12400177'.
    SCUSTOM-NAME      = 'Robinson'.
    SCUSTOM-POSTCODE  = '69542'.
    SCUSTOM-CITY      = 'Heidelberg'.
    SCUSTOM-CUSTTYPE  = 'P'.
    SCUSTOM-DISCOUNT  = '003'.
    SCUSTOM-TELEPHONE = '01234/56789'.
    INSERT INTO SCUSTOM VALUES SCUSTOM.
    2.TABLES SAIRPORT.
    SAIRPORT-ID   = 'NEW'.
    SAIRPORT-NAME = 'NEWPORT APT'.
    INSERT SAIRPORT.
    To UPDATE
    TABLES SFLIGHT.
    UPDATE SFLIGHT SET   SEATSOCC = SEATSOCC + 3
                   WHERE CARRID   = 'LH'   AND
                         CONNID   = '0400' AND
                         FLDATE   = '19950228'.
    TABLES SFLIGHT.
    UPDATE SFLIGHT CLIENT SPECIFIED
                   SET   SEATSOCC = SEATSOCC + 3
                   WHERE MANDT    = '002'  AND
                   WHERE CARRID   = 'LH'   AND
                         CONNID   = '0400' AND
                         FLDATE   = '19950228'.
    TABLES SCUSTOM.
    SCUSTOM-ID       = '00017777'.
    SCUSTOM-DISCOUNT = '003'.
    UPDATE SCUSTOM.
    OR UPDATE dbtab FROM TABLE itab.

  • How to assign value to specifically 2D table cell in DIAdem?

    Assume the 2D table dimension is 4*5, and I want to write value to (2,3) of the table cell and don't change the values in other cells. How should I do?
    Another question:
    How to hide the heading of a 2D table?
    Thanks for any reply!
    YangAfreet

    Hi YangAfreet,
    All tables in DIAdem VIEW and REPORT display the values in specific Channels in the Data Portal (or in rare cases the values of a global array variable).  So if you want to change the value of a particular cell in your table, you need to change the value of that particular cell in the data channel being displayed in that table column.  This you can do with the ChV() function in a VBScript, or you can change that value interactively in a VIEW table.
    Of course, if you're talking about a table in a SUDialog, then there is a way to address and edit individual table cells, but my guess is that this is not the sort of table you're talking about.
    Brad Turpin
    DIAdem Product Support Engineer
    National Instruments

Maybe you are looking for

  • There was a problem reading this document (118) after sleep

    Adobe reader X 10.1.8.24, windows 7 64 bit I have a lot of pdf documents located on a remote windows share and everytime I put my computer to sleep and wake it up I get problems reading pdf documents that result in this error:      There was a proble

  • Can't print from XP Machine to an OSX Shared Printer

    Hi All, I already configured my Epson RX 620 in OSX, it's printing perfectly. I turned on the printer Sharing and the Windows Sharing in OS X. Then I found my iMac in my XP explorer, connected to the shared printer, set the drivers in XP and print th

  • Error Handling and Error Messages

    I already posted this in the java programming forum, but I dont think the people responded understand patterns, or what I was asking. Here is my original post, for reference I am not asking how to catch and exception, or how to display an error, I am

  • How to read http  header from Forms

    Hi, I have a forms application deployed on 10g AS. We are planning to integrate Oracle Identity management with our forms application. Currently, I access my forms application with an url, say http://hostname/forms/frmservlet?config=test. And, I get

  • MDX Calculated Member With Multiple Conditions

    I need to create a calculated member in my cube that spans multiple dimensions. A current calculated member looks like this: [Employee Hours Category].[Utilization Category].[NON-PTO], [Measures].[Employee Hours] This calculated member returns all th