Set JTable to non editable
Hello,
I have a one column JTable that I would like not to be editable. How do I set the table not be editable? I am not using a table model. Would that be a problem?
I am using the folllwing code:
Vector rows = new Vector(0); //create a vector for the rows
//add a vector within a vector
for(int i = 0; i < 10; i++)
//create a new vector and add the values to the vector
Vector oneRow = new Vector(0);
//fill one row
oneRow.add("Row Input"));
//add the new vector to the outer vector
rows.add(oneRow);
} //add the header to the byte column
Vector cols = new Vector(0);
cols.add("Values");
//create a JTable with one col and rows the size of the byte array
JTable myTable = new JTable(rows, cols);
look at DefaultTableModel it has a isCellEditable(int rowl, int col)
method which you can override for your own needs.
Similar Messages
-
How to set the field non-editable in the classical report..
Hi..
How to set the field non-editable in the classical report..Hi experts,
For the component 'ICCMP_EMP_SRCH' there is a view 'BUPAEMPSEARCH' , which has 2 context nodes 'CUSTOMER' AND 'SEARCHEMPLOYEE' , i need to add the field 'NICKNAME' which is part of the 'CUSTOMER' context node on the search screen. Currrently all the fields on the screen screen are from the 'SEARCHEMPLOYEE' context node. when i did the configuration , the 'NICKNAME' field is greyed out . I have already generated the Getter ,Setter , GET_I, GET_M methods for the 'NICKNAME' field and the context node and controller class and context class are all active .
on debugging the GET_I method, i see that rv_disabled = 'TRUE' and the current = collection_wrapper->get_current( ) is returning empty value .
for this rv_disabled to be set false , the code below is not triggered since there is no value in current.
IF current->is_property_readonly(
'NICKNAME' ) = abap_false. "#EC NOTEXT
rv_disabled = 'FALSE'.
ENDIF.
when i check for other search fields of context node 'SEARCHEMPLOYEE' , all the fields are set to rv_disabled = 'FALSE'.
can anyone suggest how to approch this. iam i missing any binding between context nodes or any activations ?
The field properties are set as Input field and the display checkbox is not checked. -
How to set a column in JTable non-editable?
I have a JTable, and how can I set a particular column non-editable?
Thank you.You could create a sub class of DefaultTableModel, you pass the column number to the constructor or you add a method like setColumnEditable(0, false); to set column 0 non-editable.
You overwrite the method isCellEditable so it will return false when the column number that is passed to the method is 0 (if you want to have column 0 non-editable). -
Non-editable JTable cells?
Is there any way to make all the cells in a JTable non-editable? In the API I see the isEditable method, but no setEditable method. Any suggestions?
You have to set it in the TableModel.
TableModel model = new AbstractTableModel()
public int getRowCount()
return 10;
public int getColumnCount()
return 5;
public Object getValueAt(int row, int column)
return "( "+row+","+column+" )";
public boolean isCellEditable(int row,int column)
return false;
The one given above is a sample to show you how to set a cell non-editable on the cell. You have to customize it for your table model.
Thanks,
Kalyan -
Needed to make baseline date non-editable
Hi Gurus,
My requirement is to make baseline date non editable for miro.Please help how to proceed for this.Hi,
In txn. SHDO create a screen Variant for the tcode MIRO (prog. SAPLFDCB, Screen 0020).
Then click on Create icon from top
It will open the MIRO screen, then click on payment tab, maintain entries in baseline date then clik enter it will popup one screen, there you need to flag under "output Only" for Baseline date, then save.
this setting will make non editable field.
Regards
GK.
Edited by: Gnana Kumar on Oct 28, 2010 2:34 PM -
Setting Non-Editable property for selected Rows in jTable
Hi,
I want particular rows to be set non-editable within a jTable. For example. If I have seven rows as follows:
1
2 - (Non-editable)
3
4
5 - (Non-editable)
6
7
I want to set non-Editable property to the second & Fifth Rows(say) alone. Other Rows, I may edit.
How can I do this?
Thanks in adv.TableModel has method
boolean isCellEditable(int rowIndex,
int columnIndex)
so you need to make your table model return false for these rows. -
Setting ComboBox editable/non-editable in JTable
Hi,
I had a problem I am having a JTable and one of the column in ComboBox.Basing on a cell value the ComboBox should be editabl.e/Non-editable.
I used the setValueAt() method of JTable to set the comboBox and also implemented the cellChangeListener.But it did not work while loading the data intially..Plz help me....
Regards
KiranKiran,
You ignore the words of a goddess at your peril: http://forum.java.sun.com/thread.jsp?forum=57&thread=556061&tstart=15&trange=15
It sounds like some of the values in your TableModel are JComboBoxes, no? That's seems an odd thing.
Are you confusing the data with cell editors? What is your data design? -
JTable cannot make cell non-editable
I have create a JTable using the DefaultTablemodel. I want to make the cells non editable. I have overwritten the method isCellEditable with that shown below but when I double click any cell it still let me edit the cell. Someone please show me what is wrong.
public boolean isCellEditable(int cellrow, int cellcol)
return(false);
// if (cellcol == 0)
// return(false);
// else
// return(true);
Regards
psllooLook at the tutorial! This sample works.
Hope this help.
import javax.swing.JTable;
import javax.swing.table.AbstractTableModel;
import javax.swing.JScrollPane;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.JOptionPane;
import java.awt.*;
import java.awt.event.*;
public class TableDemo extends JFrame {
private boolean DEBUG = true;
public TableDemo() {
super("TableDemo");
MyTableModel myModel = new MyTableModel();
JTable table = new JTable(myModel);
table.setPreferredScrollableViewportSize(new Dimension(500, 70));
//Create the scroll pane and add the table to it.
JScrollPane scrollPane = new JScrollPane(table);
//Add the scroll pane to this window.
getContentPane().add(scrollPane, BorderLayout.CENTER);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
class MyTableModel extends AbstractTableModel {
final String[] columnNames = {"First Name",
"Last Name",
"Sport",
"# of Years",
"Vegetarian",
"essai"};
final Object[][] data = {
{"Mary", "Campione",
"Snowboarding", new Integer(5), new Boolean(false), new Integer(3)},
{"Alison", "Huml",
"Rowing", new Integer(3), new Boolean(true), new Integer(3)},
{"Kathy", "Walrath",
"Chasing toddlers", new Integer(2), new Boolean(false), new Integer(3)},
{"Sharon", "Zakhour",
"Speed reading", new Integer(20), new Boolean(true), new Integer(3)},
{"Angela", "Lih",
"Teaching high school", new Integer(4), new Boolean(false), new Integer(3)}
public int getColumnCount() {
return columnNames.length;
public int getRowCount() {
return data.length;
public String getColumnName(int col) {
return columnNames[col];
public Object getValueAt(int row, int col) {
return data[row][col];
* JTable uses this method to determine the default renderer/
* editor for each cell. If we didn't implement this method,
* then the last column would contain text ("true"/"false"),
* rather than a check box.
public Class getColumnClass(int c) {
return getValueAt(0, c).getClass();
* Don't need to implement this method unless your table's
* editable.
public boolean isCellEditable(int row, int col) {
//Note that the data/cell address is constant,
//no matter where the cell appears onscreen.
if (col < 2) {
return false;
} else {
return true;
* Don't need to implement this method unless your table's
* data can change.
public void setValueAt(Object value, int row, int col) {
if (DEBUG) {
System.out.println("Setting value at " + row + "," + col
+ " to " + value
+ " (an instance of "
+ value.getClass() + ")");
if (data[0][col] instanceof Integer
&& !(value instanceof Integer)) {
//With JFC/Swing 1.1 and JDK 1.2, we need to create
//an Integer from the value; otherwise, the column
//switches to contain Strings. Starting with v 1.3,
//the table automatically converts value to an Integer,
//so you only need the code in the 'else' part of this
//'if' block.
//XXX: See TableEditDemo.java for a better solution!!!
try {
data[row][col] = new Integer(value.toString());
fireTableCellUpdated(row, col);
} catch (NumberFormatException e) {
JOptionPane.showMessageDialog(TableDemo.this,
"The \"" + getColumnName(col)
+ "\" column accepts only integer values.");
} else {
data[row][col] = value;
fireTableCellUpdated(row, col);
if (DEBUG) {
System.out.println("New value of data:");
printDebugData();
private void printDebugData() {
int numRows = getRowCount();
int numCols = getColumnCount();
for (int i=0; i < numRows; i++) {
System.out.print(" row " + i + ":");
for (int j=0; j < numCols; j++) {
System.out.print(" " + data[i][j]);
System.out.println();
System.out.println("--------------------------");
public static void main(String[] args) {
TableDemo frame = new TableDemo();
frame.pack();
frame.setVisible(true);
[\code] -
Payment Term field to be set as Non Editable in Sales Order
Hi,
I have a requirement, in which the user wants to make the Payment Term field in Sales Order as Non Editable in case the Payment terms is copied from Customer Master to Sales order.
In case no value is copied, it should be editable.
Is there any setting to make this happen.
Can anyone help on this?
Please advise.
Regards,
HarshHarsh,
2 Options,
1 by changing screen variants by SHD0
2. By modifying USEr Exit.
Thanks,
Raja -
When recently synchronising my iphone it suggested to uograde to latest software. Now none of my sounds can be changed. Have gone to setting and tried to edit but the only sound I get is Marimba despite a different ringtone being selected?
I also lost my ringtones. I have spent about $100 dollars on ringtones to apply different songs to different callers...and now i can't find them.
-
Set editable/non-editable checkbox in alv grid
Hi all,
How to set a checkbox in alv grid in editable/non-editable. i am using alv gird display function module for this. i tried to used method cl_gui_alv_grid=>mc_style_disabled. but its not working. is it possible to have this functionality in grid? please help. thanks in advance.Hi,
Try like this.
CALL METHOD gr_alvgrid->set_table_for_first_display
EXPORTING
I_BUFFER_ACTIVE =
I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME =
IS_VARIANT =
I_SAVE =
I_DEFAULT = 'X'
is_layout = gs_layout
IS_PRINT =
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING =
IT_HYPERLINK =
CHANGING
it_outtab = gt_list[]
it_fieldcatalog = gt_fieldcat
IT_SORT =
IT_FILTER =
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4
regards
Rajesh kumar -
Setting a Text field in adobe form non editable
Hi Experts,
I have generated a Adobe form using webdynpro java. I have couple text fields. They are binded with some values which a RFC returns. When I see the output These text fiels values which are populated from backend are editable. Can anyone suggest me how to make these text fields non editable.
Thanks,
RajHi Raj,
You have to set the properties of these text field as readonly.
For this you have to select the text field ... Go to the Object Pallete.
There you will see three Tabs Field, Value and Binding.
You have to click on Value Tab and there you have select the Type as Read Only.
If you do not have Object Pallet open .. go to Menu Bar Window and Click Object
This will solve your problem.
Cheers
Satya -
Is it possible that a particular row of IWDTable set to non editable?
Hi All,
Is it possible that a particular row of IWDTable set to non editable on the basis of a field value ?? Plz help.Context
+ Rows (node)
+ value (integer)
+ readOnly (boolean,calculated=true)
Bind the "readOnly" property of the InputField (cell editor) to the "readOnly" attribute shown above. Implement the calculated attribute getter like
boolean getRowsReadOnly(IRowsElement element)
return element.getValue() == 42; /* or whatever */
Armin -
Editable ALV Dump: at setting non editable attribute
I have a problem with the ALV.
I have 2 fields in the ALV: a editable Key field and a non editable dependent text field.
I have binded a free programmed F4-Help at the key field.
In the F4Component I set the Key-field AND the text-field via :
lr_f4_context_element TYPE REF TO if_wd_context_element.
lr_f4_context_element = wd_comp_controller->listener->f4_context_element.
... set_static attribute.
The values are visible in the two alv columns.
But If I change the key after this manually I want to change the text field too.
I change at on eventhandler ON_DATA_CHECK trough set_static_attribute.
But I get later a dump for not assigned fieldsymbol:
Der Abbruch trat im ABAP-Programm "CL_SALV_WD_DATA_TABLE========
zwar in
"SET_TABLE_CELL_REF". Das Hauptprogramm war "SAPMHTTP ".
Im Quelltext befindet sich die Abbruchstelle in Zeile 8
des (Include-)Programms "CL_SALV_WD_DATA_TABLE=========CM00J".
1 method set_table_cell_ref.
2
3 field-symbols:
4 <l_value> type any.
5
6 assign r_value->* to <l_value>.
7
>>> me->set_table_cell(
9 index = index
10 attribute = attribute
11 value = <l_value> ).
12
13 endmethod.
How I can avoid the dump, but change the not editable text field, when the key field is changed?I could solve the problem with the context-mapping between the F4-component and the main-component.
The Approach to set data from the F4-Component to the main component directly was wrong! -
How to set jtable editable?
how to set jtable editable?
Hi,
Doubleclick on a particular cell to get the cellEditor for editing.
Cheers :)
Nagaraj
Maybe you are looking for
-
Possible Internet Tethering/Battery Life Issue
When either Cellular Data is turned Off, or Airplane Mode is turned On, Internet Tethering (Settings>General>Network) appears to have some process that runs continually in the background (evident by continuously spinning wheel next to the option). Th
-
Search function (Spotlight) not working in Mail
Hi, This just started happening today on my PowerBook G4. The search function in Mail is not working. No matter which mailbox I go into to search for a term it shows 0 results when I know for a fact there should be multiple results. If I search for a
-
Dear all, I had try upload STPO by LSMW with PO standard object ( Object: 0085, Method: 0001, Program Name: RM06EE10, Program Type: Direct Input), but 2 error message is come out at the last stage - Start Direct Input Program : message 24 - "Order ty
-
Firefox can't accept that my laptop has now installed the latest version of Adobe Flash Player - the plug-in states it is out-of-date & numbers the old one. Ive tried all ways to rectify this but nothing works... Fox still states that I have to updat
-
Maverick upgrade - iPhoto problems
I have updated my iMac with Maverick but find iPhoto won't work. I get the error message: "You can't' use this version of the application "iPhoto" with this version of OS X. You have "iPhoto" 9.2.3 - Any ideas what I do now? What's the point of an