Ejemplo n.º 1
0
 /**
  * Simple space saving implementation of common I18n Property Info setting.
  *
  * @param i18n i18n object to use to search for internationalized strings.
  * @param info the properties class being used to set information into.
  * @param classToSetFor class to use for i18n search.
  * @param propertyName property to set for.
  * @param label label to use for GUI (can be null if N/A).
  * @param tooltip tooltip to use for GUI (can be null if N/A).
  * @param editor editor class string to use for GUI (can be null if N/A).
  * @return Properties object passed in, or new one if null Properties passed in.
  */
 public static Properties setI18NPropertyInfo(
     I18n i18n,
     Properties info,
     Class classToSetFor,
     String propertyName,
     String label,
     String tooltip,
     String editor) {
   if (info == null) {
     info = new Properties();
   }
   if (i18n != null) {
     if (tooltip != null) {
       String internString = i18n.get(classToSetFor, propertyName, I18n.TOOLTIP, tooltip);
       info.put(propertyName, internString);
     }
     if (label != null) {
       String internString = i18n.get(classToSetFor, propertyName, label);
       info.put(propertyName + PropertyConsumer.LabelEditorProperty, internString);
     }
     if (editor != null) {
       info.put(propertyName + PropertyConsumer.ScopedEditorProperty, editor);
     }
   }
   return info;
 }
Ejemplo n.º 2
0
  /**
   * Create the Swing components that let you change the transparency of the color received from the
   * JColorChooser.
   *
   * @param initialValue the starting alpha value for the color.
   * @return JComponent to adjust the transparency value.
   */
  public JComponent getTransparancyAdjustment(int initialValue) {
    transparency = initialValue;
    // This sets initial transparency effect in preview...
    setPreviewColor(preview.getColor());
    JPanel slidePanel = new JPanel();
    Box slideBox = Box.createHorizontalBox();

    JSlider opaqueSlide =
        new JSlider(JSlider.HORIZONTAL, 0 /* min */, 255 /* max */, initialValue /* initial */);
    java.util.Hashtable<Integer, JLabel> dict = new java.util.Hashtable<Integer, JLabel>();
    String opaqueLabel = i18n.get(ColorTracker.class, "opaque", "opaque");
    String clearLabel = i18n.get(ColorTracker.class, "clear", "clear");
    if (opaqueLabel == null || opaqueLabel.length() == 0) {
      // translations are too long :(
      dict.put(new Integer(126), new JLabel(clearLabel));
    } else {
      dict.put(new Integer(50), new JLabel(clearLabel));
      dict.put(new Integer(200), new JLabel(opaqueLabel));
    }
    // commented because polish translations are too long
    opaqueSlide.setLabelTable(dict);
    opaqueSlide.setPaintLabels(true);
    opaqueSlide.setMajorTickSpacing(50);
    opaqueSlide.setPaintTicks(true);
    opaqueSlide.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent ce) {
            JSlider slider = (JSlider) ce.getSource();
            if (slider.getValueIsAdjusting()) {
              transparency = slider.getValue();
            }
            // This sets transparency in preview...
            setPreviewColor(preview.getColor());
          }
        });

    preview.setPreferredSize(new Dimension(100, slideBox.getHeight()));
    slideBox.add(preview);
    slideBox.add(Box.createGlue());
    slideBox.add(opaqueSlide);
    slideBox.add(Box.createGlue());
    slidePanel.add(slideBox);
    // You know what, it just has to be something, so the
    // UIManager will think it's valid. It will get resized as
    // appropriate when the JDialog gets packed.
    slidePanel.setSize(new Dimension(50, 50));
    return slidePanel;
  }
Ejemplo n.º 3
0
 public YesNoPropertyEditor() {
   trueButton = new JRadioButton(i18n.get(YesNoPropertyEditor.class, "Yes", "Yes"));
   falseButton = new JRadioButton(i18n.get(YesNoPropertyEditor.class, "No", "No"));
 }