View Single Post
Go4Expert Member
26Sep2011,22:50  
rajasohaibmaroof's Avatar
]
Code:
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.company.librarySystem.bm.ui;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;
 
/**
 * @version 1.0 11/09/98
 */
public class ButtonEditor extends DefaultCellEditor {
  protected JButton button;
  private String    label;
  private boolean   isPushed;
 
  public ButtonEditor(JCheckBox checkBox) {
    super(checkBox);
    button = new JButton();
    button.setOpaque(true);
    button.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        fireEditingStopped();
      }
    });
  }
 
  public Component getTableCellEditorComponent(JTable table, Object value,
                   boolean isSelected, int row, int column) {
    if (isSelected) {
      button.setForeground(table.getSelectionForeground());
      button.setBackground(table.getSelectionBackground());
    } else{
      button.setForeground(table.getForeground());
      button.setBackground(table.getBackground());
    }
    label = (value ==null) ? "" : value.toString();
    button.setText( label );
    isPushed = true;
    return button;
  }
 
  public Object getCellEditorValue() {
    if (isPushed)  {
      // 
      // 
      JOptionPane.showMessageDialog(button ,label + ": Ouch!");
      // System.out.println(label + ": Ouch!");
    }
    isPushed = false;
    return new String( label ) ;
  }
   
  public boolean stopCellEditing() {
    isPushed = false;
    return super.stopCellEditing();
  }
 
  protected void fireEditingStopped() {
    super.fireEditingStopped();
  }
}
Code:
private void UpdateMouseClicked(java.awt.event.MouseEvent evt) {                                    
    UpdateController updateController = new com.company.librarySystem.bm.controller.UpdateController();
    Book book = new Book();
   // book.setBookName(bokName.getText());
    //book.setAuthorName(authorName.getText());
    book.setSelectedRowValueOfColumnSecond(jTable1.getValueAt(jTable1.getSelectedRow(), 1));
    book.setSelectedRowValueOfColumnFirst(jTable1.getValueAt(jTable1.getSelectedRow(), 0));
    updateController.update(book);
}                                   

private void DeleteMouseClicked(java.awt.event.MouseEvent evt) {                                    
    DeleteController deleteController = new DeleteController();
    Book book = new Book();
    book.setSelectedRowValueOfColumnFirst(jTable1.getValueAt(jTable1.getSelectedRow(), 0));
    deleteController.delete(book);
    defaultTableModel.removeRow(jTable1.getSelectedRow());
    
  
    
    
}
unable to post gui 's whole code dnt knw its not letting me insert that i will just past the related code plzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz help me now [IMG]file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image001.gif[/IMG][IMG]file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image002.gif[/IMG]