void test2() {
    Locale defaultLocale = Locale.getDefault();
    TimeZone reservedTimeZone = TimeZone.getDefault();
    Date d = new Date(2005 - 1900, Calendar.DECEMBER, 22);
    String formatted;

    TimeZone tz;
    SimpleDateFormat df;

    try {
      for (int i = 0; i < TIMEZONES.length; i++) {
        tz = TimeZone.getTimeZone(TIMEZONES[i]);
        TimeZone.setDefault(tz);
        df = new SimpleDateFormat(pattern, DateFormatSymbols.getInstance(OSAKA));
        Locale.setDefault(defaultLocale);
        System.out.println(formatted = df.format(d));
        if (!formatted.equals(DISPLAY_NAMES_OSAKA[i])) {
          throw new RuntimeException(
              "TimeZone "
                  + TIMEZONES[i]
                  + ": formatted zone names mismatch. "
                  + formatted
                  + " should match with "
                  + DISPLAY_NAMES_OSAKA[i]);
        }

        df.parse(DISPLAY_NAMES_OSAKA[i]);

        Locale.setDefault(KYOTO);
        df = new SimpleDateFormat(pattern, DateFormatSymbols.getInstance());
        System.out.println(formatted = df.format(d));
        if (!formatted.equals(DISPLAY_NAMES_KYOTO[i])) {
          throw new RuntimeException(
              "Timezone "
                  + TIMEZONES[i]
                  + ": formatted zone names mismatch. "
                  + formatted
                  + " should match with "
                  + DISPLAY_NAMES_KYOTO[i]);
        }
        df.parse(DISPLAY_NAMES_KYOTO[i]);
      }
    } catch (ParseException pe) {
      throw new RuntimeException("parse error occured" + pe);
    } finally {
      // restore the reserved locale and time zone
      Locale.setDefault(defaultLocale);
      TimeZone.setDefault(reservedTimeZone);
    }
  }
Beispiel #2
0
  /** Return the list of languages supported by the server. */
  public static Collection<Locale> getLocales() {
    Collection<Locale> locales = new ArrayList<Locale>();

    for (String language : Locale.getISOLanguages()) {
      Locale locale = new Locale(language);
      if (isSupported(locale)) {
        locales.add(locale);
      }
    }

    return locales;
  }
 public static void main(String[] args) {
   Display display = new Display();
   Shell shell = new Shell(display);
   shell.setLayout(new FillLayout());
   final Table table = new Table(shell, SWT.BORDER);
   table.setHeaderVisible(true);
   final TableColumn column1 = new TableColumn(table, SWT.NONE);
   column1.setText("Column 1");
   final TableColumn column2 = new TableColumn(table, SWT.NONE);
   column2.setText("Column 2");
   TableItem item = new TableItem(table, SWT.NONE);
   item.setText(new String[] {"a", "3"});
   item = new TableItem(table, SWT.NONE);
   item.setText(new String[] {"b", "2"});
   item = new TableItem(table, SWT.NONE);
   item.setText(new String[] {"c", "1"});
   column1.setWidth(100);
   column2.setWidth(100);
   Listener sortListener =
       e -> {
         TableItem[] items = table.getItems();
         Collator collator = Collator.getInstance(Locale.getDefault());
         TableColumn column = (TableColumn) e.widget;
         int index = column == column1 ? 0 : 1;
         for (int i = 1; i < items.length; i++) {
           String value1 = items[i].getText(index);
           for (int j = 0; j < i; j++) {
             String value2 = items[j].getText(index);
             if (collator.compare(value1, value2) < 0) {
               String[] values = {items[i].getText(0), items[i].getText(1)};
               items[i].dispose();
               TableItem item1 = new TableItem(table, SWT.NONE, j);
               item1.setText(values);
               items = table.getItems();
               break;
             }
           }
         }
         table.setSortColumn(column);
       };
   column1.addListener(SWT.Selection, sortListener);
   column2.addListener(SWT.Selection, sortListener);
   table.setSortColumn(column1);
   table.setSortDirection(SWT.UP);
   shell.setSize(shell.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, 300);
   shell.open();
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) display.sleep();
   }
   display.dispose();
 }
  void test1() {
    Locale[] available = Locale.getAvailableLocales();
    List<Locale> jreimplloc =
        Arrays.asList(
            LocaleProviderAdapter.forJRE().getTimeZoneNameProvider().getAvailableLocales());
    List<Locale> providerLocales = Arrays.asList(tznp.getAvailableLocales());
    String[] ids = TimeZone.getAvailableIDs();

    for (Locale target : available) {
      // pure JRE implementation
      OpenListResourceBundle rb =
          ((ResourceBundleBasedAdapter) LocaleProviderAdapter.forJRE())
              .getLocaleData()
              .getTimeZoneNames(target);
      boolean jreSupportsTarget = jreimplloc.contains(target);

      for (String id : ids) {
        // the time zone
        TimeZone tz = TimeZone.getTimeZone(id);

        // JRE string array for the id
        String[] jrearray = null;
        if (jreSupportsTarget) {
          try {
            jrearray = rb.getStringArray(id);
          } catch (MissingResourceException mre) {
          }
        }

        for (int i = 1; i <= (tz.useDaylightTime() ? 4 : 2); i++) {
          // the localized name
          String name = tz.getDisplayName(i >= 3, i % 2, target);

          // provider's name (if any)
          String providersname = null;
          if (providerLocales.contains(target)) {
            providersname = tznp.getDisplayName(id, i >= 3, i % 2, target);
          }

          // JRE's name
          String jresname = null;
          if (jrearray != null) {
            jresname = jrearray[i];
          }

          checkValidity(
              target, jresname, providersname, name, jreSupportsTarget && jresname != null);
        }
      }
    }
  }
