NimbusLookAndFeel and Jtable ... I Cant save?

45 views Asked by At

This is My Main class

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.border.EmptyBorder;
import javax.swing.plaf.nimbus.NimbusLookAndFeel;
import javax.swing.JButton;


public class Button extends JFrame {

 public JPanel contentPane;
 public SaveObject saveObject=new SaveObject();

public table frame1 ;
 public static void main(String[] args) {
  EventQueue.invokeLater(new Runnable() {
   public void run() {
  
    try {
     Button frame = new Button();
     
     frame.setVisible(true);
    } catch (Exception e) {
     e.printStackTrace();
    }
   }
  });
 }

 /**
  * Create the frame.
  */
 public Button() {
   
  NimbusLookAndFeel laf = new NimbusLookAndFeel();
    try {
     UIManager.setLookAndFeel(laf);
    } catch (UnsupportedLookAndFeelException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
    }
    
    
  
  
  
  
  
  setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  setBounds(100, 100, 450, 300);
  contentPane = new JPanel();
  contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
  contentPane.setLayout(null);
  setContentPane(contentPane);
  
  frame1=new table();;
  
  JButton btnNewButton = new JButton("SAVE");
  btnNewButton.setBounds(151, 99, 120, 52);
  contentPane.add(btnNewButton);
  btnNewButton.addActionListener(new ActionListener() {
   
   @Override
   public void actionPerformed(ActionEvent e) {
    saveObject.save(frame1);
    
   }
  });
 }
}
This is My second Class
import java.io.Serializable;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;


public class table implements Serializable
{
 /**
  * 
  */
 private static final long serialVersionUID = 1L;
 public String[] title={"1","2","3","4","5"}; 
 public DefaultTableModel tableModel=new DefaultTableModel(title,0);
 JFrame a=new JFrame();
 JTable table = new JTable(tableModel) ;
 
 
 public JScrollPane scrollPane=new JScrollPane(); 
 public Object[] object=new Object[title.length];
 public int practiceNumber=0;

 public String[] premlesave=new String[100];
  
 public table()
 {
  scrollPane.setBounds(0, 0, 396, 188);
  table.setFillsViewportHeight(true);
  
  a.setVisible(true);
  a.add(scrollPane);
 } }
 
And this is My saveobject Class

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

import javax.imageio.stream.FileImageInputStream;

public class SaveObject
{
 private ObjectOutputStream output;
 private ObjectInputStream input;
 public void save(Object o)
 {
  try{
   output = new ObjectOutputStream(new FileOutputStream("mm.ser"));
   output.writeObject(o);;
   output.close();
   output.flush();
  }
  catch(IOException e)
  {}
 }
}
And now I want use NimbusLookAndFeel laf = new NimbusLookAndFeel(); but this is not Serializable and show error. Why? This means I cant use the NimbusLookAndFeel?

0

There are 0 answers