[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 152
  • Last Modified:

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;
}

}
0
chenwei
Asked:
chenwei
  • 3
1 Solution
 
objectsCommented:
you can add whatever object you want as a table cell value.
0
 
objectsCommented:
use a cell renderer to define how you want it displayed.
0
 
objectsCommented:
Lots of examples of cell renderers at:

http://www.objects.com.au/java/examples.do
0
 
zzynxSoftware engineerCommented:
Well, you can let your table cell renderer return whatever component you want.
Don't know hows that going to look however ;°)
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now