Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package UserInterface.ReceptionistRole; import com.twilio.sdk.TwilioRestClient; import com.twilio.sdk.TwilioRestException; import com.twilio.sdk.resource.factory.CallFactory; import com.twilio.sdk.resource.instance.Call; import java.awt.CardLayout; import java.util.ArrayList; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JPanel; import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; /** * * @author shivam */ public class CallAmbulance extends javax.swing.JPanel { private JPanel userProcessContainer; /** /** * Creates new form CallPatient */ public CallAmbulance(JPanel userProcessContainer) { initComponents(); this.userProcessContainer = userProcessContainer; } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jLabel3 = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel(); NumberTextField = new javax.swing.JTextField(); jButton1 = new javax.swing.JButton(); jLabel2 = new javax.swing.JLabel(); jButton2 = new javax.swing.JButton(); jLabel3.setText("jLabel3"); setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); jLabel1.setText("Enter Number"); add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(73, 169, -1, -1)); add(NumberTextField, new org.netbeans.lib.awtextra.AbsoluteConstraints(227, 164, 121, -1)); jButton1.setIcon( new javax.swing.ImageIcon(getClass().getResource("/UserInterface/DoctorRole/images (3).jpeg"))); // NOI18N jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(257, 245, 100, 95)); jLabel2.setFont(new java.awt.Font("Lucida Grande", 1, 24)); // NOI18N jLabel2.setText("Call Ambulance"); add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(112, 21, -1, -1)); jButton2.setText("Back"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); add(jButton2, new org.netbeans.lib.awtextra.AbsoluteConstraints(73, 311, -1, -1)); }// </editor-fold>//GEN-END:initComponents private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed // TODO add your handling code here: List<NameValuePair> params = new ArrayList<NameValuePair>(); TwilioRestClient client = new TwilioRestClient("ACd4d9c14696f348fe21e4506a5e7b14e3", "d83be392f0c78d3a493675bf8d7942f1"); params.add(new BasicNameValuePair("To", "+18577076052")); params.add(new BasicNameValuePair("From", "+18577076050")); params.add(new BasicNameValuePair("Url", "https://api.twilio.com/2010-04-01/Accounts/ACd4d9c14696f348fe21e4506a5e7b14e3/Calls")); params.add(new BasicNameValuePair("Method", "GET")); params.add(new BasicNameValuePair("FallbackMethod", "GET")); params.add(new BasicNameValuePair("StatusCallbackMethod", "GET")); params.add(new BasicNameValuePair("Record", "false")); CallFactory callFactory = client.getAccount().getCallFactory(); Call call = null; try { call = callFactory.create(params); } catch (TwilioRestException ex) { Logger.getLogger(CallAmbulance.class.getName()).log(Level.SEVERE, null, ex); } System.out.println(call.getSid()); }//GEN-LAST:event_jButton1ActionPerformed private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed // TODO add your handling code here: userProcessContainer.remove(this); CardLayout layout = (CardLayout) userProcessContainer.getLayout(); layout.previous(userProcessContainer); }//GEN-LAST:event_jButton2ActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JTextField NumberTextField; private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; // End of variables declaration//GEN-END:variables }