/** Creates a new instance of clPrintGraphPanel */
  public clPrintGraphPanel(java.awt.Frame parent, clHauptPanel hp, Locale lc) {
    super(hp.getKn(), hp.getSt(), true);
    this.parent = parent;
    dxf = hp.dxf;
    mechanismusRelKnVersch = hp.mechanismusRelKnVersch;

    Point2D[] zoomPkte = hp.getZoomPkte();
    ZoomPkt1 = zoomPkte[0];
    ZoomPkt2 = zoomPkte[1];
    ZOOMALL = hp.ZOOMALL;
    maxMechSkal = hp.maxMechSkal;

    boolean[] aktiveLayer = hp.getAktiveLayer();
    MIT_KnNr = aktiveLayer[0];
    MIT_StabNr = aktiveLayer[1];
    MIT_Lasten = aktiveLayer[2];
    MIT_Auflagerkräften = aktiveLayer[3];
    MIT_Stabkräften = aktiveLayer[4];
    MIT_Hintergrund = aktiveLayer[5];
    MIT_Mechanismus = aktiveLayer[6];

    maxPfeil = maxPfeil * druckvergr;
    spitzenlängeMax = spitzenlängeMax * druckvergr; // / (0.5d + printskal/2d);
    spitzenlängeMin = spitzenlängeMin * druckvergr; // / (0.5d + printskal/2d);
    lagerhöhe = lagerhöhe * (float) druckvergr; // / (0.5f + ((float)printskal)/2f);

    locale = lc;
    druckRB = ResourceBundle.getBundle("Fachwerk/locales/gui-drucken", locale);
    if (druckRB == null) {
      System.err.println("FEHLER: gui-drucken für " + locale.toString());
    }
  }
 /** @see java.awt.im.spi.InputMethodDescriptor#getInputMethodDisplayName */
 public synchronized String getInputMethodDisplayName(Locale inputLocale, Locale displayLanguage) {
   String name = "System Input Methods";
   if (Locale.getDefault().equals(displayLanguage)) {
     name = Toolkit.getProperty("AWT.HostInputMethodDisplayName", name);
   }
   return name;
 }
  public void init() {
    initPins(0, 1, 0, 2);
    setSize(62, 40);
    element.jSetInnerBorderVisibility(false);
    element.jSetTopPinsVisible(false);
    element.jSetBottomPinsVisible(false);

    image = element.jLoadImage(element.jGetSourcePath() + "icon.gif");

    setPin(0, ExternalIF.C_VARIANT, element.PIN_OUTPUT);
    setPin(1, ExternalIF.C_VARIANT, element.PIN_INPUT);
    setPin(2, ExternalIF.C_BOOLEAN, element.PIN_INPUT);

    String strLocale = Locale.getDefault().toString();

    if (strLocale.equalsIgnoreCase("de_DE")) {
      element.jSetPinDescription(0, "Out");
      element.jSetPinDescription(1, "in");
      element.jSetPinDescription(2, "if (true) out=in");
    }
    if (strLocale.equalsIgnoreCase("en_US")) {
      element.jSetPinDescription(0, "Out");
      element.jSetPinDescription(1, "a");
      element.jSetPinDescription(2, "if (true) out=in");
    }
    if (strLocale.equalsIgnoreCase("es_ES")) {
      element.jSetPinDescription(0, "Salida");
      element.jSetPinDescription(1, "a");
      element.jSetPinDescription(2, "if (true) out=in");
    }

    setName("Abfrage2");
  }
Example #4
0
 public ExitAction(MainFrame main) {
   super();
   Locale locale = Locale.getDefault();
   bundle = ResourceBundle.getBundle(getClass().getName(), locale);
   this.main = main;
   putValue(NAME, bundle.getString("Exit"));
   putValue(MNEMONIC_KEY, new Integer(bundle.getString("Exit.mnemonic").charAt(0)));
 }
  static Object[] getAvailableLocalesInternal() {
    List workList = nativeGetAvailableLocales();

    if (workList != null) {
      return workList.toArray();
    }

    return new Object[] {Locale.getDefault()};
  }