Beispiel #5
0
  public static void main(String[] args) throws Exception {
    /*
    	DateFormat的构造器是protected的 但它提供了一些静态方法来获取DateFormat实例。
    	df = new DateFormat();
    	getDateInstance - 格式化后的字符串只有日期。
    	getTimeInstance - 格式化的字符串只有时间
    	getDateTimeInstance - 格式化的的字符串有日期、时间

    */
    Date d = new Date();
    System.out.println(d);
    // 为了程序更加友好的界面,要求把Date转换成一个符合Locale的字符串。

    DateFormat df =
        DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, Locale.getDefault());
    System.out.println(df.format(d));

    String dateStr = "2007年aa月20日 星期二 上午11时54分15秒 CST";
    System.out.println(df.parse(dateStr));
  }
Beispiel #6
0
 /** ** Gets the System default Locale ** @return The default Java Locale instance */
 public static Locale getDefaultLocale() {
   return Locale.getDefault(); // System default
 }
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
}
 static {
   Locale.setDefault(Locale.ENGLISH);
 }
Beispiel #9
0
 static {
   setLocale(Locale.getDefault());
 }
 public static DateFormat getShortDateFormat(Locale locale) {
   if (locale.getCountry().equals("ZA")) return new SimpleDateFormat("dd/MM/yyyy h:mm a");
   else return DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale);
 }
 public static DateFormat getShortDateFormat() {
   return getShortDateFormat(Locale.getDefault());
 }
