Locked table columns in JTable?
Does anyone know if a JTable can implement locked columns? By which I mean, I'd like to nominate 1 or more columns that remain locked to the left (or even right) of the table display and don't scroll out of view when scrolling horizontally.
I can imagine some round-about ways of doing it, but I wonder if there's a simple way to do it.
Thanks
Iain
Here is my attempt at this:
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
public class FixedColumnScrollPane extends JScrollPane
public FixedColumnScrollPane(JTable main, int fixedColumns)
super( main );
// Use the table to create a new table sharing
// the DataModel and ListSelectionModel
JTable fixed = new JTable( main.getModel() );
fixed.setSelectionModel( main.getSelectionModel() );
fixed.getTableHeader().setReorderingAllowed( false );
fixed.getTableHeader().setResizingAllowed( false );
fixed.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
main.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
// Remove the fixed columns from the main table
for (int i = 0; i < fixedColumns; i++)
TableColumnModel columnModel = main.getColumnModel();
columnModel.removeColumn( columnModel.getColumn( 0 ) );
// Remove the non-fixed columns from the fixed table
while (fixed.getColumnCount() > fixedColumns)
TableColumnModel columnModel = fixed.getColumnModel();
columnModel.removeColumn( columnModel.getColumn( fixedColumns ) );
// Add the fixed table to the scroll pane
fixed.setPreferredScrollableViewportSize(fixed.getPreferredSize());
setRowHeaderView( fixed );
setCorner(JScrollPane.UPPER_LEFT_CORNER, fixed.getTableHeader());
public static void main(String[] args)
// Build your table normally
JTable table = new JTable(10, 8);
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
JScrollPane scrollPane= new FixedColumnScrollPane(table, 2 );
JFrame frame = new JFrame("Table Fixed Column Demo");
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
frame.getContentPane().add( scrollPane );
frame.setSize(400, 300);
frame.setVisible(true);
}
Similar Messages
-
How to create a dynamic table were the JTable columns keep varying
How to create a dynamic table were the JTable columns keep varying based on the input to the jtable
Oooh, I lied. DefaultTableModel has an API for adding and
removing columns. I didn't know that. You should have read
the API.
As for preferring to extend AbstractTableModel rather than
DefaultTableModel, I think it's more correct. DefaultTableModel
is a simple implementation of Abstract for basic cases. It isn't
intended to be extended. I figure most people extending
DefaultTableModel are also extending JFrame, JPanel, and Thread
instead of encapsulating the first two and implementing
Runnable for the third. -
Width of table column in a JTable
I am not able to set the default width of table column.
To set the width I need to call setPreferredWidth(),
setMaxWidth() setMinWidth() but after doing this I can
not resize the column
Any clue what I am doing wrong.if you set min and max then you can not change anymore, thats the way it is,
just take setPreferredWidth() and if the table then does not look like you want it to look default, change the sizes of the panels and/ or scrollpanes around the table -
I have see a lots of examples of whow to create fix column into JTable.
But all the examples have the same problems.
When I wont to scroll over the fix column the vertical scroll bar of the no fix column dont move, so the no fix column dose not move and the fix columns and no fix columns aren?t alined.
If sameone have same example, send it please !!!!
Thanks !!!
PabloIn a recent project I've had the same problem.
After a long research at the Swing forum at java.sun.org and google I found out that
1. Currently there is no proper Open Source solution
2. All the postings at sun are good concepts, but far away from solutions
3. The only (for me )acceptable commercial solution is the JCTable from Quest (formerly KGroup)
Since I want to have full control over the source code of the table, I decided to collect all the tips from this forums and write my own table.
Here is a first try:
http://jroller.com/resources/kriede/CoolTable.java
The main idea is to have two tables, one for the locked columns (= fixed columns = frozen columns) and one for the scrollable columns. With all the tips from this forum it was more or less a puzzle to make it work pretty. -
How to set different renderers to different cells in same column of JTable?
Hello Friends,
I need your help again...
Does any body knows, how to set different renderer's for different cells of same column in JTable..??
For ex.
Col1 Col2 Col3 Col4
A A A A
A A A B
A A A C
A A A D
Where A B C D would be different Renderers. I want set exactly same ,,, ie. one column with different renderer at different cell positions..
Right now i m setting renderer using statement bellow :
table.getColumnModel().getColumn(int).setCellRenderer(rederer_Instance);But with this, effect in the last renderer is applicable whole column....
Can any body help me out ?????????
please refer this thread for similar kind of discussion...
http://forums.sun.com/thread.jspa?forumID=57&threadID=571445Thanks
SuyogPlease refer to the first reply of [this thread|http://forums.sun.com/thread.jspa?forumID=57&threadID=571445] for the answer. If you have a specific problem implementing it, post you code with a specific question.
-
Add and remove columns from JTable
Help me please!
A try to remove column from JTable. It's removed, but when I try to add column in table, then I get all old (removed early) columns + new column....
I completely confused with it.....
Here is my code for remove column:
class DelC implements ActionListener
public void actionPerformed (ActionEvent e )
int [] HowManyColDelete = table.getSelectedColumns();
if (HowManyColDelete.length !=0)
TableColumnModel tableCModel = table.getColumnModel();
for (int i = HowManyColDelete.length-1; i>-1; i--)
table.getColumnModel().removeColumn (tableCModel.getColumn (HowManyColDelete [ i ]));
else
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "Column is not selected!");
}It's little ex for me, I just try understand clearly how it's work (table models i mean). Here is code. All action with tables take place through menu items.
My brain is boiled, I've try a lot of variants of code, but did't get right result :((
It's code represent problem, which I've describe above. If you'll try remove column and then add it again, it will be ma-a-a-any colunms...
I understand, that my code just hide columns, not delete from table model....
But now I have not any decision of my problem...
Thanks a lot for any help. :)
import javax.swing.*;
import java.awt.*;
import javax.swing.table.*;
import java.awt.event.*;
import javax.swing.table.DefaultTableModel;
class JTableF extends JFrame
Object [] [] data = new Object [0] [2];
JTable table;
DefaultTableModel model;
String [] columnNames = {"1", "2"};
TableColumnModel cm;
JTableF()
super("Table features");
setDefaultLookAndFeelDecorated( true );
setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
JMenuBar MBar = new JMenuBar();
JMenu [] menus = {new JMenu("A"), new JMenu("B")};
JMenuItem [] menu1 = {new JMenuItem("Add row"), new JMenuItem("Delete row", 'D'), new JMenuItem("Add column"), new JMenuItem("Delete column")};
menu1 [ 0 ].addActionListener(new AddL());
menu1 [ 1 ].addActionListener(new DelL());
menu1 [ 2 ].addActionListener(new AddC());
menu1 [ 3 ].addActionListener(new DelC());
for (int i=0; i<menu1.length; i++)
menus [ 0 ].add( menu1 [ i ]);
for (int i=0; i<menus.length; i++)
MBar.add(menus );
JPanel panel = new JPanel ();
model = new DefaultTableModel( data, columnNames );
table = new JTable (model);
cm = table.getColumnModel();
panel.add (new JScrollPane(table));
JButton b = new JButton ("Add row button");
b.addActionListener(new AddL());
panel.add (b);
setJMenuBar (MBar);
getContentPane().add(panel);
pack();
setLocationRelativeTo (null);
setVisible (true);
class DelC implements ActionListener
public void actionPerformed (ActionEvent e )
int [] HowManyColDelete = table.getSelectedColumns();
if (HowManyColDelete.length !=0)
TableColumnModel tableCModel = table.getColumnModel();
for (int i = HowManyColDelete.length-1; i>-1; i--)
int vizibleCol = table.convertColumnIndexToView(HowManyColDelete [ i ]);
tableCModel.removeColumn (tableCModel.getColumn (vizibleCol));
//cm = tableCModel;
else
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "Column is not selected!");
class AddC implements ActionListener
public void actionPerformed (ActionEvent e)
//table.setColumnModel(cm);
Object NewColumnName = new String();
NewColumnName = JOptionPane.showInputDialog ("Input new column name", "Here");
int i = model.getRowCount();
int j = model.getColumnCount();
Object [] newData = new Object [ i ];
model.addColumn ( NewColumnName, newData);
class AddL implements ActionListener
public void actionPerformed (ActionEvent e)
int i = model.getColumnCount();
Object [] Row = new Object [ i ];
model.addRow ( Row );
class DelL implements ActionListener
public void actionPerformed (ActionEvent e)
int [] HowManyRowsDelete = table.getSelectedRows();
if (HowManyRowsDelete.length !=0)
for (int k = HowManyRowsDelete.length-1; k>-1; k--)
model.removeRow (HowManyRowsDelete[k]);
else
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "Row is not selected!");
public static void main (String [] args)
javax.swing.SwingUtilities.invokeLater(new Runnable()
public void run()
JTableF inst = new JTableF(); -
Hello everyone.
I have run into a problem ( once again) that i want to divide the first table column
into two (but with the excepti of the column header ).
Here is what I have tried.
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.GridLayout;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import javax.swing.table.TableModel;
public class ColumnSpanExample extends JFrame{
JTable table;
TableModel dataModel;
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable(){
public void run() {
new ColumnSpanExample();
public ColumnSpanExample(){
buildGUI();
this.pack();
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setLocationRelativeTo(null);
this.setResizable(true);
this.setVisible(true);
private void buildGUI(){
String[][] data={{"asdf:1234","foo"},{"zxcv:5678","bar"}};
String [] columnNames = {"Car","Owner"};
dataModel = new DefaultTableModel(data,columnNames);
table = new JTable(dataModel);
table.setEnabled(false);
TableColumn tc = table.getColumnModel().getColumn(0);
tc.setCellRenderer(new MyTableCellRenderer2());
table.setPreferredScrollableViewportSize(table.getPreferredSize());
JScrollPane sp = new JScrollPane(table);
getContentPane().setLayout(new BorderLayout());
getContentPane().add(sp,BorderLayout.CENTER);
// private class MyTableCellRenderer extends DefaultTableCellRenderer {
// public Component getTableCellRendererComponent(JTable table, Object value,
// boolean isSelected, boolean hasFocus, int row, int column) {
// super.getTableCellRendererComponent(table,value,isSelected,hasFocus,row,column);
// // some tricks in need.
// return this;
private class MyTableCellRenderer2 extends JPanel implements TableCellRenderer {
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
removeAll();
String strValue = value==null? "":value.toString();
String[] part = strValue.split(":");
setLayout(new GridLayout(1,0));
for (int i = 0; i < part.length; i++) {
JLabel lblTmp = new JLabel(part);
lblTmp.setBorder(BorderFactory.createLineBorder(Color.black));
add(lblTmp);
return this;
And i prefer to use the jLabel as the renderer, since it is more light as a render, I thought.
Does anybody has any idea.
Thanks in advance for any reply.You are taking the easy way out. I have done what you suggest since childhood, this is 65 years ago.
Thanks for your answer anyway. Have a great day. -
Serial number column in Jtable
Apologies for this distraction.
I read at this forum about a year ago how to add a s/n column in Jtable such that all the nos are automatically updated/adjusted when a row is added/deleted. the count starts from the top down serially and unaffected by sorting.
pls help!thanks a million BaltimoreJohn and especially camickr whose solutions to problems have been most helpful. applying the referenced post, i worked around the problem by resetting the values of the column having the serial number, based on table rowCount every time there is an operation on it(deleting, addition etc)
-
Programmatically Sorting columns in JTable
Hi,
How can I programmatically sort a particular column in JTable without having to click on column header.
Thanks.to sort the desired column w/o click on header
int columnIndexToSort = 1;
RowSorter.SortKey sortKey = new RowSorter.SortKey(columnIndexToSort,SortOrder.ASCENDING);
ArrayList alist = new ArrayList(1);
alist.add(sortKey);
((DefaultRowSorter)table.getRowSorter()).setSortable(columnIndexToSort , true);
((DefaultRowSorter)table.getRowSorter()).setSortKeys(alist);
((DefaultRowSorter)table.getRowSorter()).sort();expecting dukestars.. -
I wont to hide a elected column in JTable.
how it to doTableColumnModel tcm = table.getColumnModel();
TableColumn column = tcm.getColumn( modelIndex );
tcm.removeColumn( column );
Next time, search the forum first. There are at least a dozen posts asking this question. -
how to lock a column?
pls give one example....You can't lock a column, but lock rows of a table based on changes to a column.
This is done using FOR UPDATE clause
example
SELECT ENAME, SAL
FROM EMP
WHERE DEPTNO = 20
FOR UPDATE OF SALabove query will lock the employee records of department 20, till the lock is released. -
Npe when using popup inside adf table column
hi i have a popup witch is inside adf column table but when i click the button i get this npe error
<af:column id="c7" headerText="Action">
<af:commandButton text="Add" id="cb2">
<af:showPopupBehavior popupId="p1" triggerType="click"/>
</af:commandButton>
<af:panelGroupLayout id="pgl2" inlineStyle="width:1042px;"
layout="horizontal" valign="middle"
halign="right">
<af:popup id="p1" contentDelivery="lazyUncached">
<af:dialog id="d1" type="cancel">
<af:region value="#{bindings.usrtaskflowdefinition1.regionModel}"
id="r1"/>
</af:dialog>
</af:popup>
<af:commandButton text="Cancel" id="cb1" rendered="false"/>
<af:commandButton text="Remove" id="cb3" visible="false"/>
</af:panelGroupLayout>
</af:column>
am geting this NPE ERROR
<FacesCtrlSearchBinding> <release> ADFv: release():: Release all resources.
<ADFLogger> <end> ADF web request
<XmlErrorHandler> <handleError> ADF_FACES-60096:Server Exception during PPR, #1
javax.el.ELException: java.lang.NullPointerException
at javax.el.BeanELResolver.getValue(BeanELResolver.java:266)
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:173)
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:200)
at com.sun.el.parser.AstValue.getValue(Unknown Source)
at com.sun.el.parser.AstEqual.getValue(Unknown Source)
at com.sun.el.parser.AstOr.getValue(Unknown Source)
at com.sun.el.ValueExpressionImpl.getValue(Unknown Source)
at org.apache.myfaces.trinidad.bean.FacesBeanImpl.getProperty(FacesBeanImpl.java:68)
at org.apache.myfaces.trinidad.component.UIXComponentBase.getBooleanProperty(UIXComponentBase.java:1204)
at org.apache.myfaces.trinidad.component.UIXComponentBase.isRendered(UIXComponentBase.java:423)
at org.apache.myfaces.trinidad.component.UIXComponentBase.processValidators(UIXComponentBase.java:810)
at org.apache.myfaces.trinidad.component.UIXEditableValue.processValidators(UIXEditableValue.java:263)
at org.apache.myfaces.trinidad.component.UIXComponentBase.validateChildrenImpl(UIXComponentBase.java:1022)
at org.apache.myfaces.trinidad.component.UIXComponentBase.validateChildren(UIXComponentBase.java:1007)
at org.apache.myfaces.trinidad.component.UIXComponentBase.processValidators(UIXComponentBase.java:814)
at org.apache.myfaces.trinidad.component.UIXComponentBase.validateChildrenImpl(UIXComponentBase.java:1022)
at org.apache.myfaces.trinidad.component.UIXComponentBase.validateChildren(UIXComponentBase.java:1007)
at org.apache.myfaces.trinidad.component.UIXComponentBase.processValidators(UIXComponentBase.java:814)
at org.apache.myfaces.trinidad.component.UIXComponentBase.validateChildrenImpl(UIXComponentBase.java:1022)
at org.apache.myfaces.trinidad.component.UIXComponentBase.validateChildren(UIXComponentBase.java:1007)
at org.apache.myfaces.trinidad.component.UIXComponentBase.processValidators(UIXComponentBase.java:814)
at org.apache.myfaces.trinidad.component.UIXComponentBase.validateChildrenImpl(UIXComponentBase.java:1022)
at org.apache.myfaces.trinidad.component.UIXComponentBase.validateChildren(UIXComponentBase.java:1007)
at org.apache.myfaces.trinidad.component.UIXComponentBase.processValidators(UIXComponentBase.java:814)
at org.apache.myfaces.trinidad.component.UIXComponentBase.validateChildrenImpl(UIXComponentBase.java:1022)
at org.apache.myfaces.trinidad.component.UIXComponentBase.validateChildren(UIXComponentBase.java:1007)
at org.apache.myfaces.trinidad.component.UIXComponentBase.processValidators(UIXComponentBase.java:814)
at org.apache.myfaces.trinidad.component.UIXComponentBase.validateChildrenImpl(UIXComponentBase.java:1022)
at org.apache.myfaces.trinidad.component.UIXComponentBase.validateChildren(UIXComponentBase.java:1007)
at org.apache.myfaces.trinidad.component.UIXComponentBase.processValidators(UIXComponentBase.java:814)
at org.apache.myfaces.trinidad.component.UIXComponentBase.validateChildrenImpl(UIXComponentBase.java:1022)
at org.apache.myfaces.trinidad.component.UIXComponentBase.validateChildren(UIXComponentBase.java:1007)
at org.apache.myfaces.trinidad.component.UIXComponentBase.processValidators(UIXComponentBase.java:814)
at org.apache.myfaces.trinidad.component.UIXComponentBase.validateChildrenImpl(UIXComponentBase.java:1022)
at oracle.adf.view.rich.component.fragment.UIXRegion.validateChildrenImpl(UIXRegion.java:634)
at org.apache.myfaces.trinidad.component.UIXComponentBase.validateChildren(UIXComponentBase.java:1007)
at org.apache.myfaces.trinidad.component.UIXComponentBase.processValidators(UIXComponentBase.java:814)
at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl$ProcessValidationsCallback.invokeContextCallback(LifecycleImpl.java:1422)
at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnNamingContainerComponent(UIXComponentBase.java:1358)
at oracle.adf.view.rich.component.fragment.UIXRegion.invokeOnComponent(UIXRegion.java:555)
at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnChildrenComponents(UIXComponentBase.java:1330)
at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnComponent(UIXComponentBase.java:1424)
at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnChildrenComponents(UIXComponentBase.java:1330)
at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnComponent(UIXComponentBase.java:1424)
at oracle.adf.view.rich.component.rich.RichDocument.invokeOnComponent(RichDocument.java:168)
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:720)
at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:678)
at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:407)
at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:194)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:205)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:106)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446)
at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:271)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:177)
at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.adf.library.webapp.LibraryFilter.doFilter(LibraryFilter.java:179)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:119)
at java.security.AccessController.doPrivileged(Native Method)
at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:315)
at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:442)
at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:103)
at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:171)
at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:139)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
Caused by: java.lang.NullPointerException
at oracle.adf.model.binding.DCControlBinding.reportException(DCControlBinding.java:201)
at oracle.jbo.uicli.binding.JUCtrlValueBinding.findAttributeDef(JUCtrlValueBinding.java:632)
at oracle.jbo.uicli.binding.JUCtrlValueBinding.findAttributeDef(JUCtrlValueBinding.java:597)
at oracle.jbo.uicli.binding.JUCtrlValueBinding.getAttribute(JUCtrlValueBinding.java:1341)
at oracle.adfinternal.view.faces.model.binding.FacesCtrlSearchBinding$AdfAttributeCriterion.getOperator(FacesCtrlSearchBinding.java:2240)
at sun.reflect.GeneratedMethodAccessor357.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:261)
... 87 more
<QueryCollection> <finalize> [4342] ##### QueryCollection.finl no RowFilter
<QueryCollection> <finalize> [4343] ##### QueryCollection.finl oracle.jbo.Key[Surname 0 0 ]
<QueryCollection> <finalize> [4344] ##### QueryCollection.finl oracle.jbo.Key[Firstname 0 0 ]
<ControllerState> <finalizeRequest> ADFc: Request number [9] for session [14gycvxp1h_] has been finalized.
<QueryCollection> <finalize> [4345] ##### QueryCollection.finl oracle.jbo.Key[Username 0 0 ]
<RootViewPortContextImpl> <unlockViewPortRequestLock> ADFc: Attempting to release RootViewPort request lock on 14gycvxp1h_0
<QueryCollection> <finalize> [4346] ##### QueryCollection.finl oracle.jbo.Key[Organisationname 0 0 ]
<QueryCollection> <finalize> [4347] ##### QueryCollection.finl oracle.jbo.Key[Surname 0 0 ]
<RootViewPortContextImpl> <unlockViewPortRequestLock> ADFc: Successfully released RootViewPort request lock on 14gycvxp1h_0
<QueryCollection> <finalize> [4348] ##### QueryCollection.finl oracle.jbo.Key[Firstname 0 0 ]
<QueryCollection> <finalize> [4349] ##### QueryCollection.finl oracle.jbo.Key[Username 0 0 ]
<Auditor> <isEnabled> IAU:Event Enabled : false, Event Type : CheckPermission, Event Status : true, Properties : null
<QueryCollection> <finalize> [4350] ##### QueryCollection.finl oracle.jbo.Key[Organisationname 0 0 ]
<QueryCollection> <finalize> [4351] ##### QueryCollection.finl no RowFilter
<QueryCollection> <finalize> [4352] ##### QueryCollection.finl no RowFilter
<Auditor> <isEnabled> IAU:Event Enabled : false, Event Type : CheckPermission, Event Status : true, Properties : null
<QueryCollection> <finalize> [4353] ##### QueryCollection.finl no RowFilter
<QueryCollection> <finalize> [4354] ##### QueryCollection.finl no RowFilter
<QueryCollection> <finalize> [4355] ##### QueryCollection.finl no RowFilter
<QueryCollection> <finalize> [4356] ##### QueryCollection.finl no RowFilter
<QueryCollection> <finalize> [4357] ##### QueryCollection.finl no RowFilter
<QueryCollection> <finalize> [4358] ##### QueryCollection.finl no RowFilter
<QueryCollection> <finalize> [4359] ##### QueryCollection.finl no RowFilter
<QueryCollection> <finalize> [4360] ##### QueryCollection.finl no RowFilter
<QueryCollection> <finalize> [4361] ##### QueryCollection.finl no RowFilter
<QueryCollection> <finalize> [4362] ##### QueryCollection.finl no RowFilter
<QueryCollection> <finalize> [4363] ##### QueryCollection.finl no RowFilter
<QueryCollection> <finalize> [4364] ##### QueryCollection.finl no RowFilter
<AbstractExecutionContext> <getECForJDBC> adding new ECForJDBC null to set of listeners for this context
<WatchingDocumentChangeNotifier> <run> decide if checkUsingListeners should run. loopCnt: 0 changeInterval: 60000 originalChangeInterval: 60000 forceCheckForUpdate: false notifier instance: oracle.as.config.notification.filesystem.WatchingDocumentChangeNotifier@ca7192
<WatchingDocumentChangeNotifier> <checkUsingListeners> BEGIN checkUsingListeners for notifier instance: oracle.as.config.notification.filesystem.WatchingDocumentChangeNotifier@ca7192
<WatchingDocumentChangeNotifier> <checkUsingListeners> notifier processing file: C:\Users\10017134\AppCaused by: java.lang.NullPointerException
at oracle.adf.model.binding.DCControlBinding.reportException(DCControlBinding.java:201)
at oracle.jbo.uicli.binding.JUCtrlValueBinding.findAttributeDef(JUCtrlValueBinding.java:632)
at oracle.jbo.uicli.binding.JUCtrlValueBinding.findAttributeDef(JUCtrlValueBinding.java:597)
at oracle.jbo.uicli.binding.JUCtrlValueBinding.getAttribute(JUCtrlValueBinding.java:1341)
at oracle.adfinternal.view.faces.model.binding.FacesCtrlSearchBinding$AdfAttributeCriterion.getOperator(FacesCtrlSearchBinding.java:2240)
It seems that problem is caused by af:query or quickquery component(or underlying view object or view criteria).
Maybe you can drop BTF as static region directly to your page and see if this will run correctly?
YES i have try stll does not work
So then this is not related with "npe when using popup inside adf table column"
Dario -
To setup scrollbars for individual columns in JTable
Hi,
I need to setup individual scrollbars for the
columns in JTable.
Can anybody help?
Thanks in advance.
Rgds,
sitaHi,
I need to setup individual scrollbars for the
columns in JTable.If i understand you correctly, you want to have a scrollbar for every column. If so, you will need a new instance of JTable and JScrollPane for every column, but that's a lot of work if you want to do it fancy.
The good news, is you can reuse the table model.
You could do something like that.
for (int i= 0; i < model.getColumnCount(); i++) {
JTable table = new JTable();
table.setAutoCreateColumnsFromModel(false);
//container
someContainer.add(new ScrollPane(table), null/* or some layout constrains*/);
TableColumn tc = new TableColumn(i, 120);
tc.setHeaderValue(model.getColumnName(i));
table.addColumn(tc);
Can anybody help?
Thanks in advance.
Rgds,
sita -
Hiding and restoring table columns from file?
how i handle hiding and unhiding columns in a jtable is that i have a checkbox for each column, depending on which is checked "on" the tablecolumn is found and added to a vector and removed from the table.
when the checkbox is checked "off" this vector is searched for the correct tablecolumn, and then added back to the table. this works fine.
when i close out of the program, i go thru the table and write the visible column names along with its size to file.
when i re-open the program, i create the table normally, then go thru the file and hide(remove) the tablecolumns found in it..this works fine.
but when i go back to this checkbox list and try to unhide the tablecolumn, i get an exception
java.lang.IllegalArgumentException: Cannot format given Object as a Number
at java.text.NumberFormat.format(NumberFormat.java:219)
at java.text.Format.format(Format.java:133)
at javax.swing.JTable$DoubleRenderer.setValue(JTable.java:3397)
at javax.swing.table.DefaultTableCellRenderer.getTableCellRendererComponent(DefaultTableCellRenderer.java:160)
at javax.swing.JTable.prepareRenderer(JTable.java:3731)
at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java:1149)
at javax.swing.plaf.basic.BasicTableUI.paintCells(BasicTableUI.java:1051)
at javax.swing.plaf.basic.BasicTableUI.paint(BasicTableUI.java:974)
at javax.swing.plaf.ComponentUI.update(ComponentUI.java:142)
at javax.swing.JComponent.paintComponent(JComponent.java:541)
at javax.swing.JComponent.paint(JComponent.java:808)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JComponent.paint(JComponent.java:817)
at javax.swing.JViewport.paint(JViewport.java:722)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JComponent.paint(JComponent.java:817)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4787)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4740)
at javax.swing.JComponent._paintImmediately(JComponent.java:4685)
at javax.swing.JComponent.paintImmediately(JComponent.java:4488)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:410)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:117)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)before i unhide the columns, the table is already populated with values. so it might have something to do with that...cuz there is no problems unhiding them if the table contains no data
any ideas?
thanksIf you're interested, this method hides a table column without any modifications of its content:
public static void setTableColumnVisible(JTable table, int col,
boolean visible, int width) {
try {
TableColumn column = table.getColumnModel().getColumn(col);
if (!visible) {
column.setMinWidth(0);
column.setWidth(0);
column.setMaxWidth(0);
column.setPreferredWidth(0);
else {
column.setWidth(width);
column.setPreferredWidth(width);
catch(Exception e) {
e.printStackTrace();
}Method use:
. setTableColumnVisible(table, col, false, 0) hides the column
. setTableColumnVisible(table, col, true, 100) restores the column to its size of 100
Hope this helped,
Regards. -
Moving table columns is very slow
In my application moving table columns is very slow, with the rendering of table cells dragging behind the rendering of the table cell (using Java 1.5). I use a custom table cell renderer that subclasses a JPanel and contains a JTextField.
I checked I was overriding all the methods that DefaultTableCellRenderer does for performance reasons and found I wasnt overiding validate() and invalidate(), over-riding these the table column performance is now ok, but the cells are now not rendered correctly.
I also put a System.out.println into getTableRendererComponent() and found that even if I only move a column slightly the getTableRendererComponent() is called for every cell displayed rather than just the cells within the column moved/columns either side of it which is what i expect.
Any ideas what i should do. My own vague idea is to put some code into validate() and invalidate() to only call super implemntaions when really need to, but dont know how to work this out.Hi, thanks for your help - ive created a full test case, code below. I have reworked the code so I dont need to do a removeAll() but the issues remaining are:
1. If I override validate() with an empty method nothing is displayed in the grid
2. The renderer is alot slower than the using default renderer even though ive removed stuff like borders.
The code below has validate without the empty method.
(My real renderer is a bit more complicated, and I do require to use a JPanel)
import com.jthink.jaikoz.settings.LAF;
import com.jthink.jaikoz.table.ID3Cell;
import javax.swing.*;
import javax.swing.table.*;
import java.util.Vector;
import java.awt.*;
public class SlowColumnMoveTest
public static void main(String args[])
new SlowColumnMoveTest();
public SlowColumnMoveTest()
Vector colNames = new Vector();
colNames.add("col0");
colNames.add("col1");
colNames.add("col2");
colNames.add("col3");
colNames.add("col4");
colNames.add("col5");
colNames.add("col6");
colNames.add("col7");
colNames.add("col8");
colNames.add("col9");
Vector data = new Vector();
for (int i = 0; i < 500; i++)
Vector v = new Vector();
v.add(i);
for (int j = 1; j < 10; j++)
v.add(String.valueOf((i + 1) * (j + 1)));
data.add(v);
JTable table = new JTable(new DefaultTableModel(data, colNames));
table.getColumnModel().setColumnSelectionAllowed(true);
table.setDefaultRenderer(Object.class, new SlowRenderer());
JFrame frame = new JFrame("SlowColumnMoveTest");
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
JScrollPane scrollPane = new JScrollPane(table);
frame.add(scrollPane);
frame.pack();
frame.setVisible(true);
static class SlowRenderer extends JPanel implements TableCellRenderer
private static String PROPERTY_TABLE_BGCOLOUR = "Table.background";
private static String PROPERTY_TABLE_FGCOLOUR = "Table.foreground";
private static String PROPERTY_TABLE_SELECTION_BGCOLOUR = "Table.selectionBackground";
private static String PROPERTY_TABLE_SELECTION_FGCOLOUR = "Table.selectionForeground";
protected static Color tableBGColour = null;
protected static Color tableFGColour = null;
protected static Color selectionBGColour = null;
protected static Color selectionFGColour = null;
static
tableBGColour = UIManager.getColor(PROPERTY_TABLE_BGCOLOUR);
tableFGColour = UIManager.getColor(PROPERTY_TABLE_FGCOLOUR);
selectionBGColour = UIManager.getColor(PROPERTY_TABLE_SELECTION_BGCOLOUR);
selectionFGColour = UIManager.getColor(PROPERTY_TABLE_SELECTION_FGCOLOUR);
protected JTextField text;
public SlowRenderer()
text = new JTextField();
text.setBorder(null);
text.setOpaque(false);
text.setForeground(tableFGColour);
setOpaque(true);
this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
this.add(text);
public Component getTableCellRendererComponent(final JTable table,
final Object value,
final boolean isSelected,
final boolean hasFocus,
final int row,
final int column)
//System.out.println("rendering:col:"+column+":row:"+row);
text.setVisible(true);
text.setText(value.toString());
if (isSelected)
text.setForeground(selectionFGColour);
this.setBackground(selectionBGColour);
else
text.setForeground(tableFGColour);
this.setBackground(tableBGColour);
return this;
@Override
public final boolean isOpaque()
return true;
@Override
public void invalidate()
//System.out.println("invvalidate");
//super.invalidate();
@Override
public void validate()
//System.out.println("validate");
super.validate();
@Override
public void revalidate()
@Override
public void repaint(long tm, int x, int y, int width, int height)
@Override
public void repaint(Rectangle r)
@Override
public void repaint()
@Override
protected final void firePropertyChange(final String propertyName, final Object oldValue, final Object newValue)
@Override
public final void firePropertyChange(final String propertyName, final boolean oldValue, final boolean newValue)
private static final class UIResource
extends DefaultTableCellRenderer
implements javax.swing.plaf.UIResource
}
Maybe you are looking for
-
My itunes crashes when i try to play a song
My itunes keeps crashing when I try to access the Itunes store or when i try playing a song...HELP!!!
-
PS4 including Party audio in video clips
I am wondering if anyone has the same issue as me and my friends where when you are recording video clips and everyone has their voices shared and party audio is include in the clip only my voice (or their voices on their end) are being included in t
-
Files not found while installing Oracle 9iAS Rel 2 on Win2K
Hello, When installing Oracle 9iAs Release 9.2.0.1.0 on Windows 2000, the installation pops up windows 'File not found' for a number of files like - jarfiles.1.4.jar, jarfiles.1.2.jar. I checked out and the files are not avialable in the installation
-
Warning Message after repairing disk permissions
I received the following warning after running Repair Disk Permissions: Warning: SUID file "System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/MacOS/ARDAg ent" has been modified and will not be repaired. My computer has been crashing
-
I have downloaded and installed ICC profiles (in Library/ColorSync/Profiles) for several Hahnemuller papers. The ICC profile appears in the Aperture Print dialogue box under ColorSync Profile. But when I hit print and the Epson 2400 dialog box comes