Cs03 - add column table (parts list)
Hi,
I´m new in ABAPprogramming and 2 weeks ago I got my first task.
I have to add a column with the manufacturer part number in the resulttable of the transactionnumber cs03.
I searched in several forums but I really don´t know- how can I add this column.
I read that I have to modify the Dynpro and the structure (RC29P) or add an user-exit?
Which solution is the best for my problem?
So please, can you tell me. where I have to change (structure) and in which (sub)program?
Thanks a lot.
Tobias
No you do'nt need to create... Which version of SAP you are using..? The one which we told is satndard enhancement which is available in SAP for that tcode.
I doubt in your version that enhancemnt is not available.
However I suggest you to copy paste this program (http://www.sapgenie.com/abap/code/abap26.htm ) in a your se38 editor, execute it , give the Tcode <b>CS02</b> in the prarameter option of the program execute.
This will list all the enhancements available in your version for this particular transaction.
Go to each <b>enhancements==> COmponents and see Screen Area</b>. You can modify those standard screens which are listed there. This way you can select a suitable userexit for your TCODE.
rgds,
TM.
Similar Messages
-
Hello all,
I have what so far appears to be a fairly unique problem. We are running a multilingual SharePoint 2010 environment with English as the default language and French as the secondary. We have setup the sites in a variance relationship, but the
issue I am discussing happens outside of a variant as well.
We have created a library outside the variant (but within the collection) that the two sites must share. A list view web part was created via Designer to add to each site to provide a quick view into the list. If we are in the libary and switch
to French, then update the column label it will remember the setting (because of the resource file) and maintain it as the language is flipped back and forth. Where it doesn't work is as a web part in a variant or where the language is different.
If the language is different, the out of the box columns work find, but the custom columns (all site columns not library\list columns) remain as the english label. It doesn't matter if within a variant or outside with the browser language changed.
It always reverts back to English. It's like it isn't using the same resource file that was used in the list itself.
I created a custom view and modified it with xslt as per
http://sharepoint.stackexchange.com/questions/50004/how-to-change-column-title-for-a-view-but-not-modify-the-list but this only worked within the list and did not occur in the list view either.
I can't be the first that has come across it, either I am not performing my searches properly, no one has ever documented a fix for this or this is something we just can't fix with OOTB tools. That's the other thing, the solution has to be accomplised
OOTB or with minor client side changes. I can't fire up Visual Studio because they are piloting Office 365 and have put a "No custom code" mandate on for migration.
Thank you all in advance.Ok, I have come up with a solution. I edited the XSLT for the web part on the page. I did the following:
1. Create the variants in the Site Ccollection
2. Create the library outside of the variants.
3. Add all the columns you require for the library. It is very important all the columns are there before you move on.
4. Create a French and English view.
5. Create the list view web part via designer.
6. Add the list view web part to each site selecting the appropriate view to use.
7. Edit the page in SharePoint Designer 2010.
8. Place cursor in the column you wish to modify.
9. Click Design in the List View Tools on the ribbon.
10. Then click Customize XSLT and select Customize Item. Select this option otherwise you will generate a **LOT** of unnecessary XSL code.
11. You are looking for a piece that resembles the following:
<xsl:with-param name="fieldtitle">
<xsl:value-of select="@DisplayName"/>
</xsl:with-param>
12. Modify it by typing in the actual column name you want. You should end up with something like this:
<xsl:with-param name="fieldtitle">
New Column Name.
</xsl:with-param>
13. Now, for this page only, the column will be renamed.
There are some caveats:
1. Doesn’t appear to work in a publishing portal. I think this has to do with how SP stores the pages in this case. In a publishing portal you can only modify the page layout which won’t work as we need to modify the content.
2. If you add another column, you will need to repeat the XSLT modification
Anyways, I hope this helps out any others with the same issue or need as I had. -
How to add custom columns to the list view in Finder
Hi,
I'm looking for a way to view additional file details in the list view in Finder, for example audio bit rate, so I don't have to do "Get Info" for each file separately. I couldn't find a way to add columns other than the ones listed on the view options dialog.
Can anyone help me find a way to do it?
Thanks,
TalHave you checked the Help menu for what you want to do? I found this in Apple support - List View Options
Check the AppleScript Forums. There is probably a script that you can use. -
Bex reporting (how to add a column/table by using macros)
Hai,
can anyone help me in this reagrd..
iam trying to enhance a query..
the requirement is to add a separate column/table to the right side of the result area..say 0country.
the affected materials should display only once in the country coloumn/table.
but the thing is to display a charecteristic after the keyfigures...i mean to the right of the result area..
let me know how to do this...
regards,
rambo..Hi,
Put 0COUNTRY into query and press 'Table Display' icon. Vary char position (rows, columns, before, after).
It should do the trick.
Certainly, 0COUNTRY will be INSIDE resultarea. But, I think, it's not end in itself.
Best regards,
Eugene -
How to Add column with default value in compress table.
Hi ,
while trying to add column to compressed table with default value i am getting error.
Even i tried no compress command on table still its giivg error that add/drop not allowed on compressed table.
Can anyone help me in this .
Thanks.Aman wrote:
while trying to add column to compressed table with default value i am getting error.This is clearly explain in the Oracle doc :
"+You cannot add a column with a default value to a compressed table or to a partitioned table containing any compressed partition, unless you first disable compression for the table or partition+"
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_3001.htm#sthref5163
Nicolas. -
Add custom column in default list view in sharepoint
Hello,
How to add custom column in default list view in SharePoint 2013? In list view we have view fields section. But its not allowing to add any static text. I want to add one button/textin view fields. How to add that?
<View Name="{C7499466-A865-4742-8511-5536D2521D1C}" MobileView="TRUE" Type="HTML" Hidden="TRUE" DisplayName="All Documents" Url="/SectionManagement/SitePages/Untitled_1.aspx" Level="1"
BaseViewID="1" ContentTypeID="0x" ImageUrl="/_layouts/15/images/dlicon.png?rev=23" ><Query/>
<ViewFields>
<FieldRef Name="LinkFilename"/>
<FieldRef Name="LinkFilenameNoMenu"/>
</ViewFields>Hi,
to add a field to a view use this
<ViewFields>
<FieldRef Name="LinkFilename"/>
<FieldRef Name="LinkFilenameNoMenu"/>
<FieldRef Name=[InternalNameOfCustomField]/>
</ViewFields> -
How to add column to report from the same table? Gives error now
Steps to reproduce:
Build a report on a table with easy report, select all columns
Add column to the table
Edit report and add column (one has to click Show Related Tables Only: No to view the same table!)
Report will give error as it will be build as
SELECT ... FROM table1, table1AH HAAA!!!!
And I was afraid to convert from the "SQL (Structured Query)" to "SQL". Probably because I blew up my other reports...
Thanks! -
Cannot add column to flexible table when ddl autocommit is off using Procedure
Hello All,
Through procedure I am trying to insert data into the target(EX_92) table(with schema flexibility)
Source table data
ID
PRODUCT_CODE
PRODUCT_NAME
PRICE
COLOR
TYPE
1
1
rugg
101.22
2
1
rugg
101.22
3
2
book
200.32
BLUE
Y
Target table QUERY
drop table EX_P2;
CREATE COLUMN TABLE EX_P2(
ID INTEGER PRIMARY KEY,
PRODUCT_CODE VARCHAR(3),
PRODUCT_NAME NVARCHAR(20),
PRICE DECIMAL(5,2)
) WITH SCHEMA FLEXIBILITY;
Procedure to insert above records with additional columns into the target table(EX_P2)
Procedure
drop procedure "DS_O1"."PROC";
create procedure "DS_O1"."PROC"(IN max_value INTEGER, IN schema_name varchar(40), IN table_name varchar(40), IN column_list varchar(400))
LANGUAGE SQLSCRIPT AS
BEGIN
DECLARE maxid integer :=0;
DECLARE INSERT_STR VARCHAR(1000) :='';
select max(ID) into maxid from "DS_O1"."EX_P2";
select :maxid from dummy;
INSERT_STR :='insert into "' || 'DS_O1' ||'"."EX_P2" ('||:column_list||') (select ' ||:column_list||'
FROM "'||:schema_name||'"."'||:table_name||'"' || ' where ID >' || :max_value || ')';
EXECUTE immediate(:INSERT_STR);
END;
Now while executing above procedure
CALL "DS_O1"."PROC" ( 0, 'DS_O1', 'TMP_EXL2','ID,PRODUCT_CODE,PRODUCT_NAME,PRICE,COLOR,STATUS,TYPE');
I am getting the following error
Could not execute 'CALL "DS_O1"."PROC" ( 0, 'DS_O1', 'TMP_EXL2','ID,PRODUCT_CODE,PRODUCT_NAME,PRICE,COLOR,STATUS,TYPE')' in 23 ms 564 µs .
SAP DBTech JDBC: [7]: feature not supported: [7] "DS_O1"."PROC": line 18 col 1 (at pos 779): [7] (range 3): feature not supported: cannot add column to flexible table when ddl autocommit is offHi Rajnish,
I had the same issue. For what it’s worth I was able to do a workaround basically creating all the columns when I create the table. The following code works for me to create the table which is just a matrix with one Integer column as the key and the rest as type Double.
It is not ideal in all scenarios because the table columns cannot be added dynamically via a procedure at a later point. This table has 27K columns now
Of course one of the advantages of a flex table would be programmatically adding columns dynamically. This works, but maybe there is still a way to add columns dynamically from a procedure, and someone else can advise.
Apparently dynamically adding columns via procedures may have some "minor" limitations due to the need to compile the procedure with knowledge of the flex table DDL. But again, hopefully someone knows another solution.
Best regards,
Mark
DROP PROCEDURE CREATE_MATRIX;
CREATE PROCEDURE CREATE_MATRIX(
LANGUAGE SQLSCRIPT
SQL SECURITY INVOKER
AS
/*********BEGIN PROCEDURE SCRIPT ************/
BEGIN
-- cursor over messages
declare cursor matrix_cursor for
select distinct TERM
from TERMS
order by term;
declare cnt INTEGER := 0;
declare temptxt NVARCHAR(500000) := 'CREATE COLUMN TABLE DOC_MATRIX ( CONTENT_ID INTEGER ';
for cur_matrix as matrix_cursor do
cnt:=:cnt + 1;
select temptxt || ', C' || cnt || ' DOUBLE' into temptxt from dummy;
end for;
temptxt:=temptxt || ' ) WITH SCHEMA FLEXIBILITY';
EXEC :temptxt;
select :temptxt from dummy;
END;
DROP TABLE DOC_MATRIX;
CALL CREATE_MATRIX(); -
Nsert/Update and Add Column at the same Table and at the "same" Time
Hello,
I want Insert/Update and Add Column at the same Table and at the "same" Time but in different sessions.
Example:
At first the "insert/update" statement:
Insert into TestTable (Testid,Value) values (1,5105);
After that the "add" statement:
Alter table TestTable add TestColumn number;
- sadly now I get the message: ORA-00054: resource busy and acquire with NOWAIT specified
"insert/update" statement:
Insert into TestTable (Testid,Value) values (2,1135);
After that the execute commit.
I don't know when the first session set the commit statement so I want that the DB the "Alter Table..." statement execute if it's possible.
If it's possible I want to save a repeat loop with the "Alter Table..." statemtent.
Thanks for ideasWell I want to walk in the rain without and umbrella and still stay dry, but it ain't gonna happen.
You can't run a DDL statement against a table with transactions pending. Session 2 has to wait until session commits or rollbacks (or until the session is killed). That's just the way it is.
This makes sense if you think about it. The data dictionary has to be consistent across all sessions. If session 2 was allowed to change the table structure whilst session 1 has a pending transaction then the database is in an inconsistent state. This is easier to see if you consider the reverse situation - the ALTER TABLE statement run by session 2 does a DROP COLUMN TESTID rather than adding a column: now what should happen to session 1's INSERT statement? You have retrospectively invalidated a statement that was perfectly legal when it was executed.
If it's possible I want to save a repeat loop with the "Alter Table..." statemtent.Fnord.
Cheers, APC -
How to add columns for existing table dynamically?
Hi,
I created table structure only. I want to add columns for this existing table. Columns are not fixed, according to the user choice i need to write code.
Plz give me reply asap.
Thanks
ShirishaHi Shirisha,
I think the following code snippet will help you.
int l_no_cols = 0;
//Get the number of columns in this variable, something like the following
//l_no_cols = wdContext().currentContextElement().get<Context_attribute_name>;
IWDTable l_tab;
IWDTransparentContainer l_tbl_cont = (IWDTransparentContainer)view.getElement("TableDataCont");//ID of Container
l_tab = (IWDTable)view.getElement("TableData");//ID of Table
l_tab.setVisible(WDVisibility.VISIBLE);
l_tab.bindDataSource(wdContext.nodeTable_Data().getNodeInfo());
for(int a = 1; a <=l_no_cols; a++)
//Creating the column
IWDTableColumn l_tab_col = (IWDTableColumn)view.createElement(IWDTableColumn.class,"COL"+a);
//Creating Caption for Column Header
IWDCaption l_tab_cap = (IWDCaption)view.createElement(IWDCaption.class,"Caption"+a);
l_tab_cap.setText("Col"+i);
l_tab_col.setHeader(l_tab_cap);
//Creating Table Cell Editor for column
IWDInputField l_tab_cell = (IWDInputField)view.createElement(IWDInputField.class,"CellEditor"+a);
//creating context node attribute for the column dynamically
wdContext.nodeTable_Data().getNodeInfo().addAttribute("Col"+i,"com.sap.dictionary.String");
l_tab_cell.bindValue(wdContext.nodeTable_Data().getNodeInfo().getAttribute("Col"+i));
l_tab_col.setTableCellEditor(l_tab_cell);
l_tab.addColumn(l_tab_col);
l_tbl_cont.addChild(l_tab);
Regards,
Alka -
Enhancement Request: History List -- Add Columns Catagory1, Catagory2, Bugz
Please consider this enhancement request:
To History List:
Please add columns:
Catagory1 text
Catagory2 text
BugNumber numeric ( as in Bugzilla bug number )
Thanks.Possibly add a:
Note text
column as well? -
ORA-22856: cannot add columns to object tables
Oracle 9i
==========
I tried to alter a table using a simple script.
ALTER TABLE tablename ADD col VARCHAR(50);
And it gave me the error: -
ORA-22856: cannot add columns to object tables
Can someone give me some direction on how to resolve this? The script executes fine on a test env.
Thanks in advanceThanks for replying...
exit Null? Type
BUS NUMBER
REP VARCHAR2(60)
COS NUMBER
REP VARCHAR2(50)
ACC NUMBER
ADJ VARCHAR2(2000)
BAS NUMBER
BIL VARCHAR2(360)
BIL VARCHAR2(50)
BIL VARCHAR2(3)
BIL VARCHAR2(50)
BLP VARCHAR2(240)
BLP NUMBER
BOO DATE
COM NUMBER
COM NUMBER
COM NUMBER(15)
COM NUMBER(15)
COM VARCHAR2(4000)
COM VARCHAR2(30)
CUR NUMBER
CUS VARCHAR2(240)
DEA VARCHAR2(240)
EVE VARCHAR2(240)
HEA VARCHAR2(240)
HEA VARCHAR2(240)
HEA VARCHAR2(240)
HEA VARCHAR2(240)
INC VARCHAR2(30)
INV DATE
MAN VARCHAR2(360)
ORD NUMBER
ORD VARCHAR2(240)
PAY VARCHAR2(240)
PAY NUMBER
HEL NUMBER
PEO VARCHAR2(150)
PER NUMBER
PER VARCHAR2(30)
PER NUMBER(15)
PRO VARCHAR2(240)
PRO VARCHAR2(240)
QUA NUMBER(15)
QUO NUMBER
QUO DATE
QUO DATE
QUO VARCHAR2(80)
RED VARCHAR2(240)
REP VARCHAR2(360)
REP VARCHAR2(30)
REP VARCHAR2(30)
REP VARCHAR2(150)
REP VARCHAR2(3)
REP VARCHAR2(150)
REP VARCHAR2(50)
ROL VARCHAR2(60)
SHI VARCHAR2(360)
SPL VARCHAR2(240)
STA DATE
TER DATE
TOT VARCHAR2(240)
TRX NUMBER
TRX VARCHAR2(240)
TRX VARCHAR2(20)
TRX VARCHAR2(30)
WAI VARCHAR2(240)
YEA NUMBER
MAN VARCHAR2(30)
BUF NUMBER
BUF VARCHAR2(60)
EMC NUMBER
EMC VARCHAR2(60)
INT NUMBER
INT VARCHAR2(60)
SUP NUMBER
SUP VARCHAR2(60)
BRM NUMBER
BRM VARCHAR2(60)
SUP NUMBER
SUP VARCHAR2(60)
REP NUMBER
REP VARCHAR2(60)
DIV NUMBER
DIV VARCHAR2(60)
SUP NUMBER
SUP VARCHAR2(60)
REG NUMBER
REG VARCHAR2(60)
SUP NUMBER
SUP VARCHAR2(60)
ARE NUMBER
ARE VARCHAR2(60)
DIS NUMBER
DIS VARCHAR2(60)
ROL VARCHAR2(240)
ACC NUMBER
BON NUMBER
COM VARCHAR2(240)
COM VARCHAR2(240)
REP NUMBER
BIL NUMBER
BAS NUMBER
TOT NUMBER
TOT NUMBER
OVE NUMBER
BLP NUMBER
QUO VARCHAR2(30)
FN_ NUMBER
FN_ VARCHAR2(10)
SAL NUMBER
RES NUMBER
CRE NUMBER
MAN VARCHAR2(100)
PER NUMBER
PLA NUMBER
PLA NUMBER
REV VARCHAR2(30)
REP VARCHAR2(150)
OU_ NUMBER
OU_ NUMBER
EXC VARCHAR2(1)
MAN NUMBER
INV NUMBER
REP NUMBER
UPL VARCHAR2(1)
COM NUMBER
SEQ NUMBER
QUO NUMBER
PRO VARCHAR2(10)
PRO NUMBER
PRO NUMBER
BI_ NUMBER
CUR NUMBER
YTD NUMBER
PAY NUMBER
PAY DATE
PAY VARCHAR2(1000)
PAY VARCHAR2(80)
PAI VARCHAR2(1)
HOL VARCHAR2(1)
SRP NUMBER
WAI VARCHAR2(1)
WAI VARCHAR2(1)
GBK VARCHAR2(10)
TRX DATE
PAY NUMBER(15)
FIX NUMBER
TER DATE
ADJ VARCHAR2(240)
PAY NUMBER
PRO DATE
OIC DATE
OIC NUMBER
OIC VARCHAR2(30)
OIC NUMBER
HEL NUMBER
COM NUMBER
TRA NUMBER
HDR VARCHAR2(30)
LIN VARCHAR2(30)
LIN DATE
SRC DATE
EM_ DATE
EM_ DATE
ORD VARCHAR2(30)
REP VARCHAR2(150)
BIL VARCHAR2(300)
PER VARCHAR2(240)
Excuse the incomplete column names. All datatypes are basic ones and there are no constraints defined on any of the columns (dw env). The table is partitioned. -
Is it planned to add feature for creating tables and lists in Adobe Edge Reflow?
First of all, thank you very much guys for all your work!
In my opinion Adobe Edge Reflow is missing quite important features, like creating tables and lists. For me it's a reason why I can't switch to Reflow. Any plans for implementing these? Is there any place where I can see the list of planned feature implementation? Didn't find it.Missing tables is a big one for me too, especially when doing data-grids. My last prototype was using multiple responsive data-grids where I used the simpler essential/optional hide column approach, instead of stacking or scrolling the data. I had used Reflow in the past for basic content prototypes... but had to do this one by hand... took longer. Using divs for this did not collapse properly in all the browsers, plus the back-end team use widgets that only generate tables. Here is the example:
http://www.topwebworks.com/assets/test/prototype/riocompass_prototype_v1 -
Current User Filter not available in the Add Web Parts list - Sharepoint 2007
Hi everybody,
I'm trying to build a copy (or auto-populate) function on a list.
I did all the coding changes, now I need to add a web part to my list called Current User Filter.
Problem is, the Current User Filter is not in the Web Part list at all!
How can I add it ? I looked in the Central Admin Panel and did not see anything.
Thanks in advance!What version of SharePoint are you using? I think that this is s MOSS webpart, so if you're using the WSS version of the product, you're probably out of luck.
Steven Andrews
SharePoint Business Analyst: LiveNation Entertainment
Blog: baron72.wordpress.com
Twitter: Follow @backpackerd00d
My Wiki Articles:
CodePlex Corner Series
Please remember to mark your question as "answered" if this solves (or helps) your problem. -
How to add a table(from TableRenderDemo) to a JFrame again
Hello again:
Thanks for stephen andrews's adivice, I follow your adivice to add code (it is in
EventHandeler of DrawCalendar class, and they indicated by ???????????), but it still not work, please check for me why, Thanks.
My problem
Please run my coding first, and get some view from my coding.
At the movement, I got a problem, I have not idea how to add a table(it is from TableRenderDemo) to JFrame when I click on the button(from DrawCalendar) of the numer 20, and I want the table disply under the buttons(from DrawCalendar).
Please help me to solve this problem, thanks.
*This program for add some buttons and a table on JFrame
import java.awt.*;
import javax.swing.*;public class TestMain extends JFrame{
private static TableRenderDemo tRD;
private static TestMain tM;
protected static Container c;
private static DrawCalendar dC;
public static void main(String[] args){
tM = new TestMain();
tM.setVisible(true);
public TestMain(){
super(" Test");
setSize(800,600);
//set up layoutManager
c=getContentPane();
c.setLayout ( new GridLayout(3,1));
tRD=new TableRenderDemo();
dC=new DrawCalendar();
addItems();//add Buttons to JFrame
private void addItems(){
c.add(dC); //add Buttons to JFrame
//c.add(tRD); //add Table to JFrame
*This program for add some buttons to JPanel
*and add listeners to each button
*I want to display myTable under the buttons,
*when I click on number 20, but why it doesn't
*work, The coding for these part are indicated by ??????????????
[import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.GridLayout;
public class DrawCalendar extends JPanel {
private static DrawCalendar dC;
private static TestMain tM;
private static TableRenderDemo myTable;
private static GridLayout gL;
private static final int nlen = 35;
private static String names[] = new String[nlen];
private static JButton buttons[] = new JButton[nlen];
public DrawCalendar(){
gL=new GridLayout(5,7,0,0);
setLayout(gL);
assignValues();
addJButton();
registerListener();
//assign values to each button
private void assignValues(){
names = new String[35];
for(int i = 0; i < names.length; i++)
names[i] = Integer.toString(i + 1);
//create buttons and add them to Jpanel
private void addJButton(){
buttons=new JButton[names.length];
for (int i=0; i<names.length; i++){
buttons=new JButton(names[i]);
buttons[i].setBorder(null);
buttons[i].setBackground(Color.white);
buttons[i].setFont(new Font ("Palatino", 0,8));
add(buttons[i]);
//add listeners to each button
private void registerListener(){
for(int i=0; i<35; i++)
buttons[i].addActionListener(new EventHandler());
//I want to display myTable under the buttons,
//when I click on number 20, but why it doesn't
//work
private class EventHandler implements ActionListener{
public void actionPerformed(ActionEvent e){
for(int i=0; i<35; i++){
if(i==20){ //????????????????????
tM=new TestMain(); //I want to display myTable under the buttons,
tM.c.removeAll(); //when I click on number 20, but why it doesn't
tM.c.add(dC); //work
tM.c.add(myTable); //???????????????????????????????????????
tM.validate();
if(e.getSource()==buttons[i]){
System.out.println("testing " + names[i]);
break;
*This program create a table with some data
[import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableColumn;
import javax.swing.DefaultCellEditor;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class TableRenderDemo extends JScrollPane {
private boolean DEBUG = true;
public TableRenderDemo() {
// super("TableRenderDemo");
MyTableModel myModel = new MyTableModel();
JTable table = new JTable(myModel);
table.setPreferredScrollableViewportSize(new Dimension(700, 70));//500,70
//Create the scroll pane and add the table to it.
setViewportView(table);
//Set up column sizes.
initColumnSizes(table, myModel);
//Fiddle with the Sport column's cell editors/renderers.
setUpSportColumn(table.getColumnModel().getColumn(2));
* This method picks good column sizes.
* If all column heads are wider than the column's cells'
* contents, then you can just use column.sizeWidthToFit().
private void initColumnSizes(JTable table, MyTableModel model) {
TableColumn column = null;
Component comp = null;
int headerWidth = 0;
int cellWidth = 0;
Object[] longValues = model.longValues;
for (int i = 0; i < 5; i++) {
column = table.getColumnModel().getColumn(i);
try {
comp = column.getHeaderRenderer().
getTableCellRendererComponent(
null, column.getHeaderValue(),
false, false, 0, 0);
headerWidth = comp.getPreferredSize().width;
} catch (NullPointerException e) {
System.err.println("Null pointer exception!");
System.err.println(" getHeaderRenderer returns null in 1.3.");
System.err.println(" The replacement is getDefaultRenderer.");
comp = table.getDefaultRenderer(model.getColumnClass(i)).
getTableCellRendererComponent(
table, longValues[i],
false, false, 0, i);
cellWidth = comp.getPreferredSize().width;
if (DEBUG) {
System.out.println("Initializing width of column "
+ i + ". "
+ "headerWidth = " + headerWidth
+ "; cellWidth = " + cellWidth);
//XXX: Before Swing 1.1 Beta 2, use setMinWidth instead.
column.setPreferredWidth(Math.max(headerWidth, cellWidth));
public void setUpSportColumn(TableColumn sportColumn) {
//Set up the editor for the sport cells.
JComboBox comboBox = new JComboBox();
comboBox.addItem("Snowboarding");
comboBox.addItem("Rowing");
comboBox.addItem("Chasing toddlers");
comboBox.addItem("Speed reading");
comboBox.addItem("Teaching high school");
comboBox.addItem("None");
sportColumn.setCellEditor(new DefaultCellEditor(comboBox));
//Set up tool tips for the sport cells.
DefaultTableCellRenderer renderer =
new DefaultTableCellRenderer();
renderer.setToolTipText("Click for combo box");
sportColumn.setCellRenderer(renderer);
//Set up tool tip for the sport column header.
TableCellRenderer headerRenderer = sportColumn.getHeaderRenderer();
if (headerRenderer instanceof DefaultTableCellRenderer) {
((DefaultTableCellRenderer)headerRenderer).setToolTipText(
"Click the sport to see a list of choices");
class MyTableModel extends AbstractTableModel {
final String[] columnNames = {"First Name",
"Last Name",
"Sport",
"# of Years",
"Vegetarian"};
final Object[][] data = {
{"Mary ", "Campione",
"Snowboarding", new Integer(5), new Boolean(false)},
{"Alison", "Huml",
"Rowing", new Integer(3), new Boolean(true)},
{"Kathy", "Walrath",
"Chasing toddlers", new Integer(2), new Boolean(false)},
{"Sharon", "Zakhour",
"Speed reading", new Integer(20), new Boolean(true)},
{"Angela", "Lih",
"Teaching high school", new Integer(4), new Boolean(false)}
public final Object[] longValues = {"Angela", "Andrews",
"Teaching high school",
new Integer(20), Boolean.TRUE};
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.
try {
data[row][col] = new Integer(value.toString());
fireTableCellUpdated(row, col);
} catch (NumberFormatException e) {
JOptionPane.showMessageDialog(TableRenderDemo.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("--------------------------");http://forum.java.sun.com/faq.jsp#format
Maybe you are looking for
-
ODI behavior is not consistent in case of LKM loading.
Hi All, I am facing a strange problem in ODI version 11.1.1 Actually, we have couple of interfaces and one master package. We are generating scenario for master package. We are exporting that scenario and keep it at specific location so that our appl
-
Whenever I try to sign in to my iMessage, it says check your network connection and try again. Well, my WiFi works fine and I am updated to the latest software update(iOS 7.1.1). How should I fix this to sign in?
-
How to set my router to allow one site entrance??
Hello I need help with limit my surfers form surfing outside my web. I have internet spot with WRT54G Linksys Router, the access to the router is free at my Cafe place. I would like the customers to only be able to surf to the cafe site and the opti
-
How can I increase default font size in Safari?
I know about doing a reverse "pinch" of the screen to increase font size in Safari, but is there a way to set a larger default font size?
-
I'm seeing some more strange behavior using WLST deploy. It's not using the parameters I pass in. The first case is with Plan files. I used to just give the top level directory name for the app, and it would detect the plan.xml files in the plan dir.