Module Pool table controle row level prob
Hi Experts,
I am working in a module pool program where in table controle i want a perticular row should become in display mode if a specific field is NE SPACE. is it possible if possible than please sugest me how.
Thanks and Regards,
D Tarun Kumar
In this case all the rows will be in display mode
Exactly My Requirement I am describing with example
Suppose in table control I have three Records and the first field is main field which is if initial than the row should in change mode otherwise is should be in display mode.
Field1 Field2 Field3 Field4 Field5
1abc2 1abc3 1abc4 1abc5 Record 1
2xyz1 2xyz2 2xyz3 2xyz4 2xyz5 Record 2
3pqr2 3pqr3 3pqr4 3pqr5 Record 3
So here the second rowu2019s first field is not initial so I need here in table control the second row should be in display mode and next first and second row should be in change mode.
Now You tell me is it possible or not if possible than please suggest me what I have to do
Thanks & regards,
D Tarun Kumar
Edited by: Devalla T Kumar on Oct 24, 2009 9:17 AM
Similar Messages
-
How can i decleare select-options in module pool table control?
Hi everybody!!
Can anyone tell me how can I decleare select-options in module pool table control screen?. I have declared it in a screen with a table control but a dump is triggered due to an error when generating the selection screen.
Regards...My suggestion will be try to use fm
call function 'FREE_SELECTIONS_DIALOG'
Please search this forum you can find lot of threads related to this.
a® -
Dynamic text in module pool table control
Hi ,
Can we have dynamic header text in module pool table control. Like dynamic header text in ALV report.
Thanks,
Prem.Hi,
Populate an internal table with the header text that you want.
Replace the headers with I/O fields.
Populate the Headers in the PBO. -
Module pool - table control - update ztable
hello , i doing a module pool that will have few screens , now i have one screen with a table control that fetch the data from a ztable when screen is call the table control is showing the data and is in grey and no editable i add a pf-status for change that mode i can delete the row from the table control but i don't figure out how update to the ztable when i press save , i wan't too another button for add a new row ( and remain the already in grey ) for add new entrie in the table and update the ztable
pd: sorry for my bad english
this is my code:
TOP:
PROGRAM z_pp_lote_etiquetas MESSAGE-ID zz.
TABLES:zc2p_lote_etique,
zc2p_lider_modul.
DATA: ok_code LIKE sy-ucomm.
DATA save_ok LIKE sy-ucomm.
* internal table
DATA: it_zc2p_lote_etique LIKE STANDARD TABLE OF zc2p_lote_etique.
DATA: it_zc2p_lider_modul TYPE STANDARD TABLE OF zc2p_lider_modul WITH HEADER LINE.
DATA: it_zc2p_lider_modul_del TYPE STANDARD TABLE OF zc2p_lider_modul WITH HEADER LINE.
**************Workarea
DATA: wa_c2p_lote_etique TYPE zc2p_lote_etique.
DATA: wa_c2p_lider_modul TYPE zc2p_lider_modul.
DATA: wa_c2p_lider_modul_del TYPE zc2p_lider_modul.
DATA: sel.
DATA: MARK.
DATA: init.
DATA: col TYPE scxtab_column.
DATA: lines TYPE i.
* Variable Declaration
DATA : flg, "Flag to set the change mode
ln TYPE i. "No. of records
* Table Control Declartion.
CONTROLS: zc2p_lider_crtl TYPE TABLEVIEW USING SCREEN '101'.
**PROCESS BEFORE OUTPUT INCLUDE **
*& Include Z_PP_LOTE_ETIQUETAS_O01
*& Module set_status OUTPUT
* Setting the GUI status
MODULE status_0100 OUTPUT.
SET PF-STATUS 'Z_PP_LOT_ETIQ_MENU'.
SET TITLEBAR 'Z_PP_LOT_ETIQ'.
ENDMODULE. " set_status OUTPUT screen 100
* MODULE status_0101 OUTPUT
* Setting the GUI status
MODULE status_0101 OUTPUT.
SET PF-STATUS 'Z_PP_LOT_ETIQ_ME_101'.
SET TITLEBAR 'Z_PP_LOT_ETIQ'.
* Data retreving
if init is INITIAL.
select * from zc2p_lider_modul into CORRESPONDING FIELDS OF TABLE it_zc2p_lider_modul.
DESCRIBE TABLE it_zc2p_lider_modul LINES ln.
zc2p_lider_crtl-lines = ln + 10.
init = 'X'.
endif.
ENDMODULE. "status_0101 OUTPUT
module change_sdyn_conn output.
* you can change the content of current table control line via
* sdyn_conn
READ TABLE it_zc2p_lider_modul INTO zc2p_lider_modul INDEX zc2p_lider_crtl-current_line.
endmodule. " FILL_TABLE_CONTROL OUTPUT
MODULE set_screen_fields OUTPUT.
LOOP AT SCREEN.
IF flg IS INITIAL.
screen-input = 0.
ELSE.
screen-input = 1.
ENDIF.
*ENDIF.
* Modifying the screen after making changes
MODIFY SCREEN.
ENDLOOP.
ENDMODULE. " set_screen_fields OUTPUT
PROCESS AFTER INPUT INCLUDE.
* MODULE USER_COMMAND_0100 INPUT
MODULE user_command_0100 INPUT.
CASE ok_code.
WHEN 'LIDM'.
CALL SCREEN 101.
WHEN 'CANC'.
LEAVE PROGRAM.
WHEN 'BACK'.
LEAVE PROGRAM.
WHEN 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. "USER_COMMAND_0100 INPUT
* MODULE USER_COMMAND_0101 INPUT
MODULE user_command_0101 INPUT.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'SORT'.
DATA: fldname(100),help(100).
READ TABLE zc2p_lider_crtl-cols INTO col WITH KEY selected = 'X'.
SPLIT col-screen-name AT '-' INTO help fldname.
SORT it_zc2p_lider_modul BY (fldname).
WHEN 'CHANGE'.
* Setting the flag to make the table control in editable mode[excluding
* primary key].
flg = 'Y'.
WHEN 'BACK'.
CALL SCREEN 100.
LEAVE SCREEN.
WHEN 'CANCEL'.
LEAVE PROGRAM.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'SAVE'.
MODIFY zc2p_lider_modul FROM it_zc2p_lider_modul.
COMMIT WORK.
ENDCASE.
ENDMODULE. "USER_COMMAND_0101 INPUT
* MODULE read_table_control INPUT
MODULE read_table_control INPUT.
* Check input values
IF mark = 'X' AND save_ok = 'DELETE'.
DELETE TABLE it_zc2p_lider_modul FROM zc2p_lider_modul.
DESCRIBE TABLE it_zc2p_lider_modul LINES zc2p_lider_crtl-lines.
ENDIF.
ENDMODULE. " READ_TABLE_CONTROL INPUT
Screen Flow Logic 100
PROCESS BEFORE OUTPUT.
MODULE status_0100.
PROCESS AFTER INPUT.
MODULE user_command_0100.
Screen Flow Logic 101.
PROCESS BEFORE OUTPUT.
MODULE status_0101.
LOOP AT it_zc2p_lider_modul INTO zc2p_lider_modul WITH CONTROL
zc2p_lider_crtl.
* Dynamic screen modifications
MODULE set_screen_fields.
MODULE change_sdyn_conn.
ENDLOOP.
PROCESS AFTER INPUT.
MODULE user_command_0101.
LOOP AT it_zc2p_lider_modul.
MODULE read_table_control.
ENDLOOP.
i hope somebody can help for what i missing here thanks>
Sanjeev Kumar wrote:
> Hello Edgar,
>
> Problem seems to be there in the flow logic of 101
>
>
> PROCESS BEFORE OUTPUT.
> MODULE status_0101.
> LOOP AT it_zc2p_lider_modul INTO zc2p_lider_modul WITH CONTROL
> zc2p_lider_crtl. " no need to have 'INTO zc2p_lider_modul' above
> * Dynamic screen modifications
> MODULE set_screen_fields.
> MODULE change_sdyn_conn.
> ENDLOOP.
> *
> PROCESS AFTER INPUT.
> MODULE user_command_0101. "this should be shifted after the following LOOP...ENDLOOP.
>
> LOOP AT it_zc2p_lider_modul. "need to have 'WITH CONTROL zc2p_lider_crtl' here
> MODULE read_table_control.
> ENDLOOP.
>
>
>
> With MODULE user_command_0101 call before the LOOP calls the MODIFY statement (under case save_ok 'SAVE') first and Z-table is updated with the old values as the changes are transferred from screen into the internal table it_zc2p_lider_modul in the LOOP...ENDLOOP later.
>
> Try these changes and I hope it will work.
>
> Thanks
> Sanjeev
i do the firts advice but the second one i get syntax error :
my code :
PROCESS AFTER INPUT.
LOOP at it_zc2p_lider_modul WITH CONTROL zc2p_lider_crtl.
MODULE read_table_control.
ENDLOOP.
MODULE user_command_0101.
error :
In the event PROCESS AFTER INPUT, no additions are allowed with "LOOP
AT". -
Module Pool - Table Control - Data not getting displayed in Control
Hi,
I have a table contol in my module pool program. In my processing I am filling an internal table & then in my PBO I am linking the internal table to table control. The issue is that even though the internal table is getting filled correctly (found through debugging), the data is not getting populated in table control. Nothing is populated on screen. I am writing part of code below
Declaration:
Types: begin of ty_control,
SELECTED TYPE C,
TEXT TYPE DPR_CAUSE_T-TEXT,
end of ty_control.
CONTROLS : TBL_CONT TYPE TABLEVIEW USING SCREEN '9001'.
DATA: lt_table_cont type TABLE OF ty_control with header line.
Fields in TBL_CONT:
TBL_CONT-SELECTED
TBL_CONT-TEXT
PBO Flow Logic:
MODULE STATUS_9001.
MODULE fill_data.
LOOP AT lt_table_cont WITH CONTROL TBL_CONT cursor TBL_CONT-top_line.
ENDLOOP.
PAI Flow Logic:
Loop at lt_table_cont.
MODULE UPDATE_DATA.
endloop.
MODULE USER_COMMAND_9001.
PLZ let me know what might be the problem. I have been trying to figure out but cant.
Thanks.Hi Sonali,
When ever you need to do anything with the table control, i mean if u want to display data in table control or you want to validate the data entered in table control Should be done within Loop and Endloop.(PBO or PAI's which ever is appropriate)
Here the data is not bieng displayed in ur table control because you have not used the MODULE fill_data between
LOOP AT lt_table_cont WITH CONTROL TBL_CONT cursor TBL_CONT-top_line.
ENDLOOP.
so do it like this
LOOP AT lt_table_cont WITH CONTROL TBL_CONT cursor TBL_CONT-top_line.
MODULE fill_data
ENDLOOP.
this will solve your problem.
Regards,
Syed -
Hi Techies ,
In module pool am not able to validate the checkbook field that i have included in the table control screen .
i was able to pass the other field defined in the same structure where checkbox field is declared .Hi MAX and Glen ,
Thanks for ur answers .
i was not the one developing and i didnt had much touch in TBCL.
Anyways issue resolved , it was sitting outside of TBCL hence i deleted and created new and included the CHK .
now its working .
Positive and quick gestures from you both . -
What is the use of table control in bdc is it same in module pool table con
Hi,
What is the use of table control in bdc is it same in module pool table control?
regards
eswarHi,
Table control means it contains as table and it will scroll in vertical and horizontal.
In module pool by using screen we can create new table control.
But BDC table control means here we can populate the data into the table control.
i.e.if you take VA01 for sales order creation in the belwo of VA01 screen there is table control for the filling of material details so here we will write the code to populate the data into the table control screen.
Thanks and regards,
shyla -
How to control "hide/show" in a table on row level
I was trying to implement controlling/rendering of "hide/show" in a table on row level, but no luck. Is is possible to render the "hide/show" in a table based on the row attribute? If the row attribute is "true", then render the "hide/show" at that row; If the row attribute is "false", then not render the "hide/show" for that row. Is this feasible? Thanks.
I think this should be possible, what u need to do is as follows:
1) Add a decode statement to your VO query to get 0/1 based on your condition like
decode('',true,0,1) render_flag
2) In VO attrinute mappings caste this attribute as boolean instead of number.
3) Attach this attribute to render flag of hide/show via SPEL.
--Mukul -
Function module for table control
Hi experts,
I am creating the BDC program, In that I need to select the particular item from the table control say for example item 0010 or 0020 based on the input file and need to process from there.
Is there any function module to select the particular item by passing item no say 0010 or 0020.
Thanks in advance
saiHi
I suppose there is no function module for table control.
below solution might be useful to you.
1) Do BDC recording for the table control with each condition you would like to incorporate in your program.
2) copy the code of Table Control recording in your program and place the code in Loop of internal table.
3) based on the condition call the respective BDC recording of the table control
4) By the above steps you can manage the table control based on the condition.
Regards
Santosh Kumaar.M -
How to make table control rows dynamic/unlimited using TC with Wizard
Hi Friends ,
I have designed a table control layout using table control with wizard.
Now the problem is when we design a TC layout ,then we have to design it on the page . The page has upper & lower limits. so the maximum size & maximum rows in layout is limited. I have tried to create a TC layout with maximum size & maximum rows . Maximum rows created in Layout is 25.
Now suppose if enduser wants 100 entries to enter by coping a file of 100 records in my TC present on entry screen , then ONLY 25 entries are displayed on entry scren before doing any user action or saving and after saving only these 25 entries are sved in DB. Means enrtries from 26 to 100 are not displayed on entry screen or saved in DB.
So my requirement is to display all 100 entries at a time in entry screen before saving with scrolling up & down facility and these 100 entries should also get saved in DB after clicking save button. In short I want dynamic entry screen table control which can show/dieplay Any Number . of entries whatever the number may be entered by enduser .
Plz note that I have used all 3 facilliteis i.e.
1. Scrolling
2. INSERT/DELETE
3. SELECT/DESELECT
while designing TC with wizard .
Scrolling buttons like FIRST PAGE, PREV. PAGE, NEXT PAGE, LAST PAGE are displayed.
BUT they are not functioning though there is system generated code present in both MPP and in PBO & PAI. After clicking any of them , data which is dislaying on entry screen ( Here it is 25 entries ) is getting cleared/disappeared from enry entry screen.
Waiting for ur response & solutions.
Thanks & Regards,
SudhirHi Ashish ,
Do one thing .
At PAI of screen holding TC , there is module name tc_mark on request .
in this module , there is work area declared g_tc_wa .
Now go to tc_init module of pbo , where u have given your select command .
select * from ........................................
use this code .
if g_tc_wa is initial .
SELECT * FROm
g_tc_wa = 'X'.
REFRESH CONTROL 'TC' FROM SCREEN dynnr.
ENDIF.
Just do this , m sure all buttons, insert, delete , scroll bar.. everything will work . -
Reg : Table control row settings to change mode
Hi geeks.
I am working on a requirement where the table control has to be in display mode at the time of prepopulating(initial display).This works fine and could get all columns in display mode for which i used column properties of table control. I could select a row from the table control and created a button above the table control for copy of the row which is added to the last row of the TC. I could get this with out any issues. They want the added row to be in changed mode whereas the other rows selected previously should remain in the display mode. Can anybody help me out to solve.Timely help will be appreciated <removed by moderator>
Regards ,
Kumar.
Edited by: Vinod Kumar on Aug 2, 2011 9:21 AMThis thread will assist you.
[Table control with non editable rows;
Make use of some flag for identifying the new records that will be appended in itab on the press of the button.
Then in PBO,
loop at itab with control tc cursor tc-current_line.
module editnewrow.
endloop.
module editnewrow output.
if itab-flag = 'X'.
loop at screen.
screen-input = 1.
modify screen.
endloop.
itab-flag = ' '. (resetting back to non-editable state for consequent press of the button)
modify itab index tc_4000-current_line.
endif.
endmodule. -
Module Pool (tabstrip control Error : )
I am trying to activate tabstrip control in module pool but error is coming like no sub screen is assigned to tabstrip pushbutton
tab12.
my main screen is : 0221
flow logic for 0221 is below :
PROCESS BEFORE OUTPUT.
CALL SUBSCREEN SUB1 INCLUDING SY-REPID '0321'.
CALL SUBSCREEN SUB2 INCLUDING SY-REPID '0322'.
PROCESS AFTER INPUT.
CALL SUBSCREEN SUB1.
CALL SUBSCREEN SUB2.
MODULE USER_COMMAND_0221.
and 0321 and 0322 is subscreen and i also gave ref field sub1 and sub2 .
can you plz help me to solve the problem ?Hi,
yes i created sub screen. i am going to explain what i have done .
step : i created screen 200 (i choose subscreen)and inside 200 i put tabstripcontrol then in tab1 i gave ref field sub1 and tab2 i gave ref field sub2 and fatch code ic1 and ic2.
and then i created screen 221 and 222.
inside 200 flow logic i wrote below code but still its giving me same error.
PROCESS BEFORE OUTPUT.
CALL SUBSCREEN SUB1 INCLUDING SY-REPID '0221'.
CALL SUBSCREEN SUB2 INCLUDING SY-REPID '0222'.
PROCESS AFTER INPUT.
CALL SUBSCREEN SUB1.
CALL SUBSCREEN SUB2.
MODULE USER_COMMAND_0221.
i dont know is it required to make any normal screen .
please try to give me ans as soon as possible. -
Table Rendering - Row level vs Column level
Normally renderers are specified for a given class of data or column of data.
So, how would you handle rendering requirements that are row or table dependent? For example, how do I:
a) color alternate lines in a table
b) change the border of the selected cell
Traditional Approach
Most answers in the forum would be something like "use a custom render". Sounds great, but what does it really mean? If all your data is displayed as a String then it really isn't too difficult to create a single renderer with the required logic and add it to the table as the default renderer.
However, what if you table contains, String's, Dates, Integer's, Double's and Boolean's and you want your cell to retain the default formatting of each data type in addition to the above requirement? Now you have two options:
a) render by class (multiple renderers). Each renderer would need to implement the default "formatting" of the data (dates: dd-MMM-yyy, numbers: right justified, etc) in addition to the "row/table" rendering requirements. So the answer really becomes "use five custom renderers". Now the "row/table" rendering code is found in 5 classes. Of course you could always move the "row/table" rendering code up to a common base class.
b) render by table (single renderer). A single custom renderer would be created and would need to implement the default "formatting" for all data types in the table, in addition to the "row/table" rendering. The benefit is that all the rendering code is in one class. An example solution is include for this approach.
Alternative Approach
I recently came across an approach where the "formatting" of the data is still done by the default renderers and the "row/table" rendering is done at the table level by overriding the prepareRenderer() method. This approach is much simpler, but the rendering is done in two different places. Is this a problem?
So, my question is which approach do you prefer:
a) Traditional Approach - multiple renderers
b) Triditional Approach - single renderer
c) Alternative Approach
Me, I like the alternative approach, but I'm more of a problem solver than I am a designer, so I don't know how the solution fits in a large scale application.
Hopefully your response will consider:
a) OO design principles
b) class reusability
c) class maintenance
d) anything else you can think of
import java.awt.*;
import java.text.*;
import java.util.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.table.*;
public class TableRowRendering extends JFrame
JTable table;
Border selected = new LineBorder(Color.GREEN);
public TableRowRendering()
// Model used by both tables
Object[] columnNames = {"Type", "Date", "Company", "Shares", "Price"};
Object[][] data =
{"Buy", new Date(), "IBM", new Integer(1000), new Double(80.50)},
{"Sell",new Date(), "MicroSoft", new Integer(2000), new Double(6.25)},
{"Sell",new Date(), "Apple", new Integer(3000), new Double(7.35)},
{"Buy", new Date(), "Nortel", new Integer(4000), new Double(20.00)}
DefaultTableModel model = new DefaultTableModel(data, columnNames)
public Class getColumnClass(int column)
return getValueAt(0, column).getClass();
// Traditional Approach
table = new JTable( model );
table.setPreferredScrollableViewportSize(table.getPreferredSize());
getContentPane().add(new JScrollPane( table ), BorderLayout.WEST);
TableCellRenderer custom = new CustomRenderer();
table.setDefaultRenderer(Object.class, custom);
table.setDefaultRenderer(String.class, custom);
table.setDefaultRenderer(Date.class, custom);
table.setDefaultRenderer(Number.class, custom);
table.setDefaultRenderer(Double.class, custom);
// Alternative Approach
table = new JTable( model )
public Component prepareRenderer(
TableCellRenderer renderer, int row, int column)
Component c = super.prepareRenderer(renderer, row, column);
if (!isRowSelected(row))
String type = (String)getModel().getValueAt(row, 0);
c.setBackground(row % 2 == 0 ? null : Color.LIGHT_GRAY );
if (isRowSelected(row) && isColumnSelected(column))
((JComponent)c).setBorder(selected);
return c;
table.setPreferredScrollableViewportSize(table.getPreferredSize());
getContentPane().add(new JScrollPane( table ), BorderLayout.EAST);
// Custom renderer used by Traditional approach
class CustomRenderer extends DefaultTableCellRenderer
DateFormat dateFormatter = SimpleDateFormat.getDateInstance(DateFormat.MEDIUM);
NumberFormat numberFormatter = NumberFormat.getInstance();
public Component getTableCellRendererComponent(
JTable table, Object value, boolean isSelected,
boolean hasFocus, int row, int column)
super.getTableCellRendererComponent(
table, value, isSelected, hasFocus, row, column);
// Code for data formatting
setHorizontalAlignment(SwingConstants.LEFT);
if ( value instanceof Date)
setText(dateFormatter.format((Date)value));
if (value instanceof Number)
setHorizontalAlignment(SwingConstants.RIGHT);
if (value instanceof Double)
setText(numberFormatter.format(((Number) value).floatValue()));
// Code for highlighting
if (!isSelected)
String type = (String)table.getModel().getValueAt(row, 0);
setBackground(row % 2 == 0 ? null : Color.LIGHT_GRAY );
if (table.isRowSelected(row) && table.isColumnSelected(column))
setBorder(selected);
return this;
public static void main(String[] args)
TableRowRendering frame = new TableRowRendering();
frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
frame.pack();
frame.setLocationRelativeTo( null );
frame.setVisible(true);
}Before you make your final decision. What changes would be required for each solution in the following "what if " scenarios:
a) what if, you added a Boolean column to the table
b) what if, you added a second Double column to the table which should be formatted as a currency (ie. 1,234.5 --> $1,234.50).
Here is an example of a currency renderer:
class CurrencyRenderer extends DefaultTableCellRenderer
private NumberFormat formatter;
public CurrencyRenderer()
super();
formatter = NumberFormat.getCurrencyInstance();
setHorizontalAlignment( SwingConstants.RIGHT );
public void setValue(Object value)
if ((value != null) && (value instanceof Number))
value = formatter.format(value);
super.setValue(value);
}Well, here's a partila solution using technique from a link you cited in another thread.
import tests.basic.tables.ColorProvider;
import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;
import java.text.NumberFormat;
public class DecoratedTablePrepareRenderer extends JFrame {
JTable table;
private DefaultTableModel model;
public DecoratedTablePrepareRenderer() {
Object[] columnNames = {"Type", "Company", "Price", "Shares", "Closed"};
Object[][] data =
{"Buy", "IBM", new Double(80.50), new Double(1000), Boolean.TRUE},
{"Sell", "MicroSoft", new Double(6.25), new Double(2000), Boolean.FALSE},
{"Sell", "Apple", new Double(7.35), new Double(3000), Boolean.TRUE},
{"Buy", "Nortel", new Double(20.00), new Double(4000), Boolean.FALSE}
model = new DefaultTableModel(data, columnNames);
table = new JTable(model) {
// Returning the Class of each column will allow different
// renderers to be used based on Class
public Class getColumnClass(int column) {
return getValueAt(0, column).getClass();
public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
Component c = super.prepareRenderer(renderer, row, column);
if (isRowSelected(row))
c.setFont(c.getFont().deriveFont(Font.BOLD));
return c;
ColorProvider prov = new TransactionColorProvider();
ColorTableCellRenderer renderer = new ColorTableCellRenderer(table.getDefaultRenderer(Object.class),prov);
ColorTableCellRenderer boolrenderer = new ColorTableCellRenderer(table.getDefaultRenderer(Boolean.class),prov);
ColorTableCellRenderer doublerenderer = new ColorTableCellRenderer(table.getDefaultRenderer(Double.class),prov);
int priceIndex = model.findColumn("Price");
table.getColumnModel().getColumn(priceIndex).setCellRenderer( new EtchedBorderTableCellRenderer(new ColorTableCellRenderer(new CurrencyRenderer(),prov) ));
table.setDefaultRenderer(Object.class,new EtchedBorderTableCellRenderer(renderer));
table.setDefaultRenderer(Double.class,new EtchedBorderTableCellRenderer(doublerenderer));
table.setDefaultRenderer(Boolean.class, new EtchedBorderTableCellRenderer(boolrenderer));
JScrollPane scrollPane = new JScrollPane(table);
getContentPane().add(scrollPane);
class CurrencyRenderer extends DefaultTableCellRenderer {
private NumberFormat formatter;
public CurrencyRenderer() {
super();
formatter = NumberFormat.getCurrencyInstance();
setHorizontalAlignment(SwingConstants.RIGHT);
public void setValue(Object value) {
if ((value != null) && (value instanceof Number)) {
value = formatter.format(value);
super.setValue(value);
public static void main(String[] args) {
DecoratedTablePrepareRenderer frame = new DecoratedTablePrepareRenderer();
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
class ColorTableCellRenderer implements TableCellRenderer{
protected TableCellRenderer delegate;
protected ColorProvider provider;
public ColorTableCellRenderer(TableCellRenderer delegate, ColorProvider provider) {
this.delegate = delegate;
this.provider = provider;
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Component c = delegate.getTableCellRendererComponent(table, value,isSelected,hasFocus,row, column);
c.setBackground(provider.getBackgroundColor(row, column));
return c;
class EtchedBorderTableCellRenderer implements TableCellRenderer{
protected TableCellRenderer delegate;
public EtchedBorderTableCellRenderer(TableCellRenderer delegate) {
this.delegate = delegate;
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
JComponent c = (JComponent)delegate.getTableCellRendererComponent(table, value,isSelected,hasFocus,row, column);
JPanel panel = new JPanel(new GridLayout(0,1));
panel.add(c);
panel.setBorder(BorderFactory.createEtchedBorder());
return panel;
class TransactionColorProvider implements ColorProvider {
private int keyIndex = 0;
private Color sellColor = Color.yellow;
private Color buyColor = Color.green;
public TransactionColorProvider() {
keyIndex = model.findColumn("Type");
public Color getBackgroundColor(int row, int column) {
if( model.getValueAt(row,keyIndex).equals("Sell")){
return sellColor;
else {
return buyColor;
public Color getForegroundColor(int row, int column) {
return Color.black;
}Boolean values are problematical since JCheckBox does seem to like borders, using a panel as I did in the Etched renderer seems to work. This solution need a little more work, this is submitted as a prototype
Cheers
DB -
Hi,
Cany any one tell me with example how we will use the customccontrols in module pool program..Why it is usedI got answer, i am using same editor for displaying all the custom controls.
i.e. was the problem.
anyway Thanks for looking into this issue. -
Making 10 table control rows to be displayed always
Dear All,
How to make a table control display 10 lines always..?Hi,
Thanks for the response
I have 3 table controls in a single screen. Each will have minimum 7-10 rows ( filled data ). I need to display all the table with all the rows visible to the user without scrolling.
At present though I define the lines as 10 for each table they are getting adjusted to 4 lines per table and getting fit to the screen.
But what I need is irrespective of the size of the monitor it should display all the tables with all the data. The screenmay have the scroll but not the tablecontrol.
for e.g
Table 1 Actual data is
1 flight
2 Train
3 Car
4 Flight
5 Hotel
6 Other
7 Car
But it is displayed as with scroll option for table control
1 flight
2 Train
3 Car
4 Flight
I need it to be displayed as irrespective of the size of monitor
1 flight
2 Train
3 Car
4 Flight
5 Hotel
6 Other
7 Car
Please help.
Regards
Sai
Maybe you are looking for
-
Obtain the determinat​e data from the NI-DAQmx Simulated Device
Dear All, How to config in MAX in order to obtain the determinate data from the NI-DAQmx Simulated Device? For example, the vi will run when the Digital I/O line is High, but using the Simulated Device, the result is random. In another
-
Small Home Network.........
I have a AEBS serving up for my wife's i-Book wirelessly and an i-Mac thru the LAN off the AEBS .I would like to set-up my Dell and another PC slave thru a 5-port Linksys switch to recieve my Verizon DSL also. Could I send the DSL straight to the swi
-
Efficiently retrieving only a set of records ... ?
Hi, Ours is web centric small-scale ERP. We have lot of reports which display data by pages. While retrieving records we are using the following type of SQLs: select col1,col2,.... from ( select rownum srno, col1, col2, ... from tables where ...) whe
-
Problems saving channel strips...
When I try to save a channel strip, I'm told "Permission was denied, probably due to insufficient access rights". I've tried repairing permissions already. I haven't moved anything to where it shouldn't be (ie, my Channel Strip Settings folder is rig
-
Hi, I need to print date in the following format: Jan 21, 2007 11:23 AM 21/01/2007 21-01-2007 18:23 Now as per condition of assignment the year, month, day and hour, min, sec all are entered as separate integer values. my code: import java.util.*; im