hendra_de5

FrmMenu.java

Apr 19th, 2016
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.08 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package aplikasiglobal;
  7.  
  8. import java.awt.Dimension;
  9. import java.awt.Toolkit;
  10. import java.awt.event.ActionEvent;
  11. import java.awt.event.ActionListener;
  12. import java.text.SimpleDateFormat;
  13. import java.util.Date;
  14. import javax.swing.Timer;
  15.  
  16. /**
  17. *
  18. * @author bayhaqi
  19. */
  20. public class FrmMenu extends javax.swing.JFrame {
  21.  
  22. /**
  23. * Creates new form FrmMenu
  24. */
  25. private void makecenter() {
  26. Dimension screenSize
  27. = Toolkit.getDefaultToolkit().getScreenSize();
  28. Dimension frameSize = this.getSize();
  29. if (frameSize.height > screenSize.height) {
  30. frameSize.height = screenSize.height;
  31. }
  32. if (frameSize.width > screenSize.width) {
  33. frameSize.width = screenSize.width;
  34. }
  35. this.setLocation(
  36. (screenSize.width - frameSize.width) / 2,
  37. (screenSize.height - frameSize.height) / 2);
  38. }
  39. public void setJam() {
  40. ActionListener taskPerformer = new ActionListener() {
  41. public void actionPerformed(ActionEvent evt) {
  42. String nol_jam = "", nol_menit = "", nol_detik = "";
  43.  
  44. Date dateTime = new Date();
  45. int nilai_jam = dateTime.getHours();
  46. int nilai_menit = dateTime.getMinutes();
  47. int nilai_detik = dateTime.getSeconds();
  48.  
  49. if (nilai_jam <= 9) nol_jam = "0";
  50. if (nilai_menit <= 9) nol_menit = "0";
  51. if (nilai_detik <= 9) nol_detik = "0";
  52.  
  53. String jam = nol_jam + Integer.toString(nilai_jam);
  54. String menit = nol_menit + Integer.toString(nilai_menit);
  55. String detik = nol_detik + Integer.toString(nilai_detik);
  56.  
  57. waktu.setText(jam + ":" + menit + ":" + detik + " ");
  58. }
  59. };
  60. new Timer(1000, taskPerformer).start();
  61. }
  62.  
  63.  
  64. public void tglskrg(){
  65. Date skrg= new Date();
  66. SimpleDateFormat format= new SimpleDateFormat("EEEEE , dd MMMM yyyy");
  67. String tgl = format.format(skrg);
  68. tanggal.setText(format.format(skrg));
  69.  
  70. }
  71.  
  72. public FrmMenu() {
  73. initComponents();
  74. makecenter();
  75. setJam();
  76. tglskrg();
  77. }
  78.  
  79. /**
  80. * This method is called from within the constructor to initialize the form.
  81. * WARNING: Do NOT modify this code. The content of this method is always
  82. * regenerated by the Form Editor.
  83. */
  84. @SuppressWarnings("unchecked")
  85. // <editor-fold defaultstate="collapsed" desc="Generated Code">
  86. private void initComponents() {
  87.  
  88. jMenuItem4 = new javax.swing.JMenuItem();
  89. jMenuItem5 = new javax.swing.JMenuItem();
  90. tanggal = new javax.swing.JLabel();
  91. waktu = new javax.swing.JLabel();
  92. jLabel2 = new javax.swing.JLabel();
  93. jLabel1 = new javax.swing.JLabel();
  94. jLabel3 = new javax.swing.JLabel();
  95. jLabel4 = new javax.swing.JLabel();
  96. jLabel5 = new javax.swing.JLabel();
  97. jMenuBar1 = new javax.swing.JMenuBar();
  98. jMenu1 = new javax.swing.JMenu();
  99. jMenuItem1 = new javax.swing.JMenuItem();
  100. jMenuItem2 = new javax.swing.JMenuItem();
  101. jMenuItem3 = new javax.swing.JMenuItem();
  102. jMenuItem6 = new javax.swing.JMenuItem();
  103. jMenu2 = new javax.swing.JMenu();
  104. jMenuItem7 = new javax.swing.JMenuItem();
  105. jMenuItem8 = new javax.swing.JMenuItem();
  106.  
  107. jMenuItem4.setText("jMenuItem4");
  108.  
  109. jMenuItem5.setText("jMenuItem5");
  110.  
  111. setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  112.  
  113. tanggal.setFont(new java.awt.Font("Palatino Linotype", 1, 14)); // NOI18N
  114. tanggal.setText("jLabel1");
  115.  
  116. waktu.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
  117. waktu.setText("jLabel2");
  118.  
  119. jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
  120. jLabel1.setText("APLIKASI ABSENSI DAN PENGGAJIAN");
  121.  
  122. jLabel3.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
  123. jLabel3.setText("PT. PARSAORAN GLOBAL DATATRANS");
  124.  
  125. jLabel5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/hsp.jpg"))); // NOI18N
  126.  
  127. jMenu1.setText("Form");
  128.  
  129. jMenuItem1.setText("Master Karyawan");
  130. jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
  131. public void actionPerformed(java.awt.event.ActionEvent evt) {
  132. jMenuItem1ActionPerformed(evt);
  133. }
  134. });
  135. jMenu1.add(jMenuItem1);
  136.  
  137. jMenuItem2.setText("Masuk");
  138. jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
  139. public void actionPerformed(java.awt.event.ActionEvent evt) {
  140. jMenuItem2ActionPerformed(evt);
  141. }
  142. });
  143. jMenu1.add(jMenuItem2);
  144.  
  145. jMenuItem3.setText("Pulang");
  146. jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
  147. public void actionPerformed(java.awt.event.ActionEvent evt) {
  148. jMenuItem3ActionPerformed(evt);
  149. }
  150. });
  151. jMenu1.add(jMenuItem3);
  152.  
  153. jMenuItem6.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.CTRL_MASK));
  154. jMenuItem6.setText("Exit");
  155. jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
  156. public void actionPerformed(java.awt.event.ActionEvent evt) {
  157. jMenuItem6ActionPerformed(evt);
  158. }
  159. });
  160. jMenu1.add(jMenuItem6);
  161.  
  162. jMenuBar1.add(jMenu1);
  163.  
  164. jMenu2.setText("Report");
  165.  
  166. jMenuItem7.setText("Absensi Karyawan");
  167. jMenuItem7.addActionListener(new java.awt.event.ActionListener() {
  168. public void actionPerformed(java.awt.event.ActionEvent evt) {
  169. jMenuItem7ActionPerformed(evt);
  170. }
  171. });
  172. jMenu2.add(jMenuItem7);
  173.  
  174. jMenuItem8.setText("Slip Gaji Karyawan");
  175. jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
  176. public void actionPerformed(java.awt.event.ActionEvent evt) {
  177. jMenuItem8ActionPerformed(evt);
  178. }
  179. });
  180. jMenu2.add(jMenuItem8);
  181.  
  182. jMenuBar1.add(jMenu2);
  183.  
  184. setJMenuBar(jMenuBar1);
  185.  
  186. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  187. getContentPane().setLayout(layout);
  188. layout.setHorizontalGroup(
  189. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  190. .addGroup(layout.createSequentialGroup()
  191. .addGap(53, 53, 53)
  192. .addComponent(jLabel4)
  193. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  194. .addComponent(jLabel5)
  195. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  196. .addComponent(jLabel2)
  197. .addGap(61, 61, 61)
  198. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  199. .addComponent(tanggal, javax.swing.GroupLayout.PREFERRED_SIZE, 227, javax.swing.GroupLayout.PREFERRED_SIZE)
  200. .addComponent(waktu, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE)
  201. .addComponent(jLabel1)
  202. .addComponent(jLabel3))
  203. .addContainerGap(69, Short.MAX_VALUE))
  204. );
  205. layout.setVerticalGroup(
  206. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  207. .addGroup(layout.createSequentialGroup()
  208. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  209. .addGroup(layout.createSequentialGroup()
  210. .addGap(60, 60, 60)
  211. .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 340, javax.swing.GroupLayout.PREFERRED_SIZE))
  212. .addGroup(layout.createSequentialGroup()
  213. .addGap(103, 103, 103)
  214. .addComponent(jLabel4))
  215. .addGroup(layout.createSequentialGroup()
  216. .addGap(144, 144, 144)
  217. .addComponent(tanggal)
  218. .addGap(18, 18, 18)
  219. .addComponent(waktu)
  220. .addGap(44, 44, 44)
  221. .addComponent(jLabel1)
  222. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  223. .addComponent(jLabel3))
  224. .addGroup(layout.createSequentialGroup()
  225. .addGap(68, 68, 68)
  226. .addComponent(jLabel5)))
  227. .addContainerGap(86, Short.MAX_VALUE))
  228. );
  229.  
  230. pack();
  231. }// </editor-fold>
  232.  
  233. private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {
  234. // TODO add your handling code here:
  235. System.exit(0);
  236. }
  237.  
  238. private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {
  239. // TODO add your handling code here:
  240. new FrmKeluar().setVisible(true);
  241. }
  242.  
  243. private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {
  244. // TODO add your handling code here:
  245. new FrmMasuk().setVisible(true);
  246. }
  247.  
  248. private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {
  249. // TODO add your handling code here:
  250. new FrmPegawai().setVisible(true);
  251. }
  252.  
  253. private void jMenuItem7ActionPerformed(java.awt.event.ActionEvent evt) {
  254. // TODO add your handling code here:
  255. new FrmReportGaji().setVisible(true);
  256. }
  257.  
  258. private void jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt) {
  259. // TODO add your handling code here:
  260. new FrmReportslipglobal().setVisible(true);
  261. }
  262.  
  263. /**
  264. * @param args the command line arguments
  265. */
  266. public static void main(String args[]) {
  267. /* Set the Nimbus look and feel */
  268. //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  269. /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  270. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  271. */
  272. try {
  273. for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  274. if ("Nimbus".equals(info.getName())) {
  275. javax.swing.UIManager.setLookAndFeel(info.getClassName());
  276. break;
  277. }
  278. }
  279. } catch (ClassNotFoundException ex) {
  280. java.util.logging.Logger.getLogger(FrmMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  281. } catch (InstantiationException ex) {
  282. java.util.logging.Logger.getLogger(FrmMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  283. } catch (IllegalAccessException ex) {
  284. java.util.logging.Logger.getLogger(FrmMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  285. } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  286. java.util.logging.Logger.getLogger(FrmMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  287. }
  288. //</editor-fold>
  289. //</editor-fold>
  290. //</editor-fold>
  291. //</editor-fold>
  292.  
  293. /* Create and display the form */
  294. java.awt.EventQueue.invokeLater(new Runnable() {
  295. public void run() {
  296. new FrmMenu().setVisible(true);
  297. }
  298. });
  299. }
  300.  
  301. // Variables declaration - do not modify
  302. private javax.swing.JLabel jLabel1;
  303. private javax.swing.JLabel jLabel2;
  304. private javax.swing.JLabel jLabel3;
  305. private javax.swing.JLabel jLabel4;
  306. private javax.swing.JLabel jLabel5;
  307. private javax.swing.JMenu jMenu1;
  308. private javax.swing.JMenu jMenu2;
  309. private javax.swing.JMenuBar jMenuBar1;
  310. private javax.swing.JMenuItem jMenuItem1;
  311. private javax.swing.JMenuItem jMenuItem2;
  312. private javax.swing.JMenuItem jMenuItem3;
  313. private javax.swing.JMenuItem jMenuItem4;
  314. private javax.swing.JMenuItem jMenuItem5;
  315. private javax.swing.JMenuItem jMenuItem6;
  316. private javax.swing.JMenuItem jMenuItem7;
  317. private javax.swing.JMenuItem jMenuItem8;
  318. private javax.swing.JLabel tanggal;
  319. private javax.swing.JLabel waktu;
  320. // End of variables declaration
  321. }
Add Comment
Please, Sign In to add comment