Change row height of a table by dragging

Hi,
One of my swing projects has a requirement that the user should be able to resize the height of individual rows of a table by dragging the row separator with the mouse.
JTable by default allows us to drag the column separators and change the column width. But the row heights are not adjustable in a similar way.
Is it possible to do so? I guess I will have to write a listener for the rows, don't know how to go about it though.
Any help in this regard would be highly appreciated.
Thanks.

Hi,
Well here is the table you're talkking about. I tried adding the cellrender and listen to the drag event. Could not proceed much though. I am still trying. In the mean time if any of you can progress on this then please let me know.
I've attached my full code listing here.
Thanks.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import java.awt.Cursor;
public class LineNumberTable extends JTable
     private JTable mainTable;
     public LineNumberTable(JTable table){
          super();
          mainTable = table;
          setAutoCreateColumnsFromModel(false);
          setModel(mainTable.getModel());
          setSelectionModel(mainTable.getSelectionModel());
          setAutoscrolls( false );
          addColumn(new TableColumn());
          getColumnModel().getColumn(0).setCellRenderer( mainTable.getTableHeader().getDefaultRenderer());
          //Attaching my cell renderer
          getColumnModel().getColumn(0).setCellRenderer(new myCellRenderer());
          getColumnModel().getColumn(0).setPreferredWidth(10);
          setPreferredScrollableViewportSize(getPreferredSize());
     public boolean isCellEditable(int row, int column) {
          return false;
     public Object getValueAt(int row, int column) {
          return new Integer(row + 1);
     public int getRowHeight(int row) {
          return mainTable.getRowHeight();
     public static void main(String[] args) throws Exception {
          DefaultTableModel model = new DefaultTableModel(100, 5);
          JTable table = new JTable(model);
          JScrollPane scrollPane = new JScrollPane( table );
          JTable lineTable = new LineNumberTable( table );
          scrollPane.setRowHeaderView( lineTable );
          JFrame frame = new JFrame( "Line Number Table" );
          frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
          frame.getContentPane().add(scrollPane, BorderLayout.CENTER);
          frame.setSize(400, 300);
          frame.setVisible(true);
     class myCellRenderer extends DefaultTableCellRenderer implements MouseListener, MouseMotionListener {
          private Point start;
          private Point end;
          public void mouseClicked(MouseEvent e) {
          public void mouseDragged(MouseEvent e) {
          public void mouseEntered(MouseEvent e) {
               setCursor(new Cursor(java.awt.Frame.N_RESIZE_CURSOR));
          public void mouseExited(MouseEvent e) {
               setCursor(new Cursor(java.awt.Frame.N_RESIZE_CURSOR));
          public void mouseMoved(MouseEvent e) {
          public void mousePressed(MouseEvent e) {
               start = e.getPoint();
           public void mouseReleased(MouseEvent e) {
                end = e.getPoint();
                int inc = end.y - start.y;
                LineNumberTable.this.setRowHeight(inc + LineNumberTable.this.getRowHeight());
}

Similar Messages

  • How to increase the row height of the table in the smartform

    Hi,
    Can any one say,
    How to increase the row height of the table in the smartform.
    It is presently show the row width very small, i want to increase the row with of the table in the smartform.
    Plase say how can we increase the row height in the smartform.

    Hi Ravi,
         In Smartforms , Select the Table and you can adjust the cell hieghts in OUTPUT OPTIONs TAB.
        Reward points if that Helps.
    Manish

  • Different row heights in one table - is this possible?

    I want the height of each row in a table to be set to fit the contents of that particular row.
    The column which drives the cell height uses the cell formatting options "Wrap Text" and "Row by Row Auto Fit". These options will set the row height of all rows to that which fits the tallest cell. What I prefer is to have one row height be 4, if that's all it needs, while the next row may have a height of 32 because of a long line of wrapped text.
    Can this be done with DeskI XI 3.1?

    In BO XIR3.1 the row height does not appear to be based on individual rows. Instead the row height is the same for each row in the table. Is there some setting that I need to adjust here?

  • Changing row height

    Hi,
    In an AdvancedDataGrid, is it possibe for the user to increase or decrease the row height by dragging/pulling the separations/dividers between the rows with mouse? This is similar to what we can do in an Excel sheet.
    If it is possible, can anyone let me know how this can be done.
    Thanks

    [url http://java.sun.com/docs/books/tutorial/uiswing/events/componentlistener.html]How to Write a Component Listener
    Add the listener to the frame and then reset the row height when the frame is resized.

  • Excel 2013 randomly changes row height to 409.5 pixels

    So as I said, i open a file, and some of the rows are of the maximum possible height. For no reason. If a colleague of mine opens the same document on his/her laptop, there is no issue. This also makes scrolling almost impossible, since for some reason
    a window is not enough to cover 409.5 pixels. Is there any kind soul who could help me out?

    I haven't meet this issue, but did see similar issue many times in different forums.
    Maybe you can try the menthods mentioned in the thread below:
    http://social.technet.microsoft.com/Forums/office/en-US/47740b73-9e06-442b-94af-5fbac0956add/excel-row-height-changes-when-it-should-not-change?forum=excel

  • Change row height in new iTunes

    I need to shorten row height in new iTunes.....seems to waste a lot of space.
    Thanks

    No options for that, unless you currently have Use large text for list views selected under Edit > Preferences > General.
    tt2

  • Change rows property of ADF Table

    I am trying to set the rows property of an af:table object based on the value of a drop down box (af:selectOneChoice)
    http://img.photobucket.com/albums/v294/jammiedodgers/BrianS/Accounts-1.jpg
    I have tried this a number of ways but can't get the table to pick up the change unless I do a browser page refresh. I have the autoSubmit property of the drop down box set to true. It is bound to the rows property of my backing bean (which is also bound to the table rows property)
    af:table var="row"
    value="#{accountBacking.model}"
    rows="#{accountBacking.rows}"
    first="#{accountBacking.first}"
    banding="row"
    styleClass="table.sample"
    binding="#{accountBacking.table}"
    >
    <f:facet name="actions">
    <af:selectOneChoice id="rowChoice"
    label="Rows Per Page: "
    autoSubmit="true"
    value="#{accountBacking.rows}"
    valueChangeListener="#{accountBacking.rowChange}">
    <f:selectItem itemLabel="5" itemValue="5"/>
    <f:selectItem itemLabel="10" itemValue="10"/>
    <f:selectItem itemLabel="20" itemValue="20"/>
    <f:selectItem itemLabel="50" itemValue="50"/>
    </af:selectOneChoice>
    </f:facet
    Here is the code from by backing bean. (accountBacking)
    package com.stlouiscity.budget.jsf.beans;
    import com.stlouiscity.budget.database.beans.AccountBean;
    import com.stlouiscity.budget.database.dao.AccountDAO;
    import com.stlouiscity.budget.database.dao.DAOFactory;
    import com.stlouiscity.budget.jsf.delegates.AccountService;
    import java.util.List;
    import javax.faces.application.Application;
    import javax.faces.application.ViewHandler;
    import javax.faces.context.FacesContext;
    import javax.faces.event.ValueChangeEvent;
    import javax.faces.model.DataModel;
    import javax.faces.model.ListDataModel;
    import oracle.adf.view.faces.context.AdfFacesContext;
    import oracle.adf.view.faces.model.SortableModel;
    import oracle.adf.view.faces.component.core.data.CoreTable;
    import oracle.adf.view.faces.event.ReturnEvent;
    public class AccountBacking implements java.io.Serializable{
    private AccountService acctService;
    private AccountBean account;
    private CoreTable table;
    private SortableModel model;
    private Integer first;
    private Integer rows;
    /** Creates a new instance of AccountBacking */
    public AccountBacking() { 
    acctService = new AccountService();
    AdfFacesContext afCtx = AdfFacesContext.getCurrentInstance();
    setFirst((Integer)afCtx.getProcessScope().get("first"));
    setRows((Integer)afCtx.getProcessScope().get("rows"));
    //afCtx.getProcessScope().clear();
    public CoreTable getTable() {
    return table;
    public void setTable(CoreTable table) {
    this.table = table;
    public SortableModel getModel() {
    if (model == null)
    refreshAction();
    return model;
    public void setModel(SortableModel model) {
    this.model = model;
    public AccountBean getAccount() {
    return this.account;
    public void setAccount(AccountBean account) {
    this.account = account;
    public void setRowData() {
    try {
    this.account = (AccountBean) this.table.getRowData();
    } catch (NullPointerException npe) {
    this.account = new AccountBean();
    public String editAccountAction() {
    setRowData();
    AdfFacesContext afCtx = AdfFacesContext.getCurrentInstance();
    if (getAccount() == null) {
    setAccount(new AccountBean());
    afCtx.getProcessScope().put("account",getAccount());
    afCtx.getProcessScope().put("first",this.table.getFirst());
    afCtx.getProcessScope().put("rows",this.table.getRows());
    return "EditAccount";
    public String deleteAccount() {
    setRowData();
    acctService.deleteAccount(this.getAccount());
    refreshAction();
    return null;
    public String refreshAction() {
    List list = acctService.getAccounts();
    ListDataModel listModel = new ListDataModel(list);
    model = new SortableModel(listModel);
    table.setValue(getModel());
    table.setRows(getRows());
    table.setFirst(getFirst());
    return null;
    public void rowChange(ValueChangeEvent event) {
    refreshAction();
    public Integer getFirst() {
    return first;
    public void setFirst(Integer first) {
    if (first != null) {
    this.first = first;
    } else {
    this.first = 0;
    AdfFacesContext afCtx = AdfFacesContext.getCurrentInstance();
    afCtx.getProcessScope().put("first",this.first);
    public Integer getRows() {
    return rows;
    public void setRows(Integer rows) {
    if (rows != null) {
    this.rows = rows;
    } else {
    this.rows = 10;
    AdfFacesContext afCtx = AdfFacesContext.getCurrentInstance();
    afCtx.getProcessScope().put("rows",this.rows);
    I am attempting to pass the rows and first property of the table into the process scope and then look them back up during the constructor. The backing bean is request scoped. I do no want to use a session scoped bean because I don't want to have to deal with thread safety.

    One thing...I use a technique mentioned in other threads to refresh the page that changes the view root to the page it is currently at. I call this after I return from a dialog: page to enact any change that the dialog page did that the current page should see. One problem here: the af:table does not seem to refresh (sometimes?), even when I put this partial target assignment in the return action listener of the button that enacted the dialog:...but I found a solution! In the life cycle I look for that view root to come up, tap into the backing bean of the current page to get the table UIComponent, and do this partial target assignment. Here is the lifecycle prepareModel code...
    String lCurrentView = fctx.getViewRoot().getViewId();
    if (PartialPageUtils.isPartialRequest(fctx)) {
    // Create an elsif for each form which has a popup you want to refresh from.
    if (lCurrentView.equals("/WPForm.jspx")) {
    CoreTable AccessoriesTable = (CoreTable)EL.get("#{WPForm.accessoriesTable}");
    AdfFacesContext.getCurrentInstance().addPartialTarget(AccessoriesTable);
    AdfFacesContext.getCurrentInstance().partialUpdateNotify(AccessoriesTable);
    super.prepareModel(ctx);
    Note: EL is a helper class that Steve M. (I think) wrote, which gets and sets ValueBindings. A similar functionality can be found in his ADFUtils and JSFUtils classes in the SRDemo app for ADFBC, downloadable from TechNet.oracle.com ...or the JDev help menu updates section.

  • Changing row content in displayed table & saving it in database table back

    hi!
      I am just Learning BSP applications.....i got struck with a problem....
       i am using cl_htmlb_tableview class for selecting a row...and that line is made editable....
    i want to change the data of that line and then modify the entry in the database table....
    i am using a button to be clicked and in that i am reading the line according to the 'tv_data->rowselection'
    and modifying the database table with that work area...but my data is not changing....
       Can u help me out how to get this....and what is that is being missed ......and how to proceed with it so that it is done....

    Hi,
    Foolow the below code.
    In the Do_Handle_event,
    case event.
    when 'id of the button'.
          submit( ).
    endcase.
    In the Submit method,
    data:  loc_table_event type ref to cl_htmlb_event_tableview.
    call method cl_hrrcf_iterator=>get_tv_attr
        exporting
          p_tv_id               = 'Tble view id'
          p_component_id        = me->component_id
          po_request            = me->request
        importing
          po_tv_event           = loc_table_event.
    local varibale = loc_table_event->get_cell_value(
                                             row_index     = indv
                                             column_index  = feild number ).
    <now update ur database with local variable value>
    Hope this will be helpful.
    Regards,
    Gokul.N

  • How to: Resize a rows height in a table using acrobat 9 pro?

    I'm working on a government grant, with many tables that need to be resized in order to fit the required information. Can anyone help me?

    PDF isn't a word processor like file format -- so, a "rebuild edit" to a table is a "You Don't".
    As to form fields, Acrobat provides one with the ability to edit Acrobat form fields (if the form / file is not protected).
    But, changing a grant form is likely to result in its being rejected by the originating organization.
    Basically, you want to speak with the organization that you will submit the form to.
    It may well be that you are trying to put 2 tons in the 1 ton pickup (less might be ok & actually expected).
    Or, it may be that, unknown to the organization, the PDF form is hosed.
    If so, communicating with the organization may well be a good thing.
    Be well...

  • Using Slicer to change row dimension in pivot table

    I have a requirement to display a measure amount by Quarter,Month or Week of Year.  The user needs to select one of three slicer buttons, Quarter, Month or Week.  I have tried creating a calculated column in my tables, e.g PeriodToDisplay using
    "If" or "Switch".  
    PeriodToDisplay:=Switch (Dates[PeriodSelected],"Quarterly",FactTableName[Qtr],"Monthly",FactTableName[Month],"Weekly",FactTableName[weeknum])
    Where Dates[PeriodSelected] is just a 3 row table with , Quarterly,Monthly,Weekly rows.  I display those as a slicer in the powerpivot view.
    The FactTableNames are where the aggregation sql have been done.  The row labels now are:
    Qtr
    Month
    Week
    And the granularity i know can be collapsed by the user but they do not want to see a Qtr displayed when they only want to see the month.
     I receive an error message the Quarter is not in the proper context or is a circular reference.

    The behavior you want can be achieved with a hierarchy built in the Power Pivot model, and then using Excel's drill down functionality on the pivot table.
    Alternately, you could define an MDX named set for the pivot table to define the rowfilters.

  • Table Component and Row Height

    I am using XCelsius 4.5 and using the table component.  Is there anyway the row height on the table component can be linked to the Excel file?  It is not dynamically changing or wrapping text based on the amount of data that is imported in.

    Judging from the stack trace this has nothing to do with your variable row height. You are simply not respecting some array bounds (maybe your data array for the table model) when you insert the new row.
    In newRouteFare() do you fire a tableRowsInserted event? Or something similar? Check the rows passed into the Event object to see if you are exceeding the limits of the current table model.
    Thomas

  • How to increase row height in table control?

    Hi experts,
    We have a push button in table control created using screen painter. Since this is a touch screen transaction, the default height is very small for the worker in the plant to click on a specific row, i would like to know if there is any way to increase the row height in the table control. There is no attribute in Screen painter for increasing row height in table control. I did try "import dynpro", hoping to increase the row height and export the dynpro, but that doesn't seem to have row height attributes. Any help in this regard is highly appreciated. Thanks,
    Raj

    Using a new technology means you have to recreate your screen: you may create an HTML using CL_DD_* classes (that's called "Dynamic Documents"). See [SAP Library - DD programming guide|http://help.sap.com/saphelp_nw2004s/helpdata/en/13/12284b019511d4a73e0000e83dd863/frameset.htm]. Demos are provided in SDYNAMICDOCUMENTS package. Or I think you may create web dynpro and define a CSS style to enlarge objects.
    If you don't want to create everything, maybe you can find out a workaround with GuiXT, for example creating a big button in each row (for example, with BUTTONSIZE, but don't know if it changes the height of rows but that's worth trying).
    Well, [Synactive documentation about table controls|http://www.synactive.com/docu_e/specials/tables.html] does not seem to allow that.
    Maybe you can move your question to the "scripting" forum and ask about how to do it with GuiXT...

  • Change row`s height

    Hi,
    How to change Row height in standart report template, if I use jquery.htmldbHscroll-0.0.1.min (which I found on this forum). Simply rows height are bit another than in colums without scrolling.
    Thank you !

    go0ze wrote:
    Hi,
    How to change Row height in standart report template, if I use jquery.htmldbHscroll-0.0.1.min (which I found on this forum). Simply rows height are bit another than in colums without scrolling.
    Thank you !Hi,
    You did found from this forum??
    Regards,
    Jari

  • Increase row height of a configurable table

    Dear SCN members,
    This is related to a configurable table realized using <chtmlb:configTable>. Please let me know about the following possibilities with this:
    1. Is it possible to increase the row height of this table?
    2. The content of a given cell is truncated with three dots and the complete content is visible on the tooltip if the context exceeds the column width. But is it possible to see the complete content of such cells on the table itself with some kind of wrapping rather than just on the tooltip?
    Thanks!

    It is not directly possible, however with iterator and use of text area, it is possible to display longer texts on a table.

  • Row Height Issue

    Oh Hi I have selected Optimize height by row content from Table and font tab and it shows all my text in activity name but when i saved the layout it changes back to keep current rows heights. Can any one tell me how do i fix this
    Thanks in Advanced

    *793199 ,*
    The "Row Height" issue is a common problem. Some things that affect my row height are:
    * Not saving my layout after changing row height
    * Notebook items in the gantt chart affecting the row height and may have to be manually widened to display all of the text or symbols
    Row Height*
    Optimize height by row content:* Indicates you want each row's height determined by its content. If you choose this option, type or select the maximum number of lines that should be included in each row.
    Good luck and let me know how it turns out.

Maybe you are looking for