fd.setMultiSelectionEnabled( false );
fd.setCurrentDirectory( new File( "." ) );
fd.setDialogTitle( DemoApp.getRes().getString( "Select Executable for customization" ) );
fd.setFileHidingEnabled( true );
fd.setApproveButtonText( DemoApp.getRes().getString( "Load Executable" ) );
FileFilter filter = new ExtensionFilter( DemoApp.getRes().getString( "Wrapper Executable (*.exe)" ), new String[] { "exe" } );
fd.setFileFilter( filter );
int returnVal = fd.showOpenDialog( CustomizeDialog.this );
if ( returnVal == JFileChooser.APPROVE_OPTION )
{
try
{
selectedSource = fd.getSelectedFile().getCanonicalPath();
jTextField1.setText( selectedSource );
}
catch ( IOException e1 )
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
} );
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 0;
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
jPanel1.add( jButton1, gridBagConstraints );
jButton2.setText( "..." );
jButton2.addActionListener( new ActionListener()
{
public void actionPerformed( ActionEvent e )
{
JFileChooser fd = new JFileChooser();
fd.setMultiSelectionEnabled( false );
fd.setCurrentDirectory( new File( "." ) );
fd.setDialogTitle( DemoApp.getRes().getString( "Select Icon for customization" ) );
fd.setFileHidingEnabled( true );
fd.setApproveButtonText( DemoApp.getRes().getString( "Load Icon" ) );
FileFilter filter = new ExtensionFilter( DemoApp.getRes().getString( "Icon File (*.ico)" ), new String[] { "ico" } );
fd.setFileFilter( filter );
int returnVal = fd.showOpenDialog( CustomizeDialog.this );
if ( returnVal == JFileChooser.APPROVE_OPTION )
{
try
{
selectedIcon = fd.getSelectedFile().getCanonicalPath();
jTextField2.setText( selectedIcon );
}
catch ( IOException e1 )
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
} );
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 1;
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
jPanel1.add( jButton2, gridBagConstraints );
jButton3.setText( "..." );
jButton3.addActionListener( new ActionListener()
{
public void actionPerformed( ActionEvent e )
{
JFileChooser fd = new JFileChooser();
fd.setMultiSelectionEnabled( false );
fd.setCurrentDirectory( new File( "." ) );
fd.setDialogTitle( DemoApp.getRes().getString( "Select splash screen for customization" ) );
fd.setFileHidingEnabled( true );
fd.setApproveButtonText( DemoApp.getRes().getString( "Load splash screen" ) );
FileFilter filter = new ExtensionFilter( DemoApp.getRes().getString( "Splash screen File (*.bmp)" ), new String[] { "bmp" } );
fd.setFileFilter( filter );
int returnVal = fd.showOpenDialog( CustomizeDialog.this );
if ( returnVal == JFileChooser.APPROVE_OPTION )
{
try
{
selectedSplashScreen = fd.getSelectedFile().getCanonicalPath();
jTextField3.setText( selectedSplashScreen );
}
catch ( IOException e1 )
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
} );
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 2;
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
jPanel1.add( jButton3, gridBagConstraints );
jButton4.setText( DemoApp.getRes().getString( "Customize" ) );
jButton4.addActionListener( new ActionListener()
{
public void actionPerformed( ActionEvent e )
{
String errorMsg = "";
if ( jTextField1.getText().length() == 0 || !new File( jTextField1.getText() ).exists() )
{
jTextField1.setBackground( Color.red );
errorMsg = errorMsg.concat( DemoApp.getRes().getString( "No valid Source Binary Specified\n" ) );
}
if ( jTextField2.getText().length() != 0 && !new File( jTextField2.getText() ).exists() )
{
jTextField2.setBackground( Color.red );
errorMsg = errorMsg.concat( DemoApp.getRes().getString( "No valid Icon File Specified\n" ) );
}
if ( jTextField3.getText().length() != 0 && !new File( jTextField3.getText() ).exists() )
{
jTextField3.setBackground( Color.red );
errorMsg = errorMsg.concat( DemoApp.getRes().getString( "No valid Splash Screen File Specified\n" ) );
}
if ( jTextField2.getText().length() == 0 && jTextField3.getText().length() == 0 )
{
errorMsg = errorMsg.concat( DemoApp.getRes().getString( "Please select at least one Icon or Splash Screen File.\n" ) );
jTextField2.setBackground( Color.yellow );
jTextField3.setBackground( Color.yellow );
}
if ( errorMsg.length() > 0 )
{
JOptionPane.showMessageDialog( CustomizeDialog.this, DemoApp.getRes().getString( "See the following list of errors:\n" ) + errorMsg, DemoApp.getRes().getString( "Error" ), JOptionPane.ERROR_MESSAGE );
return;
}
JFileChooser fd = new JFileChooser();
fd.setMultiSelectionEnabled( false );
fd.setCurrentDirectory( new File( "." ) );
fd.setDialogTitle( DemoApp.getRes().getString( "Select destination file of the customization" ) );
fd.setFileHidingEnabled( true );
fd.setApproveButtonText( DemoApp.getRes().getString( "Custimize Binary" ) );
FileFilter filter = new ExtensionFilter( DemoApp.getRes().getString( "Executable File (*.exe)" ), new String[] { "exe" } );
fd.setFileFilter( filter );
int returnVal = fd.showSaveDialog( CustomizeDialog.this );
if ( returnVal == JFileChooser.APPROVE_OPTION )