Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package xmlrpc_hitungberat;
- import java.awt.Color;
- import java.net.InetAddress;
- import java.time.*;
- import java.time.temporal.ChronoUnit;
- import org.apache.xmlrpc.*;
- /**
- *
- * @author ferry
- */
- public class Server_Gui extends javax.swing.JFrame {
- /**
- * Creates new form Server_Gui
- */
- public Server_Gui() {
- initComponents();
- }
- public double hitung_tinggi(String jkel, double tinggi) {
- double ideal;
- double bbi = 0;
- if(jkel.equals("pria")){
- ideal = (tinggi - 100);
- bbi = (ideal -(0.10 * ideal));
- }
- else if(jkel.equals("wanita")){
- ideal = (tinggi - 100);
- bbi = (ideal -(0.15 * ideal));
- }
- return bbi;
- }
- public double hitung_imt(double tinggi_imt, double berat) {
- double konv , imt ;
- konv = (tinggi_imt / 100); // konversi dari centimeter ke meter
- imt = berat / (konv * konv);
- return imt;
- }
- /**
- * 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">
- private void initComponents() {
- jPanel1 = new javax.swing.JPanel();
- jLabel1 = new javax.swing.JLabel();
- lisen_port = new javax.swing.JTextField();
- jLabel2 = new javax.swing.JLabel();
- jScrollPane1 = new javax.swing.JScrollPane();
- msg = new javax.swing.JTextArea();
- jLabel3 = new javax.swing.JLabel();
- jButton1 = new javax.swing.JButton();
- jLabel4 = new javax.swing.JLabel();
- handler = new javax.swing.JTextField();
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- jPanel1.setBackground(new java.awt.Color(0, 0, 0));
- jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
- jLabel1.setForeground(new java.awt.Color(255, 255, 255));
- jLabel1.setText("PORT :");
- lisen_port.setText("1234");
- jLabel2.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
- jLabel2.setForeground(new java.awt.Color(255, 255, 255));
- jLabel2.setText("XML- RPC SERVER");
- msg.setColumns(20);
- msg.setRows(5);
- jScrollPane1.setViewportView(msg);
- jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
- jLabel3.setForeground(new java.awt.Color(255, 255, 255));
- jLabel3.setText("Log :");
- jButton1.setBackground(new java.awt.Color(255, 0, 0));
- jButton1.setText("Run");
- jButton1.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton1ActionPerformed(evt);
- }
- });
- jLabel4.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
- jLabel4.setForeground(new java.awt.Color(255, 255, 255));
- jLabel4.setText("HANDLER :");
- handler.setText("kunci");
- javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
- jPanel1.setLayout(jPanel1Layout);
- jPanel1Layout.setHorizontalGroup(
- jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel1Layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel1Layout.createSequentialGroup()
- .addComponent(jLabel3)
- .addGap(0, 0, Short.MAX_VALUE))
- .addGroup(jPanel1Layout.createSequentialGroup()
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jScrollPane1)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
- .addComponent(jLabel1)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(lisen_port, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 30, Short.MAX_VALUE)
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jLabel2)
- .addGroup(jPanel1Layout.createSequentialGroup()
- .addComponent(jLabel4)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(handler, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(32, 32, 32)
- .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)))))
- .addContainerGap())))
- );
- jPanel1Layout.setVerticalGroup(
- jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel1Layout.createSequentialGroup()
- .addGap(18, 18, 18)
- .addComponent(jLabel2)
- .addGap(22, 22, 22)
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel1)
- .addComponent(lisen_port, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jLabel4)
- .addComponent(handler, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 34, Short.MAX_VALUE)
- .addComponent(jLabel3)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addContainerGap())
- );
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addContainerGap())
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- );
- pack();
- }// </editor-fold>
- private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
- LocalTime waktu = ZonedDateTime.now().toLocalTime().truncatedTo(ChronoUnit.SECONDS);
- try {
- int port = Integer.parseInt(lisen_port.getText());
- String handle = handler.getText();
- WebServer server = new WebServer(port);
- server.addHandler(handle, new Server_Gui());
- server.start();
- jButton1.setText("Running..");
- jButton1.setBackground(Color.green);
- msg.append(waktu+" |\tServer XML-RPC Sukses dijalankan...\n");
- msg.append(waktu+" |\tServer XML-RPC Handler : "+handle+"\n");
- msg.append(waktu+" |\tServer XML-RPC Host : http://"+InetAddress.getLocalHost().getHostAddress()+":"+port+"/RPC2\n");
- } catch (Exception exception) {
- msg.append(waktu+" |\tserver: " + exception + "\n");
- }
- }
- /**
- * @param args the command line arguments
- */
- public static void main(String args[]) {
- /* Set the Nimbus look and feel */
- //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
- /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
- * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
- */
- try {
- for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
- if ("Nimbus".equals(info.getName())) {
- javax.swing.UIManager.setLookAndFeel(info.getClassName());
- break;
- }
- }
- } catch (ClassNotFoundException ex) {
- java.util.logging.Logger.getLogger(Server_Gui.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (InstantiationException ex) {
- java.util.logging.Logger.getLogger(Server_Gui.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (IllegalAccessException ex) {
- java.util.logging.Logger.getLogger(Server_Gui.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (javax.swing.UnsupportedLookAndFeelException ex) {
- java.util.logging.Logger.getLogger(Server_Gui.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- }
- //</editor-fold>
- /* Create and display the form */
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new Server_Gui().setVisible(true);
- }
- });
- }
- // Variables declaration - do not modify
- private javax.swing.JTextField handler;
- private javax.swing.JButton jButton1;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JLabel jLabel3;
- private javax.swing.JLabel jLabel4;
- private javax.swing.JPanel jPanel1;
- private javax.swing.JScrollPane jScrollPane1;
- private javax.swing.JTextField lisen_port;
- private javax.swing.JTextArea msg;
- // End of variables declaration
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement