public CustomEditor(){
  m_fileChooser.setFileFilter(new ExtensionFileFilter(CostMatrix.FILE_EXTENSION,"Cost files"));
  m_fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
  m_defaultButton=new JButton("Defaults");
  m_openButton=new JButton("Open...");
  m_saveButton=new JButton("Save...");
  m_resizeButton=new JButton("Resize");
  m_classesField=new JTextField("" + m_matrix.size());
  m_defaultButton.addActionListener(this);
  m_openButton.addActionListener(this);
  m_saveButton.addActionListener(this);
  m_resizeButton.addActionListener(this);
  m_classesField.addActionListener(this);
  JPanel classesPanel=new JPanel();
  classesPanel.setLayout(new GridLayout(1,2,0,0));
  classesPanel.add(new JLabel("Classes:",SwingConstants.RIGHT));
  classesPanel.add(m_classesField);
  JPanel rightPanel=new JPanel();
  GridBagLayout gridBag=new GridBagLayout();
  GridBagConstraints gbc=new GridBagConstraints();
  rightPanel.setLayout(gridBag);
  gbc.gridx=0;
  gbc.gridy=GridBagConstraints.RELATIVE;
  gbc.insets=new Insets(2,10,2,10);
  gbc.fill=GridBagConstraints.HORIZONTAL;
  gridBag.setConstraints(m_defaultButton,gbc);
  rightPanel.add(m_defaultButton);
  gridBag.setConstraints(m_openButton,gbc);
  rightPanel.add(m_openButton);
  gridBag.setConstraints(m_saveButton,gbc);
  rightPanel.add(m_saveButton);
  gridBag.setConstraints(classesPanel,gbc);
  rightPanel.add(classesPanel);
  gridBag.setConstraints(m_resizeButton,gbc);
  rightPanel.add(m_resizeButton);
  JPanel fill=new JPanel();
  gbc.weightx=1.0;
  gbc.weighty=1.0;
  gbc.fill=GridBagConstraints.BOTH;
  gridBag.setConstraints(fill,gbc);
  rightPanel.add(fill);
  m_tableModel=new CostMatrixTableModel();
  m_tableModel.addTableModelListener(this);
  JTable matrixTable=new JTable(m_tableModel);
  setLayout(new BorderLayout());
  add(matrixTable,BorderLayout.CENTER);
  add(rightPanel,BorderLayout.EAST);
}

public CustomEditor ( ) { m_fileChooser . setFileFilter ( new ExtensionFileFilter ( CostMatrix . FILE_EXTENSION , "Cost files" ) ) ; m_fileChooser . setFileSelectionMode ( JFileChooser . FILES_ONLY ) ; m_defaultButton = new JButton ( "Defaults" ) ; m_openButton = new JButton ( "Open..." ) ; m_saveButton = new JButton ( "Save..." ) ; m_resizeButton = new JButton ( "Resize" ) ; m_classesField = new JTextField ( "" + m_matrix . size ( ) ) ; m_defaultButton . addActionListener ( this ) ; m_openButton . addActionListener ( this ) ; m_saveButton . addActionListener ( this ) ; m_resizeButton . addActionListener ( this ) ; m_classesField . addActionListener ( this ) ; JPanel classesPanel = new JPanel ( ) ; classesPanel . setLayout ( new GridLayout ( 1 , 2 , 0 , 0 ) ) ; classesPanel . add ( new JLabel ( "Classes:" , SwingConstants . RIGHT ) ) ; classesPanel . add ( m_classesField ) ; JPanel rightPanel = new JPanel ( ) ; GridBagLayout gridBag = new GridBagLayout ( ) ; GridBagConstraints gbc = new GridBagConstraints ( ) ; rightPanel . setLayout ( gridBag ) ; gbc . gridx = 0 ; gbc . gridy = GridBagConstraints . RELATIVE ; gbc . insets = new Insets ( 2 , 10 , 2 , 10 ) ; gbc . fill = GridBagConstraints . HORIZONTAL ; gridBag . setConstraints ( m_defaultButton , gbc ) ; rightPanel . add ( m_defaultButton ) ; gridBag . setConstraints ( m_openButton , gbc ) ; rightPanel . add ( m_openButton ) ; gridBag . setConstraints ( m_saveButton , gbc ) ; rightPanel . add ( m_saveButton ) ; gridBag . setConstraints ( classesPanel , gbc ) ; rightPanel . add ( classesPanel ) ; gridBag . setConstraints ( m_resizeButton , gbc ) ; rightPanel . add ( m_resizeButton ) ; JPanel fill = new JPanel ( ) ; gbc . weightx = 1.0 ; gbc . weighty = 1.0 ; gbc . fill = GridBagConstraints . BOTH ; gridBag . setConstraints ( fill , gbc ) ; rightPanel . add ( fill ) ; m_tableModel = new CostMatrixTableModel ( ) ; m_tableModel . addTableModelListener ( this ) ; JTable matrixTable = new JTable ( m_tableModel ) ; setLayout ( new BorderLayout ( ) ) ; add ( matrixTable , BorderLayout . CENTER ) ; add ( rightPanel , BorderLayout . EAST ) ; }
constructs a new customeditor .
