Foro de elhacker.net

Programación => Java => Mensaje iniciado por: Leyer en 17 Julio 2010, 02:09 am



Título: Base para crear un instalador desde Java
Publicado por: Leyer en 17 Julio 2010, 02:09 am
Os dejo este código simple que programe hace mucho, es para crear un pequeño instalador desde java o también para un visor de imágenes ,claro habría que codear bastante para hacer uno completo pero este seria la base. lo coloco por si alquilen le sirve.

PD:1 Esta en Eclipse y no en Netbeans.

(http://r.i.elhacker.net/cache?url=http://www.imagengratis.org/images/panpdft9q.png)
Paquete (http://www.mediafire.com/?mym2hnjmzzi)
Código
  1. import java.io.IOException;
  2.  
  3. import javax.swing.UIManager;
  4. import javax.swing.UnsupportedLookAndFeelException;
  5. /**
  6.  * @author leyer
  7.  */
  8. public class Install extends  jwizardcomponent.frame.JWizardFrame {
  9.    private static final long serialVersionUID = 1L;
  10.  
  11.    private jwizardcomponent.JWizardPanel panel = null;
  12.  
  13. public static final int _PANEL_0 = 0;
  14. public static final int _PANEL_1 = 1;
  15.  
  16. protected javax.swing.ImageIcon imageBackground = new javax.swing.ImageIcon("");
  17. public Install() {
  18.  this.panel = new WizardPanelMain(getWizardComponents(),"Principal");
  19.      getWizardComponents().addWizardPanel(_PANEL_0, panel);
  20.      this.panel = new WizardPanel0(getWizardComponents(),"panel");
  21.      getWizardComponents().addWizardPanel(_PANEL_1, panel);
  22.      initConfigButtons();
  23.      this.setSize(WindowsWIDTH,WindowsHEIGHT);
  24.      this.setTitle("Instalador");
  25.      jwizardcomponent.Utilities.centerComponentOnScreen(this);
  26.      this.setVisible(true);
  27.    }
  28. static final int WindowsWIDTH = 800;
  29. static final int WindowsHEIGHT= 400
  30. ;
  31. private void initConfigButtons(){
  32.      getWizardComponents().getBackButton()  .setText("Atras");
  33.      getWizardComponents().getNextButton()  .setText("Siguiente");
  34.      getWizardComponents().getCancelButton().setText("Cancelar");
  35.      getWizardComponents().getFinishButton().setText("Finalizar");
  36. }
  37. private final class WizardPanelMain extends jwizardcomponent.JWizardPanel {
  38. private static final long serialVersionUID = 1L;
  39. private javax.swing.JPanel panelBackground = new javax.swing.JPanel(){
  40. private static final long serialVersionUID = 1L;
  41. @Override
  42. public void paintComponent(java.awt.Graphics graphics){
  43. this.setOpaque(false);
  44. graphics.drawImage(imageBackground.getImage(),0,0,this.getWidth(),this.getHeight(),null);
  45. super.paintComponent(graphics);
  46. }
  47. };
  48. public WizardPanelMain(jwizardcomponent.JWizardComponents jWizardComponents, String title) {
  49.        super(jWizardComponents, title);
  50.        this.setLayout(new java.awt.BorderLayout());
  51. this.panelBackground.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
  52. this.add(panelBackground,java.awt.BorderLayout.CENTER);
  53.    }}
  54. private final class WizardPanel0 extends jwizardcomponent.JWizardPanel{
  55. private static final long serialVersionUID = 1L;
  56. private javax.swing.JPanel panelBackground = new javax.swing.JPanel(){
  57. private static final long serialVersionUID = 1L;
  58. @Override
  59. public void paintComponent(java.awt.Graphics graphics){
  60. this.setOpaque(false);
  61.  
  62. graphics.drawImage(imageBackground.getImage(),0,0,this.getWidth(),this.getHeight(),null);
  63. super.paintComponent(graphics);
  64. }
  65. };
  66. public WizardPanel0(jwizardcomponent.JWizardComponents jWizardComponents,String title) {
  67. super(jWizardComponents,title);
  68. this.setLayout(new java.awt.BorderLayout());
  69. this.add(panelBackground,java.awt.BorderLayout.CENTER);
  70. }}
  71. public static void main(String[] args) throws SecurityException, IOException {
  72. try {
  73. UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
  74. } catch (ClassNotFoundException e) {
  75. e.printStackTrace();
  76. } catch (InstantiationException e) {
  77. e.printStackTrace();
  78. } catch (IllegalAccessException e) {
  79. e.printStackTrace();
  80. e.printStackTrace();
  81. }
  82. long start, end;
  83. start = System.currentTimeMillis();
  84. new Install().setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
  85. end = System.currentTimeMillis();
  86. System.out.println("Elapsed time: " + (end - start));
  87. }
  88.  

Un saludo. :)


Título: Re: Base para crear un instalador desde Java
Publicado por: Aeros en 17 Julio 2010, 03:14 am
Probando, gracias por el aporte :D


Título: Re: Base para crear un instalador desde Java
Publicado por: Blitzkrieg' en 17 Julio 2010, 04:12 am
Buen aporte Leyer.  ;D

PD: Lo hiciste con Netbeans?


Título: Re: Base para crear un instalador desde Java
Publicado por: Leyer en 17 Julio 2010, 04:15 am
Buen aporte Leyer.  ;D

PD: Lo hiciste con Netbeans?

me conoces  :xD no toco el netbeans así sea el único IDE que exista.

Eclipse forever :D

Un saludo.


Título: Re: Base para crear un instalador desde Java
Publicado por: Debci en 17 Julio 2010, 10:47 am
Wowowowow otro gran aporte del gran maestro!

En cuanto pueda lo testeo.

Saludos


Título: Re: Base para crear un instalador desde Java
Publicado por: Leyer en 18 Julio 2010, 20:45 pm
Coloque una imagen tambien para que se entienda mas lo que es :xD

Un saludo.