/** Initializes contained components. */ private void initComponents() { final SimpleDateFormat format = new SimpleDateFormat("mm:ss"); final Calendar c = Calendar.getInstance(); final JLabel counter = new JLabel(); counter.setForeground(Color.red); counter.setFont(counter.getFont().deriveFont((float) (counter.getFont().getSize() + 5))); setLayout(new GridBagLayout()); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); GridBagConstraints constraints = new GridBagConstraints(); JLabel messageLabel = new JLabel( GuiActivator.getResources().getI18NString("service.gui.security.SECURITY_ALERT")); messageLabel.setForeground(Color.WHITE); constraints.anchor = GridBagConstraints.CENTER; constraints.fill = GridBagConstraints.NONE; constraints.gridx = 0; constraints.gridy = 0; add(messageLabel, constraints); constraints.anchor = GridBagConstraints.CENTER; constraints.fill = GridBagConstraints.NONE; constraints.gridx = 0; constraints.gridy = 1; add(counter, constraints); ZrtpControl zrtpControl = null; if (securityControl instanceof ZrtpControl) zrtpControl = (ZrtpControl) securityControl; long initialSeconds = 0; if (zrtpControl != null) initialSeconds = zrtpControl.getTimeoutValue(); c.setTimeInMillis(initialSeconds); counter.setText(format.format(c.getTime())); if (initialSeconds > 0) timer.schedule( new TimerTask() { @Override public void run() { if (c.getTimeInMillis() - 1000 > 0) { c.add(Calendar.SECOND, -1); counter.setText(format.format(c.getTime())); } } }, 1000, 1000); }
public void setSelectedItem(Object anItem) { if (anItem == null) { return; } if (anItem instanceof Date) { try { selectedDate = this.dateFormat.format((Date) anItem); } catch (Exception ex) { ex.printStackTrace(); } } else { try { String strDate = anItem.toString().trim(); if (strDate.length() != 10 && strDate.length() != 19) { return; } String pattern = dateFormat.toPattern(); if (strDate.length() == 10 && pattern.length() == 19) { strDate = strDate + selectedDate.substring(10); } dateFormat.parse(strDate); selectedDate = strDate; } catch (Exception ex) { throw new UnsupportedOperationException( "Invalid datetime: string [" + anItem + "], format is [" + dateFormat.toPattern() + "]. "); } } fireContentsChanged(this, -1, -1); }
protected void load() throws IOException { BufferedReader is = new BufferedReader(new FileReader("ReminderService.txt")); SimpleDateFormat formatter = new SimpleDateFormat("yyyy MM dd hh mm"); String aLine; while ((aLine = is.readLine()) != null) { ParsePosition pp = new ParsePosition(0); Date date = formatter.parse(aLine, pp); if (date == null) { message("Invalid date in " + aLine); continue; } String mesg = aLine.substring(pp.getIndex()); l.add(new Item(date, mesg)); } }
/** * isValidDate tests a string to see whether it is a valid date. * * @param date * @return true if valid date, false if not valid */ public static boolean isValidDate(String date) { SimpleDateFormat sdf = new SimpleDateFormat("MMM d, yyyy"); Date testDate = null; try { testDate = sdf.parse(date); } catch (ParseException e) { return false; } if (!sdf.format(testDate).equals(date)) { return false; } return true; }
public void setFecha(String val) { try { fecha.setDate(sdf.parse(val)); } catch (Exception e) { omoikane.sistema.Dialogos.lanzarDialogoError( null, "Error en el registro: Fecha inválida", omoikane.sistema.Herramientas.getStackTraceString(e)); } }
/*========================================================== * public methods *==========================================================*/ public Vector parse(Object entry) throws ParseException { String logEntry = (String) entry; // parsing the log Entry and return segments // Debug.println("LogDataModel: DefaultLogParser: parse() -" +logEntry); int x = logEntry.indexOf("["); if (x == -1) throw new ParseException(logEntry, 0); String temp = logEntry.substring(x + 1); x = temp.indexOf("]"); if (x == -1) throw new ParseException(logEntry, 0); String dateStr = temp.substring(0, x); // Debug.println("LogDataModel: DefaultLogParser: parse() -"+dateStr+" "+temp); SimpleDateFormat format = new SimpleDateFormat(DATE_PATTERN); Date date = format.parse(dateStr); String dateColumn = DateFormat.getDateInstance().format(date); String timeColumn = DateFormat.getTimeInstance().format(date); // Debug.println("LogDataModel: DefaultLogParser: parse() -"+dateColumn+" "+timeColumn); temp = temp.substring(x + 2); x = temp.indexOf("]"); if (x == -1) throw new ParseException(logEntry, 0); String source = temp.substring(1, x); temp = temp.substring(x + 2); x = temp.indexOf("]"); if (x == -1) throw new ParseException(logEntry, 0); String level = temp.substring(1, x); temp = temp.substring(x + 2); Vector row = new Vector(); row.addElement(getSourceString(source)); row.addElement(getLevelString(level)); row.addElement(dateColumn); row.addElement(timeColumn); JLabel detail = new JLabel(temp); detail.setToolTipText(temp); row.addElement(detail); return row; }
public String getFecha() { return (String) sdf.format(this.fecha.getDate()); }
public class FrmMainMenu extends javax.swing.JFrame { private Date activeDate = new Date(); private SimpleDateFormat sdf = new SimpleDateFormat("dd MMM yyyy", Locale.getDefault()); private String date = sdf.format(activeDate); private String PROP_FILE = "initial.ini"; int top = 70; int left = 150; private static Properties loadProperties(String sFile) { Properties p = new Properties(); try { FileInputStream in = new FileInputStream(sFile); p.load(in); in.close(); } catch (IOException iOException) { JOptionPane.showMessageDialog(null, iOException); } return p; } void setLookAndFeel() { Properties p2 = new Properties(); p2 = loadProperties(PROP_FILE); String skin = p2.getProperty("Skin"); if (skin == null) { skin = "0"; } int skinInt = Integer.valueOf(skin).intValue(); try { if (skinInt == 0) { UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } else if (skinInt == 1) { UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); } else { UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); } } catch (Exception e) { System.out.println(e.toString()); } } public FrmMainMenu() { Data user = new Data(); String UserID; String UserName; UserID = user.getUserID().trim(); UserName = user.getUserName().trim(); setLookAndFeel(); initComponents(); txtUserID.setText(UserID.toString().trim()); txtUserName.setText(UserName.toString().trim()); lbDate.setText(date); setTime(); lbYear.setText(user.getActivePeriod()); checkUserAuthorization(); } void checkUserAuthorization() { Data User = new Data(); mnMasterUser.setEnabled( User.UserRight(txtUserID.getText().trim(), "MST-001", Data.typeOfAction.View)); mnUserFunction.setEnabled( User.UserRight(txtUserID.getText().trim(), "MST-002", Data.typeOfAction.View)); mnMasterBudgetGroup.setEnabled( User.UserRight(txtUserID.getText().trim(), "MST-003", Data.typeOfAction.View)); mnMasterBudgetDetail.setEnabled( User.UserRight(txtUserID.getText().trim(), "MST-004", Data.typeOfAction.View)); mnMasterTitle.setEnabled( User.UserRight(txtUserID.getText().trim(), "MST-005", Data.typeOfAction.View)); mnMasterEmployee.setEnabled( User.UserRight(txtUserID.getText().trim(), "MST-006", Data.typeOfAction.View)); mnTransactionBeginningBalance.setEnabled( User.UserRight(txtUserID.getText().trim(), "TSK-001", Data.typeOfAction.View)); mnTransactionBudgetUsage.setEnabled( User.UserRight(txtUserID.getText().trim(), "TSK-002", Data.typeOfAction.View)); mnTransactionBudgetTransfer.setEnabled( User.UserRight(txtUserID.getText().trim(), "TSK-003", Data.typeOfAction.View)); mnTransactionEndofYear.setEnabled( User.UserRight(txtUserID.getText().trim(), "TSK-004", Data.typeOfAction.View)); mnRptMasterBudget.setEnabled( User.UserRight(txtUserID.getText().trim(), "RPT-001", Data.typeOfAction.View)); mnRptBudgetUsage.setEnabled( User.UserRight(txtUserID.getText().trim(), "RPT-002", Data.typeOfAction.View)); mnRptTrxBudgetUsage.setEnabled( User.UserRight(txtUserID.getText().trim(), "RPT-003", Data.typeOfAction.View)); mnRptTrxBudgetTransfer.setEnabled( User.UserRight(txtUserID.getText().trim(), "RPT-004", Data.typeOfAction.View)); } void setTime() { ActionListener taskPerformer = new ActionListener() { public void actionPerformed(ActionEvent evt) { String zero_hour = "", zero_minute = "", zero_second = ""; Date dateTime = new Date(); int int_hour = dateTime.getHours(); int int_minute = dateTime.getMinutes(); int int_second = dateTime.getSeconds(); if (int_hour <= 9) zero_hour = "0"; if (int_minute <= 9) zero_minute = "0"; if (int_second <= 9) zero_second = "0"; String hour = zero_hour + Integer.toString(int_hour); String minute = zero_minute + Integer.toString(int_minute); String second = zero_second + Integer.toString(int_second); lbHour.setText(hour + ":" + minute + ":" + second + " "); } }; new Timer(1000, taskPerformer).start(); } // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jToolBar1 = new javax.swing.JToolBar(); jPanel1 = new javax.swing.JPanel(); txtUserID = new javax.swing.JTextField(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); txtUserName = new javax.swing.JTextField(); lbHour = new javax.swing.JLabel(); lbDate = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); lbYear = new javax.swing.JLabel(); jMenuBar1 = new javax.swing.JMenuBar(); mnMaster = new javax.swing.JMenu(); mnMasterTitle = new javax.swing.JMenuItem(); mnMasterEmployee = new javax.swing.JMenuItem(); mnMasterBudgetGroup = new javax.swing.JMenuItem(); mnMasterBudgetDetail = new javax.swing.JMenuItem(); mnTransaction = new javax.swing.JMenu(); mnTransactionBeginningBalance = new javax.swing.JMenuItem(); mnTransactionBudgetUsage = new javax.swing.JMenuItem(); mnTransactionBudgetTransfer = new javax.swing.JMenuItem(); mnTransactionEndofYear = new javax.swing.JMenuItem(); mnLaporan = new javax.swing.JMenu(); mnRptMasterBudget = new javax.swing.JMenuItem(); mnRptBudgetUsage = new javax.swing.JMenuItem(); mnRptTrxBudgetUsage = new javax.swing.JMenuItem(); mnRptTrxBudgetTransfer = new javax.swing.JMenuItem(); mnUser = new javax.swing.JMenu(); mnMasterUser = new javax.swing.JMenuItem(); mnUserFunction = new javax.swing.JMenuItem(); mnChangePassword = new javax.swing.JMenuItem(); mnExit = new javax.swing.JMenu(); mnLogOff = new javax.swing.JMenuItem(); mnExitExit = new javax.swing.JMenuItem(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("OPC Budget Controlling Program"); addWindowListener( new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { FrmMainMenu.this.windowClosing(evt); } }); jToolBar1.setRollover(true); jPanel1.setBackground(new java.awt.Color(255, 51, 51)); txtUserID.setBackground(new java.awt.Color(204, 255, 204)); txtUserID.setFont(new java.awt.Font("Tahoma", 1, 12)); txtUserID.setDisabledTextColor(new java.awt.Color(255, 51, 51)); txtUserID.setEnabled(false); jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12)); jLabel1.setText("User ID"); jLabel2.setFont(new java.awt.Font("Tahoma", 1, 12)); jLabel2.setText("User Name"); txtUserName.setBackground(new java.awt.Color(204, 255, 204)); txtUserName.setFont(new java.awt.Font("Tahoma", 1, 12)); txtUserName.setDisabledTextColor(new java.awt.Color(255, 51, 51)); txtUserName.setEnabled(false); lbHour.setBackground(new java.awt.Color(51, 51, 255)); lbHour.setFont(new java.awt.Font("Tahoma", 1, 12)); lbHour.setForeground(new java.awt.Color(51, 255, 51)); lbDate.setBackground(new java.awt.Color(51, 51, 255)); lbDate.setFont(new java.awt.Font("Tahoma", 1, 12)); lbDate.setForeground(new java.awt.Color(51, 255, 51)); jLabel3.setFont(new java.awt.Font("Tahoma", 1, 12)); jLabel3.setText("Budget Year"); lbYear.setBackground(new java.awt.Color(51, 51, 255)); lbYear.setFont(new java.awt.Font("Tahoma", 1, 12)); lbYear.setForeground(new java.awt.Color(51, 255, 51)); org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add( jPanel1Layout .createSequentialGroup() .addContainerGap() .add(jLabel1) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add( txtUserID, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 123, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(18, 18, 18) .add( jLabel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add( txtUserName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 133, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(26, 26, 26) .add( lbDate, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 123, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) .add( lbHour, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 85, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(75, 75, 75) .add( jLabel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) .add( lbYear, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 62, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(50, 50, 50))); jPanel1Layout.setVerticalGroup( jPanel1Layout .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add( jPanel1Layout .createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add( txtUserID, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(jLabel1) .add( txtUserName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(jLabel2) .add( lbDate, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add( lbHour, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add( lbYear, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(jLabel3))); jToolBar1.add(jPanel1); mnMaster.setBackground(new java.awt.Color(204, 255, 255)); mnMaster.setText("Master"); mnMaster.setFont(new java.awt.Font("Tahoma", 1, 12)); mnMasterTitle.setAccelerator( javax.swing.KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_L, java.awt.event.InputEvent.CTRL_MASK)); mnMasterTitle.setBackground(new java.awt.Color(255, 255, 204)); mnMasterTitle.setFont(new java.awt.Font("Tahoma", 1, 12)); mnMasterTitle.setText("Title"); mnMasterTitle.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnMasterTitleActionPerformed(evt); } }); mnMaster.add(mnMasterTitle); mnMasterEmployee.setAccelerator( javax.swing.KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_Y, java.awt.event.InputEvent.CTRL_MASK)); mnMasterEmployee.setBackground(new java.awt.Color(255, 255, 204)); mnMasterEmployee.setFont(new java.awt.Font("Tahoma", 1, 12)); mnMasterEmployee.setText("Employee"); mnMasterEmployee.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnMasterEmployeeActionPerformed(evt); } }); mnMaster.add(mnMasterEmployee); mnMasterBudgetGroup.setAccelerator( javax.swing.KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_G, java.awt.event.InputEvent.CTRL_MASK)); mnMasterBudgetGroup.setBackground(new java.awt.Color(255, 255, 204)); mnMasterBudgetGroup.setFont(new java.awt.Font("Tahoma", 1, 12)); mnMasterBudgetGroup.setText("Budget Group"); mnMasterBudgetGroup.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnMasterBudgetGroupActionPerformed(evt); } }); mnMaster.add(mnMasterBudgetGroup); mnMasterBudgetDetail.setAccelerator( javax.swing.KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_D, java.awt.event.InputEvent.CTRL_MASK)); mnMasterBudgetDetail.setBackground(new java.awt.Color(255, 255, 204)); mnMasterBudgetDetail.setFont(new java.awt.Font("Tahoma", 1, 12)); mnMasterBudgetDetail.setText("Budget Detail"); mnMasterBudgetDetail.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnMasterBudgetDetailActionPerformed(evt); } }); mnMaster.add(mnMasterBudgetDetail); jMenuBar1.add(mnMaster); mnTransaction.setBackground(new java.awt.Color(204, 255, 255)); mnTransaction.setText("Transaction"); mnTransaction.setFont(new java.awt.Font("Tahoma", 1, 12)); mnTransactionBeginningBalance.setAccelerator( javax.swing.KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK)); mnTransactionBeginningBalance.setBackground(new java.awt.Color(255, 255, 204)); mnTransactionBeginningBalance.setFont(new java.awt.Font("Tahoma", 1, 12)); mnTransactionBeginningBalance.setText("Beginning Balance"); mnTransactionBeginningBalance.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnTransactionBeginningBalanceActionPerformed(evt); } }); mnTransaction.add(mnTransactionBeginningBalance); mnTransactionBudgetUsage.setAccelerator( javax.swing.KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_P, java.awt.event.InputEvent.CTRL_MASK)); mnTransactionBudgetUsage.setBackground(new java.awt.Color(255, 255, 204)); mnTransactionBudgetUsage.setFont(new java.awt.Font("Tahoma", 1, 12)); mnTransactionBudgetUsage.setText("Budget Usage"); mnTransactionBudgetUsage.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnTransactionBudgetUsageActionPerformed(evt); } }); mnTransaction.add(mnTransactionBudgetUsage); mnTransactionBudgetTransfer.setAccelerator( javax.swing.KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_F, java.awt.event.InputEvent.CTRL_MASK)); mnTransactionBudgetTransfer.setBackground(new java.awt.Color(255, 255, 204)); mnTransactionBudgetTransfer.setFont(new java.awt.Font("Tahoma", 1, 12)); mnTransactionBudgetTransfer.setText("Budget Transfer"); mnTransactionBudgetTransfer.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnTransactionBudgetTransferActionPerformed(evt); } }); mnTransaction.add(mnTransactionBudgetTransfer); mnTransactionEndofYear.setAccelerator( javax.swing.KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_T, java.awt.event.InputEvent.CTRL_MASK)); mnTransactionEndofYear.setBackground(new java.awt.Color(255, 255, 204)); mnTransactionEndofYear.setFont(new java.awt.Font("Tahoma", 1, 12)); mnTransactionEndofYear.setText("End of Year"); mnTransactionEndofYear.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnTransactionEndofYearActionPerformed(evt); } }); mnTransaction.add(mnTransactionEndofYear); jMenuBar1.add(mnTransaction); mnLaporan.setBackground(new java.awt.Color(204, 255, 255)); mnLaporan.setText("Report"); mnLaporan.setFont(new java.awt.Font("Tahoma", 1, 12)); mnRptMasterBudget.setBackground(new java.awt.Color(255, 255, 204)); mnRptMasterBudget.setFont(new java.awt.Font("Tahoma", 1, 12)); mnRptMasterBudget.setText("Master Budget"); mnRptMasterBudget.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnRptMasterBudgetActionPerformed(evt); } }); mnLaporan.add(mnRptMasterBudget); mnRptBudgetUsage.setBackground(new java.awt.Color(255, 255, 204)); mnRptBudgetUsage.setFont(new java.awt.Font("Tahoma", 1, 12)); mnRptBudgetUsage.setText("Budget Detail Per Month"); mnRptBudgetUsage.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnRptBudgetUsageActionPerformed(evt); } }); mnLaporan.add(mnRptBudgetUsage); mnRptTrxBudgetUsage.setBackground(new java.awt.Color(255, 255, 204)); mnRptTrxBudgetUsage.setFont(new java.awt.Font("Tahoma", 1, 12)); mnRptTrxBudgetUsage.setText("Trx. Budget Usage"); mnRptTrxBudgetUsage.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnRptTrxBudgetUsageActionPerformed(evt); } }); mnLaporan.add(mnRptTrxBudgetUsage); mnRptTrxBudgetTransfer.setBackground(new java.awt.Color(255, 255, 204)); mnRptTrxBudgetTransfer.setFont(new java.awt.Font("Tahoma", 1, 12)); mnRptTrxBudgetTransfer.setText("Trx. Budget Transfer"); mnRptTrxBudgetTransfer.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnRptTrxBudgetTransferActionPerformed(evt); } }); mnLaporan.add(mnRptTrxBudgetTransfer); jMenuBar1.add(mnLaporan); mnUser.setBackground(new java.awt.Color(204, 255, 255)); mnUser.setText("Users Management"); mnUser.setFont(new java.awt.Font("Tahoma", 1, 12)); mnMasterUser.setAccelerator( javax.swing.KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_F5, java.awt.event.InputEvent.CTRL_MASK)); mnMasterUser.setBackground(new java.awt.Color(255, 255, 204)); mnMasterUser.setFont(new java.awt.Font("Tahoma", 1, 12)); mnMasterUser.setText("User"); mnMasterUser.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnMasterUserActionPerformed(evt); } }); mnUser.add(mnMasterUser); mnUserFunction.setAccelerator( javax.swing.KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_F6, java.awt.event.InputEvent.CTRL_MASK)); mnUserFunction.setBackground(new java.awt.Color(255, 255, 204)); mnUserFunction.setFont(new java.awt.Font("Tahoma", 1, 12)); mnUserFunction.setText("User Functions"); mnUserFunction.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnUserFunctionActionPerformed(evt); } }); mnUser.add(mnUserFunction); mnChangePassword.setAccelerator( javax.swing.KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_F7, java.awt.event.InputEvent.CTRL_MASK)); mnChangePassword.setBackground(new java.awt.Color(255, 255, 204)); mnChangePassword.setFont(new java.awt.Font("Tahoma", 1, 12)); mnChangePassword.setText("Change Password"); mnChangePassword.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnChangePasswordActionPerformed(evt); } }); mnUser.add(mnChangePassword); jMenuBar1.add(mnUser); mnExit.setBackground(new java.awt.Color(204, 255, 255)); mnExit.setText("Exit"); mnExit.setFont(new java.awt.Font("Tahoma", 1, 12)); mnLogOff.setAccelerator( javax.swing.KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK)); mnLogOff.setBackground(new java.awt.Color(255, 255, 204)); mnLogOff.setFont(new java.awt.Font("Tahoma", 1, 12)); mnLogOff.setText("Log Off"); mnLogOff.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnLogOffActionPerformed(evt); } }); mnExit.add(mnLogOff); mnExitExit.setAccelerator( javax.swing.KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_E, java.awt.event.InputEvent.CTRL_MASK)); mnExitExit.setBackground(new java.awt.Color(255, 255, 204)); mnExitExit.setFont(new java.awt.Font("Tahoma", 1, 12)); mnExitExit.setText("Exit"); mnExitExit.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnExitExitActionPerformed(evt); } }); mnExit.add(mnExitExit); jMenuBar1.add(mnExit); setJMenuBar(jMenuBar1); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jToolBar1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 925, Short.MAX_VALUE)); layout.setVerticalGroup( layout .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add( layout .createSequentialGroup() .add( jToolBar1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 25, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addContainerGap(649, Short.MAX_VALUE))); pack(); java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); java.awt.Dimension dialogSize = getSize(); setLocation( (screenSize.width - dialogSize.width) / 2, (screenSize.height - dialogSize.height) / 2); } // </editor-fold>//GEN-END:initComponents private void mnMasterUserActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_mnMasterUserActionPerformed FrmMasterUser frmUser = new FrmMasterUser(); frmUser.setBounds(left, top, 450, 565); frmUser.setVisible(true); } // GEN-LAST:event_mnMasterUserActionPerformed private void mnMasterBudgetGroupActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_mnMasterBudgetGroupActionPerformed FrmMasterBudgetGroup frm = new FrmMasterBudgetGroup(); frm.setBounds(left, top, 520, 580); frm.setVisible(true); } // GEN-LAST:event_mnMasterBudgetGroupActionPerformed private void mnChangePasswordActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_mnChangePasswordActionPerformed FrmChangePassword frmPassword = new FrmChangePassword(); frmPassword.setBounds(left, top, 290, 180); frmPassword.setVisible(true); } // GEN-LAST:event_mnChangePasswordActionPerformed private void mnMasterBudgetDetailActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_mnMasterBudgetDetailActionPerformed FrmMasterBudget frmBudget = new FrmMasterBudget(); frmBudget.setBounds(left, top, 610, 630); frmBudget.setVisible(true); } // GEN-LAST:event_mnMasterBudgetDetailActionPerformed private void mnUserFunctionActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_mnUserFunctionActionPerformed FrmMasterUserFunction frmFunction = new FrmMasterUserFunction(); frmFunction.setBounds(left, top, 660, 400); frmFunction.setVisible(true); } // GEN-LAST:event_mnUserFunctionActionPerformed private void mnTransactionBeginningBalanceActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_mnTransactionBeginningBalanceActionPerformed FrmTrxBeginningBalance frmTrx = new FrmTrxBeginningBalance(); frmTrx.setBounds(left, top, 560, 580); frmTrx.setVisible(true); } // GEN-LAST:event_mnTransactionBeginningBalanceActionPerformed private void mnTransactionBudgetUsageActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_mnTransactionBudgetUsageActionPerformed FrmTrxBudgetUsage frmTrx = new FrmTrxBudgetUsage(); frmTrx.setBounds(left, top, 560, 540); frmTrx.setVisible(true); } // GEN-LAST:event_mnTransactionBudgetUsageActionPerformed private void mnTransactionEndofYearActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_mnTransactionEndofYearActionPerformed FrmTrxEndofYear frmTrx = new FrmTrxEndofYear(); frmTrx.setBounds(left, top, 360, 250); frmTrx.setVisible(true); } // GEN-LAST:event_mnTransactionEndofYearActionPerformed private void mnTransactionBudgetTransferActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_mnTransactionBudgetTransferActionPerformed FrmTrxBudgetTransfer frmTrx = new FrmTrxBudgetTransfer(); frmTrx.setBounds(left, top, 570, 460); frmTrx.setVisible(true); } // GEN-LAST:event_mnTransactionBudgetTransferActionPerformed private void mnRptMasterBudgetActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_mnRptMasterBudgetActionPerformed FrmRptMasterBudget frmRpt = new FrmRptMasterBudget("RPT-001"); frmRpt.setBounds(left, top, 400, 210); frmRpt.setVisible(true); } // GEN-LAST:event_mnRptMasterBudgetActionPerformed private void mnRptBudgetUsageActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_mnRptBudgetUsageActionPerformed FrmRptMasterBudget frmRpt = new FrmRptMasterBudget("RPT-002"); frmRpt.setBounds(left, top, 400, 210); frmRpt.setVisible(true); } // GEN-LAST:event_mnRptBudgetUsageActionPerformed private void mnLogOffActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_mnLogOffActionPerformed int reply = JOptionPane.showConfirmDialog( this, "Do you want to re-login ?", "Budget", JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE); if (reply == JOptionPane.YES_OPTION) { setVisible(false); dispose(); FrmLogin login = new FrmLogin(); login.setVisible(true); login.pack(); } } // GEN-LAST:event_mnLogOffActionPerformed private void mnExitExitActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_mnExitExitActionPerformed int reply = JOptionPane.showConfirmDialog( this, "Do you want to exit from the System ?", "Budget", JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE); if (reply == JOptionPane.YES_OPTION) { dispose(); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); System.exit(0); } } // GEN-LAST:event_mnExitExitActionPerformed private void mnRptTrxBudgetUsageActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_mnRptTrxBudgetUsageActionPerformed FrmRptBudgetUsage frmRpt = new FrmRptBudgetUsage(); frmRpt.setBounds(left, top, 400, 190); frmRpt.setVisible(true); } // GEN-LAST:event_mnRptTrxBudgetUsageActionPerformed private void mnRptTrxBudgetTransferActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_mnRptTrxBudgetTransferActionPerformed FrmRptBudgetTransfer frmRpt = new FrmRptBudgetTransfer(); frmRpt.setBounds(left, top, 260, 160); frmRpt.setVisible(true); } // GEN-LAST:event_mnRptTrxBudgetTransferActionPerformed private void windowClosing(java.awt.event.WindowEvent evt) { // GEN-FIRST:event_windowClosing System.exit(0); } // GEN-LAST:event_windowClosing private void mnMasterEmployeeActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_mnMasterEmployeeActionPerformed FrmMasterEmployee frm = new FrmMasterEmployee(); frm.setBounds(left, top, 610, 580); frm.setVisible(true); } // GEN-LAST:event_mnMasterEmployeeActionPerformed private void mnMasterTitleActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_mnMasterTitleActionPerformed FrmMasterTitle frm = new FrmMasterTitle(); frm.setBounds(left, top, 550, 550); frm.setVisible(true); } // GEN-LAST:event_mnMasterTitleActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JMenuBar jMenuBar1; private javax.swing.JPanel jPanel1; private javax.swing.JToolBar jToolBar1; private javax.swing.JLabel lbDate; private javax.swing.JLabel lbHour; private javax.swing.JLabel lbYear; private javax.swing.JMenuItem mnChangePassword; private javax.swing.JMenu mnExit; private javax.swing.JMenuItem mnExitExit; private javax.swing.JMenu mnLaporan; private javax.swing.JMenuItem mnLogOff; private javax.swing.JMenu mnMaster; private javax.swing.JMenuItem mnMasterBudgetDetail; private javax.swing.JMenuItem mnMasterBudgetGroup; private javax.swing.JMenuItem mnMasterEmployee; private javax.swing.JMenuItem mnMasterTitle; private javax.swing.JMenuItem mnMasterUser; private javax.swing.JMenuItem mnRptBudgetUsage; private javax.swing.JMenuItem mnRptMasterBudget; private javax.swing.JMenuItem mnRptTrxBudgetTransfer; private javax.swing.JMenuItem mnRptTrxBudgetUsage; private javax.swing.JMenu mnTransaction; private javax.swing.JMenuItem mnTransactionBeginningBalance; private javax.swing.JMenuItem mnTransactionBudgetTransfer; private javax.swing.JMenuItem mnTransactionBudgetUsage; private javax.swing.JMenuItem mnTransactionEndofYear; private javax.swing.JMenu mnUser; private javax.swing.JMenuItem mnUserFunction; private javax.swing.JTextField txtUserID; private javax.swing.JTextField txtUserName; // End of variables declaration//GEN-END:variables }
/** Creates new form frmAsignarTransporte */ public frmAsignarTransporte() { initComponents(); gestorH.actualizarUsuario(labelusuario); txtFecha.setEditable(false); txtFecha.setEnabled(false); txtHora.setEditable(false); txtHora.setEnabled(false); // setear el campo de fecha con la del sistema GregorianCalendar gc = new GregorianCalendar(); GregorianCalendar.getInstance(); gc.setTimeZone(TimeZone.getTimeZone("GMT-3")); gc.get(Calendar.DAY_OF_WEEK); gc.get(Calendar.MONTH); gc.get(Calendar.YEAR); SimpleDateFormat formateador = new SimpleDateFormat("dd-MM-yyyy"); txtFecha.setText(formateador.format(gc.getTime())); // setear el campo de hora con la del sistema GregorianCalendar calendario = new GregorianCalendar(); GregorianCalendar.getInstance(); gc.setTimeZone(TimeZone.getTimeZone("GMT-3")); calendario.get(Calendar.HOUR); calendario.get(Calendar.MINUTE); SimpleDateFormat formateadorHora = new SimpleDateFormat("HH:mm"); txtHora.setText(formateadorHora.format(calendario.getTime())); // Las siguientes lineas son para dar a la pantalla el tamaño requerido y luego centrarla en la // pantalla. Toolkit kit = Toolkit.getDefaultToolkit(); Dimension tamanioPantalla = kit.getScreenSize(); int ancho = 820; int alto = 570; // int posX = (int) ((tamanioPantalla.width - ancho) / 2); // int posY = (int) ((tamanioPantalla.height - alto) / 2); this.setSize(ancho, alto); this.setLocation(260, 30); // redimensionar columnas tabla tblViaje.getColumnModel().getColumn(0).setPreferredWidth(50); tblViaje.getColumnModel().getColumn(1).setPreferredWidth(50); tblViaje.getColumnModel().getColumn(2).setPreferredWidth(100); tblVehiculo.getColumnModel().getColumn(0).setPreferredWidth(100); tblVehiculo.getColumnModel().getColumn(1).setPreferredWidth(100); // centrar cabecera jtable DefaultTableCellRenderer renderer = (DefaultTableCellRenderer) tblVehiculo.getTableHeader().getDefaultRenderer(); renderer.setHorizontalAlignment(0); DefaultTableCellRenderer renderer2 = (DefaultTableCellRenderer) tblViaje.getTableHeader().getDefaultRenderer(); renderer2.setHorizontalAlignment(0); Iterator ite = gestorH.listarClase(Viaje.class).iterator(); SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yy"); SimpleDateFormat sdfguion = new SimpleDateFormat("dd-MM-yyyy"); while (ite.hasNext()) { Viaje viaje = (Viaje) ite.next(); Date fecha1 = sdf.parse(viaje.getFecha(), new ParsePosition(0)); Date fecha3 = sdfguion.parse(txtFecha.getText(), new ParsePosition(0)); if (viaje.getEstado().equalsIgnoreCase("En Proceso") && (viaje.getTipoViaje().getNombreTipoViaje().equalsIgnoreCase("Traslado a Puerto") || viaje .getTipoViaje() .getNombreTipoViaje() .equalsIgnoreCase("Traslado a Establecimiento"))) { if (fecha1.before(fecha3)) { viaje.setEstado("Finalizado"); viaje.getVehiculo().setEstado("Disponible"); } } } gestorA.RellenarTablaViajes(tblViaje); }
// method to display current Person object in the ArrayList // uses global index ?? private void displayRecord() { p = (Person) persons.get(index); n.setText(p.name); d.setText(f.format(p.date)); }
private String formatDate(Date myDate) { String strFormat = "yyyy-MM-dd HH:mm:ss"; SimpleDateFormat formatter = new SimpleDateFormat(strFormat); String strDate = formatter.format(myDate); return strDate; }
public void update(MultihopMsg msg) { String info; SurgeMsg SMsg = new SurgeMsg(msg.dataGet(), msg.offset_data(0)); if (SMsg.get_type() == 0) { if (SMsg.get_parentaddr() == MainFrame.BEACON_BASE_ADDRESS) { isDirectChild = true; } else { isDirectChild = false; } // Update message count and rate // Only update if this message is coming to the root from // a direct child int saddr = msg.get_sourceaddr(); NodeInfo ni = (NodeInfo) SensorAnalyzer.proprietaryNodeInfo.get(new Integer(saddr)); if (ni != null) { if (ni.isDirectChild) { msgCount++; int new_seq_no = (int) SMsg.get_seq_no() & 0x7fffff; if (stats_start_sequence_number == 0) stats_start_sequence_number = new_seq_no; if (seq_no == 0) seq_no = new_seq_no - 1; int diff = new_seq_no - seq_no; if (diff > 1000) diff = 1; active = true; long curtime = System.currentTimeMillis(); packetTimes[packetTimesPointer++] = curtime - lastTime; packetTimesPointer %= SensorAnalyzer.HISTORY_LENGTH; packetSkips[packetSkipsPointer++] = diff; packetSkipsPointer %= SensorAnalyzer.HISTORY_LENGTH; msgRate = calcMsgRate(0); msgYield = calcMsgYield(0); SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a"); String log = ""; log += nodeNumber + "#"; log += msgCount + "#"; log += formatter.format(new Date()) + "#"; log += curtime + "#"; log += (curtime - lastTime) + "#"; log += SMsg.get_parentaddr() + "#"; parent_count[SMsg.get_parentaddr()]++; log += msgRate + "#"; seq_no = new_seq_no; batt = (int) SMsg.get_seq_no() >> 23 & 0x1ff; log += seq_no + "#"; log += hopcount + "#"; level_sum += hopcount; log += SMsg.get_reading() + "#"; log += batt + "#"; for (int i = 0; i < 5; i++) { log += neighbors[i].id + "#"; log += neighbors[i].hopcount + "#"; log += neighbors[i].link_quality / 255.0 + "#"; } log += SMsg.get_temp() + "#"; log += SMsg.get_light() + "#"; log += SMsg.get_accelx() + "#"; log += SMsg.get_accely() + "#"; log += SMsg.get_magx() + "#"; log += SMsg.get_magy() + "#"; System.out.println(log); double batt_val = (double) batt; batt_val = 1.25 * 1023.0 / batt_val; batt_val *= 256.0 / 4.0; // System.out.println(batt_val); // Store the sensor readings. yield_series.insertNewReading(total_yield++, new Integer((int) (yield() * 256.0))); time_series.insertNewReading(seq_no, new Long(curtime)); batt_series.insertNewReading(seq_no, new Integer((int) batt_val)); temp_series.insertNewReading(seq_no, new Integer(SMsg.get_temp())); light_series.insertNewReading(seq_no, new Integer(SMsg.get_light())); accelx_series.insertNewReading(seq_no, new Integer(SMsg.get_accelx())); accely_series.insertNewReading(seq_no, new Integer(SMsg.get_accely())); magx_series.insertNewReading(seq_no, new Integer(SMsg.get_magx())); magy_series.insertNewReading(seq_no, new Integer(SMsg.get_magy())); link_quality = neighbors[0].link_quality / 255; // update the edge quality as well... MainClass.locationAnalyzer.setQualityForEdge( nodeNumber.intValue(), SMsg.get_parentaddr(), (int) (link_quality * 255.0)); lastTime = curtime; } } if (self_calc != false) info = msgCount + " msgs "; else info = ""; this.value = SMsg.get_reading(); if (panel != null) { panel.YieldLabel.setText(String.valueOf(percent_yield()) + " %"); panel.SensorLabel.setText(String.valueOf(value)); panel.ParentLabel.setText(String.valueOf(SMsg.get_parentaddr())); panel.SequenceLabel.setText(String.valueOf(seq_no)); panel.CountLabel.setText(String.valueOf(msgCount)); panel.DepthLabel.setText(String.valueOf(hopcount)); panel.repaint(); } this.infoString = info; } }