Example #6
0
 static {
   try {
     resources = ResourceBundle.getBundle("resources.TextViewer", Locale.getDefault());
   } catch (MissingResourceException mre) {
     String errstr = "TextViewer:resources/TextViewer.properties not found";
     // System.exit(1);
     System.err.println(errstr);
   }
 }
Example #7
0
 static {
   try {
     properties = new Properties();
     properties.load(Notepad.class.getResourceAsStream("resources/NotepadSystem.properties"));
     resources = ResourceBundle.getBundle("resources.Notepad", Locale.getDefault());
   } catch (MissingResourceException | IOException e) {
     System.err.println(
         "resources/Notepad.properties " + "or resources/NotepadSystem.properties not found");
     System.exit(1);
   }
 }
  /** Creates new form SwitchboardView */
  public SwitchboardView() {
    initComponents();

    btnSalesReport.addActionListener(this);
    btnBackOffice.addActionListener(this);
    btnClockOut.addActionListener(this);
    btnEditTicket.addActionListener(this);

    if (!"false".equals(AppConfig.getFeatureGroupTicketFlag())) {
      btnGroupSettle.addActionListener(this);
    }

    btnLogout.addActionListener(this);

    if (!"false".equals(AppConfig.getManagerMenuFlag())) {
      btnManager.addActionListener(this);
    }

    btnNewTicket.addActionListener(this);

    if (!"false".equals(AppConfig.getFeaturePenarikanFlag())) {
      btnPayout.addActionListener(this);
    }

    btnOrderInfo.addActionListener(this);
    btnReopenTicket.addActionListener(this);
    btnSettleTicket.addActionListener(this);
    btnShutdown.addActionListener(this);

    if (!"false".equals(AppConfig.getFeatureSplitTicketFlag())) {
      btnSplitTicket.addActionListener(this);
    }

    btnTakeout.addActionListener(this);
    btnVoidTicket.addActionListener(this);

    orderServiceExtension = Application.getPluginManager().getPlugin(OrderServiceExtension.class);

    if (orderServiceExtension == null) {
      //            btnHomeDelivery.setEnabled(false);
      //            btnPickup.setEnabled(false);
      //            btnDriveThrough.setEnabled(false);
      //            btnAssignDriver.setEnabled(false);
      //            btnCloseOrder.setEnabled(false);

      orderServiceExtension = new DefaultOrderServiceExtension();
    }
    //		ticketListUpdater = new Timer(30 * 1000, new TicketListUpdaterTask());

    applyComponentOrientation(ComponentOrientation.getOrientation(Locale.getDefault()));

    instance = this;
  }
  @Override
  public UIDefaults getDefaults() {
    try {
      final Method superMethod = BasicLookAndFeel.class.getDeclaredMethod("getDefaults");
      superMethod.setAccessible(true);
      final UIDefaults metalDefaults = (UIDefaults) superMethod.invoke(new MetalLookAndFeel());

      final UIDefaults defaults = (UIDefaults) superMethod.invoke(base);
      if (SystemInfo.isLinux) {
        if (!Registry.is("darcula.use.native.fonts.on.linux")) {
          Font font = findFont("DejaVu Sans");
          if (font != null) {
            for (Object key : defaults.keySet()) {
              if (key instanceof String && ((String) key).endsWith(".font")) {
                defaults.put(key, new FontUIResource(font.deriveFont(13f)));
              }
            }
          }
        } else if (Arrays.asList("CN", "JP", "KR", "TW")
            .contains(Locale.getDefault().getCountry())) {
          for (Object key : defaults.keySet()) {
            if (key instanceof String && ((String) key).endsWith(".font")) {
              final Font font = defaults.getFont(key);
              if (font != null) {
                defaults.put(key, new FontUIResource("Dialog", font.getStyle(), font.getSize()));
              }
            }
          }
        }
      }

      LafManagerImpl.initInputMapDefaults(defaults);
      initIdeaDefaults(defaults);
      patchStyledEditorKit(defaults);
      patchComboBox(metalDefaults, defaults);
      defaults.remove("Spinner.arrowButtonBorder");
      defaults.put("Spinner.arrowButtonSize", JBUI.size(16, 5).asUIResource());
      MetalLookAndFeel.setCurrentTheme(createMetalTheme());
      if (SystemInfo.isWindows && Registry.is("ide.win.frame.decoration")) {
        JFrame.setDefaultLookAndFeelDecorated(true);
        JDialog.setDefaultLookAndFeelDecorated(true);
      }
      if (SystemInfo.isLinux && JBUI.isHiDPI()) {
        applySystemFonts(defaults);
      }
      defaults.put("EditorPane.font", defaults.getFont("TextField.font"));
      return defaults;
    } catch (Exception e) {
      log(e);
    }
    return super.getDefaults();
  }
 protected void initResourceBundle(UIDefaults table) {
   // The following line of code does not work, when Quaqua has been loaded with
   // a custom class loader. That's why, we have to inject the labels
   // by ourselves:
   // table.addResourceBundle( "ch.randelshofer.quaqua.Labels" );
   ResourceBundle bundle =
       ResourceBundle.getBundle(
           "ch.randelshofer.quaqua.Labels", Locale.getDefault(), getClass().getClassLoader());
   for (Enumeration i = bundle.getKeys(); i.hasMoreElements(); ) {
     String key = (String) i.nextElement();
     table.put(key, bundle.getObject(key));
   }
 }
 @JdkConstants.FontStyle
 static int getFontStyle(String fontName) {
   fontName = fontName.toLowerCase(Locale.getDefault());
   for (String name : BOLD_ITALIC_NAMES) {
     if (fontName.contains(name)) return Font.BOLD | Font.ITALIC;
   }
   for (String name : ITALIC_NAMES) {
     if (fontName.contains(name)) return Font.ITALIC;
   }
   for (String name : BOLD_NAMES) {
     if (fontName.contains(name)) return Font.BOLD;
   }
   return Font.PLAIN;
 }
  /**
   * Create this dialog with the given parent and title.
   *
   * @param parent window from which this dialog is launched
   * @param title the title for the dialog box window
   * @since ostermillerutils 1.00.00
   */
  public PasswordDialog(Frame parent, String title) {

    super(parent, title, true);

    setLocale(Locale.getDefault());

    if (title == null) {
      setTitle(labels.getString("dialog.title"));
    }
    if (parent != null) {
      setLocationRelativeTo(parent);
    }
    // super calls dialogInit, so we don't need to do it again.
  }
 public void setLocale(Locale locale) {
   // locale == null --> l�schen
   Element root = document.getRootElement();
   // pr�fen,ob locale-tag vorhanden
   java.util.List localeListe = PM_XML_Utils.getElementListe(document, "//" + TAG_LOCALE);
   Element localeElement = null;
   if (localeListe.isEmpty()) {
     if (locale == null) {
       return; // soll gel�scht sein
     }
     localeElement = new org.dom4j.tree.DefaultElement(TAG_LOCALE);
     updateAttribute(localeElement, ATTR_LOCALE_LANGUAGE, locale.getLanguage());
     root.add(localeElement);
   } else {
     localeElement = (Element) localeListe.get(0);
     if (locale != null) {
       updateAttribute(localeElement, ATTR_LOCALE_LANGUAGE, locale.getLanguage());
     } else {
       // l�schen
       updateAttribute(localeElement, ATTR_LOCALE_LANGUAGE, null);
     }
   }
 }
 private String tr(String key) {
   String übersetzt;
   try {
     übersetzt = druckRB.getString(key);
   } catch (MissingResourceException e) {
     System.err.println(
         "Schluesselwort "
             + key
             + " nicht gefunden fuer "
             + locale.toString()
             + " ; "
             + e.toString());
     return key;
   }
   return übersetzt;
 }
  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");
      }
    }
  }