Beispiel #12
0
  /** @param args */
  public static void main(String[] args) {

    try {

      // force dot as decimal separator
      Locale.setDefault(new Locale("en", "US"));

      // Get current time
      long start = System.currentTimeMillis();

      RinexNavigation navigationIn =
          new RinexNavigation(RinexNavigation.IGN_NAVIGATION_HOURLY_ZIM2);

      FileInputStream fis = new FileInputStream(".\\data\\aphemeris.dat");
      // FileInputStream fis = new FileInputStream(".\\data\\assistnow.dat");
      DataInputStream dis = new DataInputStream(fis);
      String msg = null;
      try {
        msg = dis.readUTF();
        while (msg != null) {
          System.out.println("Msg:[" + msg + "]");
          if (msg.equalsIgnoreCase(Streamable.MESSAGE_OBSERVATIONS)) {
            Observations o = new Observations(dis, false);

          } else if (msg.equalsIgnoreCase(Streamable.MESSAGE_EPHEMERIS)) {
            EphGps eph1 = new EphGps(dis, false);
            System.out.println(
                "found sat" + eph1.getSatID() + " time:" + eph1.getRefTime().getGpsTime());

            EphGps eph2 =
                navigationIn.findEph(
                    eph1.getRefTime().getMsec(), eph1.getSatID(), eph1.getSatType());

            // Compare
            if (eph2 != null) {
              double ms = eph1.getRefTime().getGpsTime() - eph2.getRefTime().getGpsTime();
              System.out.println(" time dif:" + (ms / 1000) + "s " + (ms % 1000) + "ms");
              ;
              equalDouble("Af0", eph1.getAf0(), eph2.getAf0());
              equalDouble("Af1", eph1.getAf1(), eph2.getAf1());
              equalDouble("Af2", eph1.getAf2(), eph2.getAf2());
              equalDouble("Cic", eph1.getCic(), eph2.getCic());
              equalDouble("Cis", eph1.getCis(), eph2.getCis());
              equalDouble("Crc", eph1.getCrc(), eph2.getCrc());
              equalDouble("Crs", eph1.getCrs(), eph2.getCrs());
              equalDouble("Cuc", eph1.getCuc(), eph2.getCuc());
              equalDouble("Cus", eph1.getCus(), eph2.getCus());
              equalDouble("DeltaN", eph1.getDeltaN(), eph2.getDeltaN());
              equalDouble("E", eph1.getE(), eph2.getE());
              equalDouble("FitInt", eph1.getFitInt(), eph2.getFitInt());
              equalDouble("I0", eph1.getI0(), eph2.getI0());
              equalDouble("iDot", eph1.getiDot(), eph2.getiDot());
              equalDouble("M0", eph1.getM0(), eph2.getM0());
              equalDouble("Omega", eph1.getOmega(), eph2.getOmega());
              equalDouble("Omega0", eph1.getOmega0(), eph2.getOmega0());
              equalDouble("OmegaDot", eph1.getOmegaDot(), eph2.getOmegaDot());
              equalDouble("RootA", eph1.getRootA(), eph2.getRootA());
              equalDouble("Tgd", eph1.getTgd(), eph2.getTgd());
              equalDouble("Toc", eph1.getToc(), eph2.getToc());
              equalDouble("Toe", eph1.getToe(), eph2.getToe());
              equalDouble("Iodc", eph1.getIodc(), eph2.getIodc());
              equalDouble("Iode", eph1.getIode(), eph2.getIode());
              equalDouble("L2Code", eph1.getL2Code(), eph2.getL2Code());
              equalDouble("L2Flag", eph1.getL2Flag(), eph2.getL2Flag());
              equalDouble("SvAccur", eph1.getSvAccur(), eph2.getSvAccur());
              equalDouble("SvHealth", eph1.getSvHealth(), eph2.getSvHealth());

            } else {
              System.out.println(
                  "EPH 2 not found for " + eph1.getSatID() + " at " + eph1.getRefTime());
            }

          } else if (msg.equalsIgnoreCase(Streamable.MESSAGE_OBSERVATIONS_SET)) {
            ObservationSet eps = new ObservationSet(dis, false);
            // nothing to do with ?
          } else if (msg.equalsIgnoreCase(Streamable.MESSAGE_IONO)) {
            IonoGps iono = new IonoGps(dis, false);
            // addIonospheric(iono);
          } else if (msg.equalsIgnoreCase(Streamable.MESSAGE_COORDINATES)) {
            Coordinates c = Coordinates.readFromStream(dis, false);
            // setDefinedPosition(c);

          } else {
            System.out.println("Unknow Msg:[" + msg + "]");
          }

          msg = dis.readUTF();
        }
      } catch (EOFException eof) {
        // ok
      }
      fis.close();

      try {
        navigationIn.release(true, 10000);
      } catch (InterruptedException ie) {
        ie.printStackTrace();
      }

      // Get and display elapsed time
      int elapsedTimeSec = (int) Math.floor((System.currentTimeMillis() - start) / 1000);
      int elapsedTimeMillisec =
          (int) ((System.currentTimeMillis() - start) - elapsedTimeSec * 1000);
      System.out.println(
          "\nElapsed time (read + proc + display + write): "
              + elapsedTimeSec
              + " seconds "
              + elapsedTimeMillisec
              + " milliseconds.");
    } catch (Exception e) {
      e.printStackTrace();
    }
  }