コード例 #1
0
ファイル: GuiWithWatch.java プロジェクト: ADTC/VietOCR
  /** @param args the command line arguments */
  public static void main(String args[]) {
    selectedUILang = prefs.get("UILanguage", "en");
    Locale.setDefault(selectedUILang.equals("vi") ? VIETNAM : Locale.US);

    java.awt.EventQueue.invokeLater(
        new Runnable() {

          @Override
          public void run() {
            new GuiWithWatch().setVisible(true);
          }
        });
  }
コード例 #2
0
  public PhoneBookGUI(PhoneBook pb) {
    super("PhoneBook");
    phoneBook = pb;

    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);

    Locale.setDefault(new Locale("en"));
    /* To avoid hardcoded Swedish text on OptionPane dialogs */
    UIManager.put("OptionPane.cancelButtonText", "Cancel");

    setLayout(new BorderLayout());
    JMenuBar menubar = new JMenuBar();
    setJMenuBar(menubar);

    JMenu editMenu = new JMenu("Edit");
    menubar.add(editMenu);
    editMenu.add(new AddMenu(phoneBook, this));
    editMenu.add(new RemoveMenu(phoneBook, this));
    JMenu findMenu = new JMenu("Find");
    menubar.add(findMenu);
    findMenu.add(new FindNumbersMenu(phoneBook, this));
    findMenu.add(new FindNamesMenu(phoneBook, this));
    JMenu viewMenu = new JMenu("View");
    menubar.add(viewMenu);
    viewMenu.add(new ShowAllMenu(phoneBook, this));

    JPanel southPanel = new JPanel();
    messageArea = new JTextArea(4, 25);
    messageArea.setEditable(false);
    southPanel.add(new JScrollPane(messageArea));
    southPanel.add(new QuitButton(phoneBook));
    add(southPanel, BorderLayout.CENTER);

    pack();
    setVisible(true);

    String fileName = JOptionPane.showInputDialog("Enter file name");
    if (fileName != null) {
      try {
        phoneBook.readFromFile(fileName);
      } catch (Exception e) {
        setText("No such file was found");
      }
    }
  }
コード例 #3
0
  private void setDefaultLocale() {

    if (sessions.containsKey("emul.locale")) {
      Locale.setDefault(parseLocal(sessions.getProperty("emul.locale")));
    }
  }
コード例 #4
0
ファイル: SVGApplet.java プロジェクト: ilyessou/jhotdraw
  /**
   * Displays a progress indicator and then invokes <code>loadDrawing</code> on a worker thread.
   * Displays the drawing panel when done successfully. Displays an error message when done
   * unsuccessfully.
   *
   * @see #loadDrawing
   */
  @Override
  public final void init() {
    // set the language of the applet
    if (getParameter("Locale") != null) {
      Locale.setDefault(new Locale(getParameter("Locale")));
    }

    final ResourceBundleUtil labels =
        ResourceBundleUtil.getBundle("org.jhotdraw.samples.svg.Labels");

    // Set look and feel
    // -----------------
    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Throwable e) {
      // Do nothing.
      // If we can't set the desired look and feel, UIManager does
      // automaticaly the right thing for us.
    }

    // Set our own popup factory, because the one that comes with Mac OS X
    // creates translucent popups which is not useful for color selection
    // using pop menus.
    try {
      PopupFactory.setSharedInstance(new PopupFactory());
    } catch (Throwable e) {
      // If we can't set the popup factory, we have to use what is there.
    }

    // Display a progress indicator while we are loading the drawing
    // ----------------------------------------------------------
    Container c = getContentPane();
    final ProgressIndicator progress =
        new ProgressIndicator(getName(), labels.getString("progressInitializing"));
    c.add(progress);
    progress.revalidate();

    // Load the drawing using a worker thread
    // --------------------------------------
    new Worker<Drawing>() {

      @Override
      protected Drawing construct() throws Exception {
        Thread t =
            new Thread() {

              @Override
              public void run() {
                try {
                  drawingComponent = createDrawingComponent();
                } catch (Throwable t) {
                  t.printStackTrace();
                }
              }
            };
        t.start();
        try {
          progress.setNote(labels.getString("progressLoading"));
          Drawing drawing = loadDrawing(progress);
          progress.setNote(labels.getString("progressOpeningEditor"));
          progress.setIndeterminate(true);
          return drawing;
        } finally {
          t.join();
        }
      }

      @Override
      protected void done(Drawing result) {
        Container c = getContentPane();
        c.removeAll();
        c.setLayout(new BorderLayout());
        c.add(drawingComponent.getComponent());
        initComponents();
        if (result != null) {
          setDrawing(result);
        }
        drawingComponent.revalidate();
        ((JComponent) c).revalidate();
      }

      @Override
      protected void failed(Throwable error) {
        Drawing d = createDrawing();
        String message = (error.getMessage() == null) ? error.toString() : error.getMessage();
        SVGTextAreaFigure txt =
            new SVGTextAreaFigure(
                labels.getFormatted("messageLoadFailed", getParameter("DrawingURL"), message));
        txt.setBounds(new Point2D.Double(0, 0), new Point2D.Double(getWidth(), getHeight()));
        d.add(txt);
        done(d);
        /*
        Container c = getContentPane();
        c.setLayout(new BorderLayout());
        c.removeAll();
        Throwable error = result;
        error.printStackTrace();
        String message = (error.getMessage() == null) ? error.toString() : error.getMessage();
        MessagePanel mp = new MessagePanel(
        UIManager.getIcon("OptionPane.errorIcon"),
        labels.getFormatted("messageLoadFailed", htmlencode(getParameter("DrawingURL")), htmlencode(message)));
        c.add(mp);
        mp.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
        if ("close".equals(evt.getActionCommand())) {
        close();
        }
        }
        });
        mp.revalidate();
        */
      }

      @Override
      protected void finished() {
        long end = System.currentTimeMillis();
        System.out.println("AbstractDrawingApplet startup latency:" + (end - start));
      }
    }.start();
  }