Example #16
0
 /** ** Gets the System default Locale ** @return The default Java Locale instance */
 public static Locale getDefaultLocale() {
   return Locale.getDefault(); // System default
 }
  private void recreateEditorsPanel() {
    myValuesPanel.removeAll();
    myValuesPanel.setLayout(new CardLayout());

    if (!myProject.isOpen()) return;
    JPanel valuesPanelComponent = new MyJPanel(new GridBagLayout());
    myValuesPanel.add(
        new JBScrollPane(valuesPanelComponent) {
          @Override
          public void updateUI() {
            super.updateUI();
            getViewport().setBackground(UIUtil.getPanelBackground());
          }
        },
        VALUES);
    myValuesPanel.add(myNoPropertySelectedPanel, NO_PROPERTY_SELECTED);

    List<PropertiesFile> propertiesFiles = myResourceBundle.getPropertiesFiles();

    GridBagConstraints gc =
        new GridBagConstraints(
            0,
            0,
            0,
            0,
            0,
            0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH,
            new Insets(5, 5, 5, 5),
            0,
            0);
    releaseAllEditors();
    myTitledPanels.clear();
    int y = 0;
    Editor previousEditor = null;
    Editor firstEditor = null;
    for (final PropertiesFile propertiesFile : propertiesFiles) {
      final Editor editor = createEditor();
      final Editor oldEditor = myEditors.put(propertiesFile, editor);
      if (firstEditor == null) {
        firstEditor = editor;
      }
      if (previousEditor != null) {
        editor.putUserData(
            ChooseSubsequentPropertyValueEditorAction.PREV_EDITOR_KEY, previousEditor);
        previousEditor.putUserData(
            ChooseSubsequentPropertyValueEditorAction.NEXT_EDITOR_KEY, editor);
      }
      previousEditor = editor;
      if (oldEditor != null) {
        EditorFactory.getInstance().releaseEditor(oldEditor);
      }
      ((EditorEx) editor)
          .addFocusListener(
              new FocusChangeListener() {
                @Override
                public void focusGained(final Editor editor) {
                  mySelectedEditor = editor;
                }

                @Override
                public void focusLost(final Editor eventEditor) {
                  writeEditorPropertyValue(editor, propertiesFile, null);
                }
              });
      gc.gridx = 0;
      gc.gridy = y++;
      gc.gridheight = 1;
      gc.gridwidth = GridBagConstraints.REMAINDER;
      gc.weightx = 1;
      gc.weighty = 1;
      gc.anchor = GridBagConstraints.CENTER;

      Locale locale = propertiesFile.getLocale();
      List<String> names = new ArrayList<String>();
      if (!Comparing.strEqual(locale.getDisplayLanguage(), null)) {
        names.add(locale.getDisplayLanguage());
      }
      if (!Comparing.strEqual(locale.getDisplayCountry(), null)) {
        names.add(locale.getDisplayCountry());
      }
      if (!Comparing.strEqual(locale.getDisplayVariant(), null)) {
        names.add(locale.getDisplayVariant());
      }

      String title = propertiesFile.getName();
      if (!names.isEmpty()) {
        title += " (" + StringUtil.join(names, "/") + ")";
      }
      JComponent comp =
          new JPanel(new BorderLayout()) {
            @Override
            public Dimension getPreferredSize() {
              Insets insets = getBorder().getBorderInsets(this);
              return new Dimension(100, editor.getLineHeight() * 4 + insets.top + insets.bottom);
            }
          };
      comp.add(editor.getComponent(), BorderLayout.CENTER);
      comp.setBorder(IdeBorderFactory.createTitledBorder(title, true));
      myTitledPanels.put(propertiesFile, (JPanel) comp);

      valuesPanelComponent.add(comp, gc);
    }
    if (previousEditor != null) {
      previousEditor.putUserData(
          ChooseSubsequentPropertyValueEditorAction.NEXT_EDITOR_KEY, firstEditor);
      firstEditor.putUserData(
          ChooseSubsequentPropertyValueEditorAction.PREV_EDITOR_KEY, previousEditor);
    }

    gc.gridx = 0;
    gc.gridy = y;
    gc.gridheight = GridBagConstraints.REMAINDER;
    gc.gridwidth = GridBagConstraints.REMAINDER;
    gc.weightx = 10;
    gc.weighty = 1;

    valuesPanelComponent.add(new JPanel(), gc);
    selectionChanged();
    myValuesPanel.repaint();
    UIUtil.invokeAndWaitIfNeeded(
        new Runnable() {
          @Override
          public void run() {
            updateEditorsFromProperties();
          }
        });
  }
  /**
   * Called by constructors to initialize the dialog.
   *
   * @since ostermillerutils 1.00.00
   */
  @Override
  protected void dialogInit() {

    if (labels == null) {
      setLocale(Locale.getDefault());
    }

    name = new JTextField("", 20);
    pass = new JPasswordField("", 20);
    okButton = new JButton(labels.getString("dialog.ok"));
    cancelButton = new JButton(labels.getString("dialog.cancel"));
    nameLabel = new JLabel(labels.getString("dialog.name") + " ");
    passLabel = new JLabel(labels.getString("dialog.pass") + " ");

    super.dialogInit();

    KeyListener keyListener =
        (new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ESCAPE
                || (e.getSource() == cancelButton && e.getKeyCode() == KeyEvent.VK_ENTER)) {
              pressed_OK = false;
              PasswordDialog.this.setVisible(false);
            }
            if (e.getSource() == okButton && e.getKeyCode() == KeyEvent.VK_ENTER) {
              pressed_OK = true;
              PasswordDialog.this.setVisible(false);
            }
          }
        });
    addKeyListener(keyListener);

    ActionListener actionListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            Object source = e.getSource();
            if (source == name) {
              // the user pressed enter in the name field.
              name.transferFocus();
            } else {
              // other actions close the dialog.
              pressed_OK = (source == pass || source == okButton);
              PasswordDialog.this.setVisible(false);
            }
          }
        };

    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    c.insets.top = 5;
    c.insets.bottom = 5;
    JPanel pane = new JPanel(gridbag);
    pane.setBorder(BorderFactory.createEmptyBorder(10, 20, 5, 20));
    c.anchor = GridBagConstraints.EAST;
    gridbag.setConstraints(nameLabel, c);
    pane.add(nameLabel);

    gridbag.setConstraints(name, c);
    name.addActionListener(actionListener);
    name.addKeyListener(keyListener);
    pane.add(name);

    c.gridy = 1;
    gridbag.setConstraints(passLabel, c);
    pane.add(passLabel);

    gridbag.setConstraints(pass, c);
    pass.addActionListener(actionListener);
    pass.addKeyListener(keyListener);
    pane.add(pass);

    c.gridy = 2;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.CENTER;
    JPanel panel = new JPanel();
    okButton.addActionListener(actionListener);
    okButton.addKeyListener(keyListener);
    panel.add(okButton);
    cancelButton.addActionListener(actionListener);
    cancelButton.addKeyListener(keyListener);
    panel.add(cancelButton);
    gridbag.setConstraints(panel, c);
    pane.add(panel);

    getContentPane().add(pane);

    pack();
  }
  private boolean inInitState() {
    Component focusOwner = myContext.getFocusOwner();
    boolean isModalContext = myContext.isModalContext();
    DataContext dataContext = myContext.getDataContext();
    KeyEvent e = myContext.getInputEvent();

    // http://www.jetbrains.net/jira/browse/IDEADEV-12372
    if (myLeftCtrlPressed
        && myRightAltPressed
        && focusOwner != null
        && e.getModifiers() == (InputEvent.CTRL_MASK | InputEvent.ALT_MASK)) {
      if (Registry.is("actionSystem.force.alt.gr")) {
        return false;
      }
      final InputContext inputContext = focusOwner.getInputContext();
      if (inputContext != null) {
        Locale locale = inputContext.getLocale();
        if (locale != null) {
          @NonNls final String language = locale.getLanguage();
          if (ALT_GR_LAYOUTS.contains(language)) {
            // don't search for shortcuts
            return false;
          }
        }
      }
    }

    KeyStroke originalKeyStroke = KeyStroke.getKeyStrokeForEvent(e);
    KeyStroke keyStroke = getKeyStrokeWithoutMouseModifiers(originalKeyStroke);

    if (myKeyGestureProcessor.processInitState()) {
      return true;
    }

    if (SystemInfo.isMac) {
      boolean keyTyped = e.getID() == KeyEvent.KEY_TYPED;
      boolean hasMnemonicsInWindow =
          e.getID() == KeyEvent.KEY_PRESSED && hasMnemonicInWindow(focusOwner, e.getKeyCode())
              || keyTyped && hasMnemonicInWindow(focusOwner, e.getKeyChar());
      boolean imEnabled = IdeEventQueue.getInstance().isInputMethodEnabled();

      if (e.getModifiersEx() == InputEvent.ALT_DOWN_MASK
          && (hasMnemonicsInWindow || (!imEnabled && keyTyped))) {
        setPressedWasProcessed(true);
        setState(KeyState.STATE_PROCESSED);
        return false;
      }
    }

    updateCurrentContext(focusOwner, new KeyboardShortcut(keyStroke, null), isModalContext);
    if (myContext.getActions().isEmpty()) {
      // there's nothing mapped for this stroke
      return false;
    }

    if (myContext.isHasSecondStroke()) {
      myFirstKeyStroke = keyStroke;
      final ArrayList<Pair<AnAction, KeyStroke>> secondKeyStrokes = getSecondKeystrokeActions();

      final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
      StringBuilder message = new StringBuilder();
      message.append(KeyMapBundle.message("prefix.key.pressed.message"));
      message.append(' ');
      for (int i = 0; i < secondKeyStrokes.size(); i++) {
        Pair<AnAction, KeyStroke> pair = secondKeyStrokes.get(i);
        if (i > 0) message.append(", ");
        message.append(pair.getFirst().getTemplatePresentation().getText());
        message.append(" (");
        message.append(KeymapUtil.getKeystrokeText(pair.getSecond()));
        message.append(")");
      }

      StatusBar.Info.set(message.toString(), project);

      mySecondStrokeTimeout.cancelAllRequests();
      mySecondStrokeTimeout.addRequest(
          mySecondStrokeTimeoutRunnable, Registry.intValue("actionSystem.secondKeystrokeTimeout"));

      if (Registry.is("actionSystem.secondKeystrokeAutoPopupEnabled")) {
        mySecondKeystrokePopupTimeout.cancelAllRequests();
        if (secondKeyStrokes.size() > 1) {
          final DataContext oldContext = myContext.getDataContext();
          mySecondKeystrokePopupTimeout.addRequest(
              new Runnable() {
                @Override
                public void run() {
                  if (myState == KeyState.STATE_WAIT_FOR_SECOND_KEYSTROKE) {
                    StatusBar.Info.set(null, PlatformDataKeys.PROJECT.getData(oldContext));
                    new SecondaryKeystrokePopup(myFirstKeyStroke, secondKeyStrokes, oldContext)
                        .showInBestPositionFor(oldContext);
                  }
                }
              },
              Registry.intValue("actionSystem.secondKeystrokePopupTimeout"));
        }
      }

      setState(KeyState.STATE_WAIT_FOR_SECOND_KEYSTROKE);
      return true;
    } else {
      return processAction(e, myActionProcessor);
    }
  }
Example #20
0
  /**
   * 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();
  }
  private void setDefaultLocale() {

    if (sessions.containsKey("emul.locale")) {
      Locale.setDefault(parseLocal(sessions.getProperty("emul.locale")));
    }
  }