How to add the listener to use mouse to one single line

I have a requirement. In a JTable when I double click on a particular line the cells in the row put the width which I have provided.

The problem with my code is when I click on the fourth row of the table, the first line adjusts.

How I need help is so

that if I click on the first row, the first cell size line should be adjusted not when I click on the fourth line.

If I give a few cells of the width and the height of the cells in the fourth row, then when I double click on the fourth line, the fourth should only get adjusted and not the other lines.

Hope I explained it clearly.

How is it possible?


Below is my code. Everything is hardcoded. Thus, it may seem messy. Please excuse.

Imports
import impossible;
import java.awt.Color;
java.awt.Component import;
to import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

to import javax.swing.JFrame;
to import javax.swing.JPanel;
javax.swing.JScrollPane import;
javax.swing.JTable import;
Import javax.swing.JTextArea;
Import javax.swing.table.DefaultTableModel;
javax.swing.table.TableCellRenderer import;
Import javax.swing.table.TableColumn;

class SimpleTableExample extends JFrame {}
Instance attributes used in this example
private JPanel Top;
JTable table private;
private get scrollPane;
String data1 = "";
String data2 = "123456789ABCDEFGHIJKLMNOPQRSTUVQWXYZabcdefghijklmnopqrstuvwxyzaquickbrownfoxjumpedoverthelazydog";
int size = data2.length ();

Main chassis constructor
public SimpleTableExample() {}
Define the characteristics of frame
setTitle ("Simple Application of Table");
setSize (400, 200);
setBackground (Color.gray);

Create a Panel to contain all other components
Top = new JPanel();
topPanel.setLayout (new BorderLayout());
getContentPane () .add (topPanel);

Create column names
ColumnNames String() is {'SALT', "DESIGN DATA", "REFERENCE"};.

Create data

String [] [] dataValues = {{data1, data2, "67", "77"},
{"", "43", "853"}, {"", "89.2", "109"},
{{' ', "9033", "3092"}} ;
Model DefaultTableModel = new DefaultTableModel (dataValues, columnNames);
model.addColumn ("SECTION TITLE");
model.addColumn ("SPECIAL INSTRUCTIONS").
table = new JTable (model) {}
' public boolean isCellEditable (int rowIndex, int colIndex) {}
Returns false;
}
};
adjust the height of specific line
table.setAutoResizeMode (JTable.AUTO_RESIZE_OFF);
colInd int = 0;
TableColumn col = table.getColumnModel () .getColumn (colInd);
int width = 50;
col.setPreferredWidth (width);
int colInd2 = 1;
TableColumn col2 = table.getColumnModel () .getColumn (colInd2);
int width2 = 100;
col2.setPreferredWidth (WIDTH2);
int colInd3 = 2;
TableColumn col3 = table.getColumnModel () .getColumn (colInd3);
int width3 = 10;
Col3.setPreferredWidth (width3);
int colInd4 = 3;
TableColumn col4 = table.getColumnModel () .getColumn (colInd4);
width4 int = 10;
Col4.setPreferredWidth (width4);
int colInd5 = 4;
TableColumn col5 = table.getColumnModel () .getColumn (colInd5);
width5 int = 10;
col5.setPreferredWidth (width5);

table.addMouseListener (new MouseAdapter() {}
{} public void mouseClicked (MouseEvent e)
If (e.getClickCount () == 2) {}
JTable target = e.getSource () (JTable);
int row = target.getSelectedRow ();
int target.getSelectedColumn () = column;

TableColumn col1 = table.getColumnModel () .getColumn (0);
col1.setPreferredWidth (50);
TableColumn col2 = table.getColumnModel () .getColumn (1);
col2.setPreferredWidth (400);
(.setCellRenderer) table.getColumnModel () .getColumn (1)
(new TableCellLongTextRenderer());
table.setRowHeight (50);
TableColumn col5 = table.getColumnModel (.getColumn) (4);
col5.setPreferredWidth (200);
}
}
});

Create a new instance of table

table = new JTable (dataValues, columnNames);

Add the table to a scroll pane
scrollPane = new get (table);
topPanel.add (scrollPane, BorderLayout.CENTER);
}

Main entry point for this example
Public Shared Sub main (String [] args) {}
Create an instance of the test application
MainFrame SimpleTableExample = new SimpleTableExample();
mainFrame.setVisible (true);
}
}

