• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTABLE Update

 
Nagaseshagiri poola
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please look in to my code
public class MainFrame extends JFrame implements ActionListener
{

TV1Table m_tv1Table;

public MainFrame()
{

this.getContentPane().setLayout(new FlowLayout());
this.setJMenuBar(new MenuBar());

initTVKontolle();
setSize(900, 550);
setVisible(true);
this.getContentPane().setBackground(Color.WHITE);
setResizable(false);

}


private void initTVKontolle()
{
JPanel tTopPanel = new JPanel();
tTopPanel.setBackground(Color.WHITE);

tTopPanel.add(new JLabel("TV-Kontrolle"));
tTopPanel.add(new JLabel(" "));
JCheckBox tCheckBox = new JCheckBox("FS");
tCheckBox.setBackground(Color.WHITE);
tTopPanel.add(tCheckBox);

JPanel tCenterPanel = new JPanel();
tCenterPanel.setBackground(Color.WHITE);
// tCenterPanel.add(new JLabel("TV-Kontrolle"));
JLabel Img = new JLabel("", new ImageIcon("images/index.jpg"),JLabel.CENTER);
tCenterPanel.add(Img);

JPanel tLowerPanel = new JPanel(new BorderLayout());
tLowerPanel.setBackground(Color.WHITE);

JPanel tiLowerPanel = new JPanel();
tiLowerPanel.setBackground(Color.WHITE);
tiLowerPanel.add(new TV1Table());
JButton searchChannels = new JButton("Channels Search");
searchChannels.addActionListener(this);

searchChannels.setPreferredSize(new Dimension(140, 26));
JPanel srcPanel = new JPanel();
srcPanel.setBackground(Color.WHITE);
srcPanel.add(searchChannels);

tLowerPanel.add(tiLowerPanel, BorderLayout.NORTH);
tLowerPanel.add(srcPanel, BorderLayout.SOUTH);

JPanel tMainPanel = new JPanel(new BorderLayout());
tMainPanel.setBackground(Color.WHITE);
tMainPanel.add(tTopPanel, BorderLayout.NORTH);
tMainPanel.add(tCenterPanel, BorderLayout.CENTER);
tMainPanel.add(tLowerPanel, BorderLayout.SOUTH);

this.getContentPane().add(tMainPanel);

}

public void actionPerformed(ActionEvent ae){
String actionCmd = ae.getActionCommand();
if(actionCmd.equalsIgnoreCase("Channels Search")){
// Here i want to update my tables TV1Table()
// Actually i want to change the table values
}
}
/**********************************
TV1Table()
public class TV1Table extends JPanel implements MouseListener
{
JTable iSA1Table;
ArrayList m_tv1 = null;


public TV1Table()
{
initTable();
}

private void initTable()
{



iSA1Table = new JTable(initTableModel());
//iSA1Table.setPreferredSize(new Dimension(300, 200));


JTableHeader tTableHeader = iSA1Table.getTableHeader();
iSA1Table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
tTableHeader.setReorderingAllowed(false);
tTableHeader.addMouseListener(this);
iSA1Table.addMouseListener(this);
iSA1Table.getColumnModel().getColumn(0).setMaxWidth(20);
iSA1Table.getColumnModel().getColumn(1).setMinWidth(90);

JPanel tTablePanel = new JPanel(new BorderLayout(0, 0));
//iSA1Table.setPreferredSize(new Dimension(400, 600));
//iAbstandTable.setPreferredScrollableViewportSize(new Dimension(400, 300));

tTablePanel.add(iSA1Table, BorderLayout.CENTER);
JScrollPane tTableScrollPane = new JScrollPane(tTablePanel);
//setLayout(new BorderLayout(0,0));
//add(new JLabel("Sensorfeld1"), BorderLayout.NORTH);
add(tTableScrollPane, BorderLayout.CENTER);
}

public DefaultTableModel initTableModel()
{
DefaultTableModel tDefaultTableModel = new DefaultTableModel();
tDefaultTableModel.addColumn("");
tDefaultTableModel.addColumn("");

Vector tRowVector = new Vector();
tRowVector.add("1");
tRowVector.add("");

tDefaultTableModel.addRow(tRowVector);

Vector t2RowVector = new Vector();
t2RowVector.add("2");
t2RowVector.add("2");

tDefaultTableModel.addRow(t2RowVector);

return tDefaultTableModel;

}
}
Please help to update the values in the tv1table class
 
Joe Ess
Bartender
Posts: 9362
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Nagaseshagiri poola:
Please look in to my code
Please help to update the values in the tv1table class

1. Use the "CODE" tags to format your code.
2. Post code that compiles.
3. Be a little more descriptive. I don't have a copy of your assignment. For example, what do you want to update the tv1table class with? At the least you will have to keep a reference to tv1table in your MainFrame class (I know you _declare_ one, but you don't use it), expose a method in TV1Table to perform the update and call that method in ActionPerformed.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!