swing - Java Class to execute in JButton MouseClicked -


I am with this group I am new to Java, I can open a PDF file:

 < code> public square View PDF {public static void main (string [] Arges) throws an exception process {p = Rntaimkjettaim () .exec ( "rundll32 Url.dll, FileProtocolHandler c: /pdf/mypdf.pdf "); P.waitFor (); Println ("complete."); }}   

Now to fire the square, use the Pebble Mouse Event and open that PDF. Can I give some help to somebody working in Netbeans?

NewJFrame.java

  public class NewJFrame extends javax.swing.JFrame {/ ** new builds * / public Nugfrem (NewJFrame) {initComponents (); } / ** This method is called from within the Creator to start the form. * WARNING: Do not modify this code. The contents of this method are always revived by the form editor * / @SuppressWarnings ("uncheck") // & lt; Editor-fold defaultstate = "collapsed" desc = "generated code" & gt; Private Zero Init Components () {jButton1 = new javax.swing.JButton (); SetDefaultCloseOperation (javax.swing.WindowConstants.EXIT_ON_CLOSE); JButton1.setText ("jButton1"); JButton1.addMouseListener (new java.awt.event.MouseAdapter () {public void mouseClicked (java.awt.event.MouseEvent evt) {jButton1MouseClicked (evt);}}); Javax.swing.GroupLayout layout = new javax.swing.GroupLayout (getContentPane ()); GetContentPane () setLayout (layout). Layout. Sethorizontal Group (layout.completegroup (javax.swing.GroupLayout.Alignment.LEADING) .adgroup (javax.swing.GroupLayout.Alignment.TRAILLING, layout.cctsAgegenic group) .addContainerGap (217, short.mx_avn) .addComponent ( JButton1) .addGap (108, 108, 108))); Leautksetvrtikalgrup (Leautkkreateprllelgrup (Jvksksvingkgroupleout.alainmentkleeding) Kaddgrup (Leautkkretsekuantielgrup () Kadagp (67, 67, 67) Kadkmponent (Jbuttonl) Kadktenergap (210, Shartkmaks_valu)) ); Pack (); } // & lt; / Editor-fold & gt; Private void jButton1MouseClicked (java.awt.event.MouseEvent evt) {// TODO add on your handling code:} / ** * @param command line arguments * / public static void (String args []) {Java args. Awt.EventQueue.invokeLater (New Runnabal) {Public Zero Run} {New NewJFrame (.) SetVisible (true);}}); } // Variable Announcement - Do not modify personal javax.swing.JButton jButton1; // the completion of the variable declaration}   

thanks in advance ... ^^

As an alternative, you can use it in your button handler.

Comments