class TableCellLongTextRenderer extends JTextArea implements {TableCellRenderer

public getTableCellRendererComponent (JTable, Object value, table Component
Boolean isSelected, boolean hasFocus, int line, int column) {}
this.setText ((String) value);
this.setWrapStyleWord (true);
this.setLineWrap (true);
the width of the column in the table to the JTextArea
setSize (table.getColumnModel () .getColumn (column) .getWidth (),
getPreferredSize () .height);
If (table.getRowHeight (row)! = getPreferredSize () .height) {}
set the height of the row in the table to the calculated height of the
JTextArea
table.setRowHeight (rank, getPreferredSize () .height);
}
Back to this;
}

}

Published by: 915175 on August 3, 2012 04:24

Hello

Try code below. Hope this will help

import impossible;
import java.awt.Color;
java.awt.Component import;
to import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

to import javax.swing.JFrame;
to import javax.swing.JPanel;
javax.swing.JScrollPane import;
javax.swing.JTable import;
Import javax.swing.JTextArea;
Import javax.swing.table.DefaultTableModel;
javax.swing.table.TableCellRenderer import;
Import javax.swing.table.TableColumn;

SerializableAttribute public class SimpleTableExample extends JFrame {}

private JPanel Top;
JTable table private;
private get scrollPane;
String data1 = "";
String data2 = "123456789ABCDEFGHIJKLMNOPQRSTUVQWXYZabcdefghijklmnopqrstuvwxyzaquickbrownfoxjumpedoverthelazydog";
int size = data2.length ();

Main chassis constructor
public SimpleTableExample() {}
Define the characteristics of frame
setTitle ("Simple Application of Table");
setSize (400, 200);
setBackground (Color.gray);

Create a Panel to contain all other components
Top = new JPanel();
topPanel.setLayout (new BorderLayout());
getContentPane () .add (topPanel);

Create column names
ColumnNames String() is {'SALT', "DESIGN DATA", "REFERENCE"};.

Create data

String [] [] dataValues = {{data1, data2, "67", "77"},
{"", "43", "853"}, {"", "89.2", "109"},
{{' ', "9033", "3092"}} ;
Model DefaultTableModel = new DefaultTableModel (dataValues, columnNames);
model.addColumn ("SECTION TITLE");
model.addColumn ("SPECIAL INSTRUCTIONS").
table = new JTable (model) {}
' public boolean isCellEditable (int rowIndex, int colIndex) {}
Returns false;
}
};
adjust the height of specific line
table.setAutoResizeMode (JTable.AUTO_RESIZE_OFF);
colInd int = 0;
TableColumn col = table.getColumnModel () .getColumn (colInd);
int width = 50;
col.setPreferredWidth (width);
int colInd2 = 1;
TableColumn col2 = table.getColumnModel () .getColumn (colInd2);
int width2 = 100;
col2.setPreferredWidth (WIDTH2);
int colInd3 = 2;
TableColumn col3 = table.getColumnModel () .getColumn (colInd3);
int width3 = 10;
Col3.setPreferredWidth (width3);
int colInd4 = 3;
TableColumn col4 = table.getColumnModel () .getColumn (colInd4);
width4 int = 10;
Col4.setPreferredWidth (width4);
int colInd5 = 4;
TableColumn col5 = table.getColumnModel () .getColumn (colInd5);
width5 int = 10;
col5.setPreferredWidth (width5);

Rendering of the cell must be applied on each column - add by Mohamed
for (int i = 0; i)< table.getcolumnmodel().getcolumncount();="">
table.getColumnModel () .getColumn (i) .setCellRenderer (new TableCellLongTextRenderer());
}

table.addMouseListener (new MouseAdapter() {}
{} public void mouseClicked (MouseEvent e)
If (e.getClickCount () == 2) {}
JTable target = e.getSource () (JTable);
int row = target.getSelectedRow ();
int target.getSelectedColumn () = column;
setTableCellHeight (table, row, column); Added by Mohamed
TableColumn col1 = table.getColumnModel () .getColumn (0);
col1.setPreferredWidth (50);
TableColumn col2 = table.getColumnModel () .getColumn (1);
col2.setPreferredWidth (400);
TableColumn col5 = table.getColumnModel (.getColumn) (4);
col5.setPreferredWidth (200);
}
}
});

Create a new instance of table

table = new JTable (dataValues, columnNames);

Add the table to a scroll pane
scrollPane = new get (table);
topPanel.add (scrollPane, BorderLayout.CENTER);
}

/**
* Created by Mohamed
*
* This will set the cell height and width of column
*
@param table
@param line
@param column
*/
' Public Sub setTableCellHeight (table JTable, int line, int column) {}

