|
|
JPanel in JTable cell
I have JTable , and i want to have in each cell of table some custome
panel whith buttons and textboxes ,the same in every cell.Is it posible
to catch an event from components in that panel?
i would appritiate advice ,thnx
|
|
0
|
|
|
|
Reply
|
helena
|
6/28/2005 8:35:12 AM |
|
Hi,
Try writing custom renderers and editors for your table
|
|
0
|
|
|
|
Reply
|
ravi
|
6/28/2005 10:49:07 AM
|
|
Creating custom cell renderer is easy by using QuickTable. QuickTable
is a free java component (http://quicktable.org) which is an
implementation on top of JTable , but hides all the complexities and
allows to use the JTable methods. So you can just replace Jtable with
QuickTable.
For example, we create a File selector cell using a JPanel and JButton.
//we create a File selecter cell editor
//this has a label & a button, when user wants to change the file to
something else
//instead of directly editing this cell, they click on the button
which opens a file
// dialog and user selects the file
class FileCell extends JPanel implements CellComponent
{
JLabel jl = new JLabel();
JButton jb = new JButton("...");
JFileChooser jf;
public FileCell()
{
//use a border layout , rather than the used flow layout
add(jl);
add(jb);
// add a actionlistener to open file dialog when user clicks on
the button
jb.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if( jf == null)
{
jf = new JFileChooser();
}
String val = jl.getText();
if( val != null && !("".equals(val)) )
{
jf.setCurrentDirectory(new File(val));
}
int returnVal = jf.showOpenDialog(null);
if(returnVal == JFileChooser.APPROVE_OPTION)
jl.setText(jf.getSelectedFile().getPath());
}
});
}
public void setValue(Object value)
{
jl.setText( (String)(value==null?"":value ));
}
public Object getValue()
{
String val = jl.getText();
if( val != null && !("".equals(val)) )
return val;
else
return null;
}
public JComponent getComponent()
{
return this;
}
}
|
|
0
|
|
|
|
Reply
|
Liz
|
7/12/2005 7:08:11 PM
|
|
|
2 Replies
585 Views
(page loaded in 0.061 seconds)
Similiar Articles: JPanel in JTable cell - comp.lang.java.guiI have JTable , and i want to have in each cell of table some custome panel whith buttons and textboxes ,the same in every cell.Is it posible to ca... Event handler problem in JTable - comp.lang.java.gui... on the table cell, the event picked up is a table event rather than the JPanel (cell ... JTable cell selection event - Application Forum at ObjectMix.com JTable cell ... JTable horizontal scrollbar problem - comp.lang.java.gui ...JPanel in JTable cell - comp.lang.java.gui JPanel in JTable cell - comp.lang.java.gui //we create a File selecter cell editor //this has a label & a ... Using JComboBoxes in a JTable - comp.lang.java.guiJPanel in JTable cell - comp.lang.java.gui I have JTable , and i want to have in each cell of table some custome panel whith buttons and textboxes ,the same in every cell ... how to put JTextfield and JButton in a cell of JTable - comp.lang ...JPanel in JTable cell - comp.lang.java.gui... focus in JTextField) - comp ... JPanel in JTable cell ... JPanel in JTable cell - comp.lang.java.gui JButton ... Problem of JTable and the JComboBox cell editor. - comp.lang.java ...JPanel in JTable cell - comp.lang.java.gui Problem of JTable and the JComboBox cell editor. - comp.lang.java ... Problem of JTable and the JComboBox cell editor. - comp ... Hyperlink inJtable cells - comp.lang.java.guiJPanel in JTable cell - comp.lang.java.gui I have JTable , and i want to have in each cell of table some custome panel whith buttons and textboxes ,the same in every cell ... How to Wrap Text in JTable Header and Cell - comp.lang.java.gui ...How to Wrap text in JTable Header and cell? thanks in advance. MC ... Limiting the number of characters in a JTable cell. - comp.lang ...JPanel in JTable cell - comp.lang.java.gui JPanel in JTable cell - comp.lang.java.gui JTable and input methods (or, and: focus in ... Make a simple 4 row by 4 column ... How to set a specific cells backcolor in JTable? - comp.lang.java ...What I've come up with is implement ListCellRenderer and extend JPanel ... setting size of JComboBox - comp.lang.java.gui How to set a specific cells backcolor in JTable ... Custom JPanel cell with JButtons in JTable - pekaliciousIf you ever wanted to add a JPanel with various interactive components (e.g. JButtons, JCheckBoxes etc.) in a JTable cell and could not figure out how to make them ... JPanel in JTable cell - Java forums. Thousands of discussion ...I have JTable , and i want to have in each cell of table some custome panel whith buttons and textboxes ,the same in every cell.Is it posible 7/22/2012 6:37:30 PM
|
|
|
|
|
|
|
|
|