|
|
|
|
@ -29,6 +29,7 @@ public class Importer extends JFrame
|
|
|
|
|
public Importer( String filename )
|
|
|
|
|
throws Exception
|
|
|
|
|
{
|
|
|
|
|
System.out.println( "File: " + filename );
|
|
|
|
|
setupComponents( filename );
|
|
|
|
|
|
|
|
|
|
addWindowListener( new WindowAdapter(){
|
|
|
|
|
@ -56,8 +57,8 @@ public class Importer extends JFrame
|
|
|
|
|
table.getColumn( i ).setResizable( true );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TableColumn col = table.getColumnModel().getColumn( 0 );
|
|
|
|
|
col.setHeaderRenderer( new ComboBoxHeaderRenderer() );
|
|
|
|
|
// TableColumn col = table.getColumnModel().getColumn( 0 );
|
|
|
|
|
// col.setHeaderRenderer( new ComboBoxHeaderRenderer() );
|
|
|
|
|
|
|
|
|
|
JScrollPane sp = new JScrollPane( table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
|
|
|
|
|
|
|
|
|
|
@ -70,7 +71,8 @@ public class Importer extends JFrame
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
im = new Importer(
|
|
|
|
|
"C:\\Documents and Settings\\psantos\\My Documents\\Devel\\teste.xls"
|
|
|
|
|
// "E:\\test.xls"
|
|
|
|
|
"C:\\Documents and Settings\\psantos\\My Documents\\Devel\\teste_2.xls"
|
|
|
|
|
// "C:\\Documents and Settings\\psantos\\My Documents\\Devel\\Docs\\jexcelapi\\jxlrwtest.xls"
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
@ -79,7 +81,14 @@ public class Importer extends JFrame
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
im.show();
|
|
|
|
|
if( im == null )
|
|
|
|
|
{
|
|
|
|
|
System.out.println( "O im e' null" );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
im.show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// String[][] all = (String[][]) e.getObjects();
|
|
|
|
|
//
|
|
|
|
|
@ -94,35 +103,3 @@ public class Importer extends JFrame
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class ComboBoxHeaderRenderer extends JComboBox implements TableCellRenderer
|
|
|
|
|
{
|
|
|
|
|
public Component getTableCellRendererComponent(JTable table, Object value,
|
|
|
|
|
boolean isSelected, boolean hasFocus, int rowIndex, int vColIndex) {
|
|
|
|
|
// 'value' is column header value of column 'vColIndex'
|
|
|
|
|
// rowIndex is always -1
|
|
|
|
|
// isSelected is always false
|
|
|
|
|
// hasFocus is always false
|
|
|
|
|
|
|
|
|
|
// Configure the component with the specified value
|
|
|
|
|
// setText(value.toString());
|
|
|
|
|
|
|
|
|
|
JPopupMenu pm = new JPopupMenu( "Menu" );
|
|
|
|
|
pm.add( "Ola" );
|
|
|
|
|
pm.add( "Adeus" );
|
|
|
|
|
add( pm );
|
|
|
|
|
|
|
|
|
|
// Set tool tip if desired
|
|
|
|
|
setToolTipText((String)value);
|
|
|
|
|
|
|
|
|
|
// Since the renderer is a component, return itself
|
|
|
|
|
//return this;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The following methods override the defaults for performance reasons
|
|
|
|
|
// public void validate() {}
|
|
|
|
|
// public void revalidate() {}
|
|
|
|
|
// protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {}
|
|
|
|
|
// public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) {}
|
|
|
|
|
}
|