Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Swing / AWT / SWT
Search Coderanch
Advance search
Google search
Register / Login
Forums
Register
Login
Java
»
Swing / AWT / SWT
How to hide collumns in JTable
Michal Bury
,
Greenhorn
Nov 21, 2006 00:13:00
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
I want to hide last four collumns in my JTable. Is there any way to set some collumns in table to be not Visible?
thanks
prashant gour
,
Ranch Hand
Nov 21, 2006 01:58:00
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JViewport;
import javax.swing.table.JTableHeader;
public class FixedTable extends JFrame implements PropertyChangeListener
{
JScrollPane scrTabel1;
JTable tblFixedData = new JTable(200, 6);
public FixedTable()
{
Container container = getContentPane();
container.add(getFixedTable());
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
pack();
}
private JPanel getFixedTable()
{
JTable tableTrade = new JTable(345,8);
scrTabel1 = new JScrollPane(tableTrade);
JTableHeader header = tblFixedData.getTableHeader();
JPanel pnl1 = new JPanel(new BorderLayout());
pnl1.add(header,"North");
pnl1.add(tblFixedData,"Center");
JPanel pnl = new JPanel(new GridLayout(1,2));
pnl.add(pnl1);
pnl.add(scrTabel1);
scrTabel1.addPropertyChangeListener(this);
pnl.setPreferredSize(new Dimension(300,300));
tblFixedData.setSelectionModel( tableTrade.getSelectionModel() );
tblFixedData.getTableHeader().setReorderingAllowed( false );
tblFixedData.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
tableTrade.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
return pnl;
}
public void propertyChange(PropertyChangeEvent pv){
JViewport viewport = scrTabel1.getViewport();
System.out.println(viewport);
tblFixedData.setPreferredScrollableViewportSize(viewport.getPreferredSize());
tblFixedData.revalidate();
tblFixedData.repaint();
}
public static void main(
String
[] args)
{
new FixedTable();
}
}
try above code, hope this will give you some clue.
Post by:
autobot
I yam what I yam and that's all that I yam - the great philosopher Popeye. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
reply
This thread has been viewed 833 times.
Similar Threads
JTable
JTable
Jtable without borders etc.
JTable
JTable cell rendering with no borders
More...
All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 18:21:36
.