the width of the column in the table to the JTextArea
setSize (table.getColumnModel () .getColumn (column) .getWidth (),
getPreferredSize () .height);
If (table.getRowHeight (row)! = getPreferredSize () .height) {}
set the height of the row in the table to the calculated height of the
JTextArea
table.setRowHeight (rank, getPreferredSize () .height);
}
}

Main entry point for this example
Public Shared Sub main (String [] args) {}
Create an instance of the test application
MainFrame SimpleTableExample = new SimpleTableExample();
mainFrame.setVisible (true);
}

}

class TableCellLongTextRenderer extends JTextArea implements {TableCellRenderer

public getTableCellRendererComponent (JTable, Object value, table Component
Boolean isSelected, boolean hasFocus, int line, int column) {}
this.setText ((String) value);
this.setWrapStyleWord (true);
this.setLineWrap (true);
Back to this;
}

}

Tags: Java

Similar Questions

  • How to add the listener password password file?

    Oracle 10g. I put a password for current listener. Is there such a thing that I would add a password for the listener to the password file? Please notify.

    Thank you

    S.

    ski123 wrote:
    Oracle 10g. I put a password for current listener. Is there such a thing that I would add a password for the listener to the password file? Please notify.

    Thank you

    S.

    Documentation on setting up a listening port password is clear enough and does not address file a/the password. You define the listener password by issuing the appropriate lsnrctl command. The password is encrypted and stored in the listener.ora file. That's all.

    And at least from 10 g, if your OS account is member of the dba group, the Auditor considers you authenticated OS (just like "/ as sysdba" to sqlplus) and will not require a password. The password protects against accounts that are NOT members of the dba group.

  • How to add the listener showPopup trigger for a commandlink type context menu

    Hi all

    I use jdev 11.1.1.7

    I have a commandlink with actionlistener, which will display a popup and his works fine

    But when the right click on the link same context menu should be display

    That's why I added a trigger type contextmenu for this commandlink showPopupListener but its does not work

    I even added oracle.adf.view.rich.ACTION_LINK_BROWSER_CONTEXT_SUPPRESSION to no. as suggested in https://docs.oracle.com/cd/E24382_01/web.1112/e16181/af_navigate.htm#ADFUI11777 still does not


    <af:commandLink id="dc_cl2" text="#{page.concatMemberNameDisplayed}" actionListener="#{pageFlowScope.MyBean.openMS}"
                                              inlineStyle="font-size:smaller;" rendered="#{page.axisType==3}">
                                <f:attribute name="selectedPageMem" value="#{page}"/>
                                <af:showPopupBehavior popupId="contextMenu" triggerType="contextMenu" align="afterEnd"/>
                                <af:popup id="contextMenu" launcherVar="var" eventContext="launcher">
                                  <af:menu text="ContextMenu" id="m1">
                                    <af:forEach items="#{pageFlowScope.MyBean.mapKeys}" var="it">
                                      <af:forEach items="#{pageFlowScope.MyBean.menuItems[it]}" var="menuItem">
                                        <af:commandMenuItem text="#{menuItem.label}" id="cmi1" actionListener="#{pageFlowScope.MyBean.contextMenuClicked}" action="onContextMenu"
                                                            rendered="#{it eq 'Global'}">
                                          <f:attribute name="selectedMenu" value="#{menuItem}"/>
                                          <f:attribute name="selectedPageMem" value="#{page}"/>
                                        </af:commandMenuItem>
                                      </af:forEach>
                                    </af:forEach>
                                  </af:menu>
                                </af:popup>
                              </af:commandLink>
    

    Please let me know how to achieve this. Thanks, Asha

    If the component on the page sometimes is visible and sometimes will not depending on the condition or user action, you must use the visible property. Whether or not the component is visible only once (for example according to the privilege of the user or user type), you must use return ownership.

  • How to add the fragment in jsf using page add tag to jdeveloper

    Hi all
    Can you tell me wat is use the syntax: tag .or how to add the fragment in the jsf page...

    Published by: 947228 on July 18, 2012 05:01

    Hello

    Why do you do this?

    Check [url https://blogs.oracle.com/jheadstart/entry/avoid_use_of_jspinclude_where] this out before continuing.

    BTW, always mention your version JDev, varnish usecase for assistance.

    Arun-

  • How to add the symbol for the brand to use?

    I saw how to add copyright and brand symbols, but anyone know how to add the symbol of the brand to use (SM)?

    Thank you.

    Mac OS > FInder > edit > special characters > type of service in the lower-right search

    Problem is many fonts do not have this, then you might want to set an exhibitor SM.

  • How to add the warning message when you use the function 'print' in Adobe LiveCycle Designer

    I'm trying to make the pdf document for my business that requires the addition of a warning message while everyone to use the function 'print' page...

    Does anyone know how to add the warning message about LiveCycle Designer

    Also my supervisor mentioned something using "nag" If that sounds at all

    Not in the XML code, in the case of script of pre-publication of the "print" key. If you don't have the script editor to the top on your version of designer, you can press ctrl + shift + F5 to bring it.

  • How to add the name of the title of graph in Excel

    Dear friends

    I'm using LabVIEW 8.0.I need how to add the name of the title of graph in Excel.

    You have the report generation tool? If so, the VI of graph Easy Excel has an entry for this.

    If you don't have the Toolbox, then you need to use ActiveX. Please do a search on the use of the ActiveX (there are examples provided with LabVIEW) to control Excel. Also, there are many examples in the thread Excel. NOTE: DON'T POST QUESTIONS IN THIS THREAD.

    In the end, you will need to search for information contained in MSDN.

  • How to add the listenter in a folder

    Hello friends,

    Please help me out by telling how can I add a file listener in any folder in flex.

    whenever a file is added to this file, I can get any event, which tells me that on the file,

    Exactly, I want to add the listener to record image in playbook to get information if it adds a new file.

    Thank you

    The suggestion of John (I think that is correct: no way integrated for this), the as3corelib library has a FileMonitor already, class that does what it describes.  You can extend to do something similar with a polling call to getDirectoryListing (or, preferably, the asynchronous version of that) to keep track of the directory.

  • How to add the Quazip library

    Hi, I want to try to use Quazip. Since I read, I have to add the library before use.

    I downloaded from http://quazip.sourceforge.net/

    How to add the Quazip library? Please explain the step, never add lib before.

    Thank you

    I have change the .pro file

    Like this:

    http://StackOverflow.com/questions/13341234/unzip-files-downloaded-from-Server

  • How to create the user account using the command?

    How to create the user account using the command?

    Open cmd as administrator, and then type the following commands one after the other

    NET user / add program mypassword
    net localgroup administrators program / add
    net share concfg * C:------/ grant: program, complete
    This will create a user account with the name "Program" and the password "MonMotpasse".

    You can create the user name and password of your choice.
  • How to add the collapsible functionality to the Spry Menu?

    Dear Adobe community,

    How to add the functionality of collapsible for the Spry Menu like the one on the White House | whitehouse.gov ?

    Load the White House Web site and minimize your browser window as observe you what happends to the menu bar when you pass a certain limit.

    This is the feature that I want to put in place and I would be happy if one of you could direct me to or share relevant information.

    Concerning

    Andreas

    This isn't a menu Spry Spry do not appear on mobile devices.

    Use any sensitive menu you like for example:

    CSS & jQuery Mobile Navigation Menu Demo

    The tutorial is here:

    CSS and jQuery Menu of Navigation Mobile reactive

  • How to add the form designed in adobe acrobat pro live cycle Designer?

    How to add the form designed in adobe acrobat pro live cycle Designer?

    I want to add the form designed in adobe acrobat pro live cycle Designer. I saved the form designed in adobe live cycle designer in pdf format. But you can't change the same in Adobe Acrobat format. I would like to add a few fields and use the fields designed by Adobe Live cycle Designer.

    You can only modify this form in LiveCycle Designer. Forms Acrobat and LCD are not interchangeable.

  • How to add the blank page to existing Document in Adobe Dc

    How to add the blank page to existing Document in Adobe Dc Pro

    Hi thashrifs16749461,

    You can add a blank page using Adobe Acrobat DC by following the instructions below:-

    (1) open your PDF in Acrobat DC.

    (2) choose the form of option "Organize the Page" of the tool pane on the right as shown below in the screen shoot.

    (3) now, at the top, you will see all the tools to organize the page, click "Insert" & select 'White Page' in the drop down menu to insert blank pages.

    * Shortcut: If you are using a windows computer you can use the key "Shift + Ctrl + T" to insert blank pages.

    In case if you have any problem or have any questions please let us know. We will be happy to help you.

    Kind regards

    Nicos

  • How to add the asterisk (*) next to the label of the element

    Hello

    Can someone suggest me how to add the asterisk (*) or (∞) symbol next to the label of the element in the apex oracle 4.2.2.

    Ex: -.

    1 County IN

    2 County * IN

    Thank you and best regards,

    Ibrahim Sayyed.

    Hello

    Do tag is obsolete and not supported in HTML5

    http://www.w3schools.com/tags/tag_font.asp

    Use for example duration and styles

    *
    

    Kind regards

    Jari

  • How to submit the report BEEP using the CONCSUB utility

    Hi all

    I presented the report BEEP using the Concsub utility. But I got the xml instead of PDF output.

    I found that the page layout is not attached with this concurrent program.

    Please guide me how to add the layout with this simultaneous program when sending through CONCSUB.

    Kind regards
    Karim

    Published by: karim on November 5, 2012 13:32

    Ok

    I tried and I can't say how it works, but there work ;)

    step by step for r12
    -create a XXAND17 cp
    -create data XXAND17 definition
    -create the XXAND17 model

    [oracle@oebs out]$ CONCSUB APPS/APPS FND 'Application Developer' SYSADMIN WAIT=N CONCURRENT FND XXAND17
    Submitted request 9915625 for CONCURRENT FND XXAND17
    
    cd $APPLCSF/$APPLOUT
    

    and see the o9915625.out to open it and it's xml data. then ok

    [oracle@oebs out]$ CONCSUB apps/apps FND 'Application Developer' SYSADMIN WAIT=N CONCURRENT XDO XDOREPPB Y 9915625 0 XXAND17 en N RTF RTF
    Submitted request 9915626 for CONCURRENT XDO XDOREPPB Y 9915625 0 XXAND17 en N RTF RTF
    

    See o9915626.out open it and it isn't xml
    It looks like word doc

    {\rtf1\ansi\deff0
    {\fonttbl
    {\f0 Arial;}
    {\f1 Times;}
    {\f2 Courier New;}
    {\f3 Calibri;}
    }
    ...
    

    copy on the local computer and rename it to o9915626.rtf
    opened by the word and she is out as well report

    so conclusion:
    XDOREPPB works fine but not rename output way output format (rtf in my case)

    If this is a bug or a profile must be defined

    -Add

    SQL> select LOGFILE_NAME, OUTFILE_NAME from fnd_concurrent_requests r
      2  where request_id in (9915625, 9915626)
      3  /
    
    LOGFILE_NAME                                                                     OUTFILE_NAME
    -------------------------------------------------------------------------------- --------------------------------------------------------------------------------
    /oracle/VIS/inst/apps/VIS_oebs/logs/appl/conc/log/l9915625.req                   /oracle/VIS/inst/apps/VIS_oebs/logs/appl/conc/out/o9915625.out
    /oracle/VIS/inst/apps/VIS_oebs/logs/appl/conc/log/l9915626.req                   /oracle/VIS/inst/apps/VIS_oebs/logs/appl/conc/out/o9915626.out
    
    SQL> select * from fnd_conc_req_outputs where concurrent_request_id  in (9915625, 9915626)
      2  /
    
    CONCURRENT_REQUEST_ID  OUTPUT_ID FILE_TYPE                      FILE_NAME                                                                        FILE_NODE_NAME                                                                    FILE_SIZE ACTION_TYPE FILE_CREATION_DATE
    --------------------- ---------- ------------------------------ -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- ---------- ----------- ------------------
    
    SQL> 
    

    =/

    Published by: Alexandr on 8 November 2012 06:28

Maybe you are looking for

  • Satellite P500 - loop of reboot after using the Toshiba Recovery disk

    Hello I have a problem recovery SATELLITE P500. I did the recovery disks. It starts ok on the recovery disk and format the hard drive and copy the disks to the hard drive. Then, he begins installing windows and restarts. He then goes to a loop(1) mar

  • Satellite A350-20J and Touchpad

    Hello! Is it possible to set the sensitivity of the touchpad on my laptop?I have a Satellite A350-20J (according to the label at the bottom of the laptop), a PSAL6E-04800GRU (from Toshiba utility to diagnoses). I bought this laptop in Moscow.It is al

  • Internet Explore 11 - drag a link to the new tab button no longer works

    http://superuser.com/questions/680591/Internet-Explorer-11-dragging-a-link-to-the-new-tab-button-no-... This is essentially my problem, can someone help me on this? I have a lenovo y510p just in case you guys ask.

  • R61 CD/DVD RAM

    I have a laptop here with a CARPET R61 * beep * UJ-860 DVD player has as well as the driver has stopped working. I can't find the driver anywhere. can anyone provide a driver for this? Thank you.

  • Protection of password after entering sleep mode does not

    I recently added another user to my windows laptop 8 and after mode password protection 'sleep', he stopped. I went in the power options, and this option is grayed out. All solutions?