Link to home
Start Free TrialLog in
Avatar of chenwei
chenwei

asked on

How to add a class as row-element in a table cell?

I asked a similar question yesterday. Now what I want is to add a class as element into the table cell. This class is a DesktopPane and has some components such as button on it. It looks as follow:

public class AddToken extends JDesktopPane implements ComponentListener{

private JButton jButtonAddButton = null;
      
AddToken(){
  initialize();
}
      

private void initialize() {
 // TODO Automatisch erstellter Methoden-Stub
 addComponents();
}

private void addComponents() {
 // TODO Automatisch erstellter Methoden-Stub
 this.add(getJButtonAddButton(), null);
}

private Component getJButtonAddButton() {
// TODO Automatisch erstellter Methoden-Stub
 if(jButtonAddButton == null){
  jButtonAddButton = new JButton();
  jButtonAddButton.setText("Set");
  jButtonAddButton.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 12));
                    jButtonAddButton.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
  jButtonAddButton.setSize(60,23);
  jButtonAddButton.setLocation(5,5);
 
  return jButtonAddButton;
}

}
Avatar of Mick Barry
Mick Barry
Flag of Australia image

you can add whatever object you want as a table cell value.
use a cell renderer to define how you want it displayed.
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Well, you can let your table cell renderer return whatever component you want.
Don't know hows that going to look however ;°)