Пример #1
0
  public MemberRehearsalView(GemList<Room> roomList) {

    memberField = new GemField(35);
    memberField.setEditable(false);
    datePanel = new DateRangePanel(DateRangePanel.SIMPLE_DATE, null);
    hourPanel = new HourRangePanel(3 * 60);
    roomChoice = new RoomChoice(roomList);
    withCard = new JCheckBox(BundleUtil.getLabel("Subscription.label"));
    withCard.setBorder(null);
    this.setLayout(new GridBagLayout());
    GridBagHelper gb = new GridBagHelper(this);

    gb.add(new GemLabel(BundleUtil.getLabel("Member.label")), 0, 0, 1, 1, GridBagHelper.WEST);
    gb.add(new GemLabel(BundleUtil.getLabel("Date.label")), 0, 1, 1, 1, GridBagHelper.WEST);
    gb.add(new GemLabel(BundleUtil.getLabel("Hour.label")), 0, 2, 1, 1, GridBagHelper.WEST);
    gb.add(new GemLabel(BundleUtil.getLabel("Room.label")), 0, 3, 1, 1, GridBagHelper.WEST);
    // gb.add(new GemLabel(BundleUtil.getLabel("Subscription.label")), 0, 4, 1, 1,
    // GridBagHelper.EAST);

    gb.add(memberField, 1, 0, 1, 1, GridBagHelper.WEST);
    gb.add(datePanel, 1, 1, 1, 1, GridBagHelper.WEST);
    gb.add(hourPanel, 1, 2, 1, 1, GridBagHelper.WEST);
    gb.add(roomChoice, 1, 3, 1, 1, GridBagHelper.WEST);
    gb.add(withCard, 1, 4, 1, 1, GridBagHelper.WEST);
  }
Пример #2
0
 public void setJCheckbox(JCheckBox jcb) {
   jcb.setOpaque(false);
   jcb.setBorder(null);
   jcb.setBorderPainted(false);
   jcb.setMargin(new Insets(0, 0, 0, 0));
   jcb.setContentAreaFilled(false);
   jcb.setFocusable(false);
   jcb.setFont(new Font("ËÎÌå", 0, 12));
   jcb.addMouseListener(new ButtonListener());
 }
Пример #3
0
    public CheckBoxCellRenderer() {
      super();

      if (noFocusBorder == null) {
        noFocusBorder = new EmptyBorder(1, 1, 1, 1);
      }

      checkBox = new JCheckBox();
      checkBox.addItemListener(this);
      checkBox.setOpaque(true);
      checkBox.setBorder(noFocusBorder);
    }
Пример #4
0
 public Component getListCellRendererComponent(
     JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
   JCheckBox checkbox = (JCheckBox) value;
   if (!UIUtil.isUnderNimbusLookAndFeel()) {
     checkbox.setBackground(getBackground(isSelected, checkbox));
     checkbox.setForeground(getForeground(isSelected, checkbox));
   }
   checkbox.setEnabled(isEnabled());
   checkbox.setFont(getFont(checkbox));
   checkbox.setFocusPainted(false);
   checkbox.setBorderPainted(true);
   checkbox.setBorder(isSelected ? mySelectedBorder : myBorder);
   adjustRendering(checkbox, isSelected, cellHasFocus);
   return checkbox;
 }
Пример #5
0
    private Component getCell(
        JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
      checkBox.setSelected(((Boolean) value).booleanValue());
      checkBox.setFont(table.getFont());

      if (isSelected) {
        checkBox.setBackground(table.getSelectionBackground());
        checkBox.setForeground(table.getSelectionForeground());
      } else {
        checkBox.setBackground(table.getBackground());
        checkBox.setForeground(table.getForeground());
      }

      checkBox.setBorder(
          (hasFocus) ? UIManager.getBorder("Table.focusCellHighlightBorder") : noFocusBorder);

      return checkBox;
    }
Пример #6
0
    public Component getListCellRendererComponent(
        JList<? extends JCheckBox> list,
        JCheckBox value,
        int index,
        boolean isSelected,
        boolean cellHasFocus) {
      JCheckBox checkbox = value;

      // Drawing checkbox, change the appearance here
      checkbox.setBackground(isSelected ? getSelectionBackground() : getBackground());
      checkbox.setForeground(isSelected ? getSelectionForeground() : getForeground());
      checkbox.setEnabled(isEnabled());
      checkbox.setFont(getFont());
      checkbox.setFocusPainted(false);
      checkbox.setBorderPainted(true);
      checkbox.setBorder(
          isSelected ? UIManager.getBorder("List.focusCellHighlightBorder") : noFocusBorder);
      return checkbox;
    }
  @Override
  public JComponent createComponent() {
    JPanel wrapper = new JPanel(new FlowLayout(FlowLayout.LEFT));
    myHighlightRecentlyChanged = new JCheckBox("Show changed in last");
    myHighlightRecentlyChanged.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    myHighlightInterval =
        new JSpinner(new SpinnerNumberModel(1, 1, VcsContentAnnotationSettings.ourMaxDays, 1));
    wrapper.add(myHighlightRecentlyChanged);
    wrapper.add(myHighlightInterval);
    wrapper.add(new JLabel("days"));

    myHighlightRecentlyChanged.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            myHighlightInterval.setEnabled(myHighlightRecentlyChanged.isSelected());
          }
        });
    return wrapper;
  }
 public Component getListCellRendererComponent(
     JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
   if (containerBox == null) {
     containerBox = Box.createHorizontalBox();
     checkBox = new JCheckBox();
     checkBox.setEnabled(isEnabled());
     checkBox.setFont(getFont());
     checkBox.setFocusPainted(false);
     checkBox.setBorderPainted(true);
     checkBox.setBorder(
         isSelected ? UIManager.getBorder("List.focusCellHighlightBorder") : noFocusBorder);
     containerBox.add(checkBox);
   }
   checkBox.setBackground(isSelected ? getSelectionBackground() : getBackground());
   checkBox.setForeground(isSelected ? getSelectionForeground() : getForeground());
   if (value != null) {
     ListItem item = (ListItem) value;
     checkBox.setText(item.dataItem.toString());
     checkBox.setSelected(item.selected);
   }
   return containerBox;
 }
Пример #9
0
  private void buildDialog() {
    Window window = SwingUtilities.windowForComponent(target.getEditComponent());

    dialog = new JDialog(window, "Find / Replace");
    dialog.setModal(false);

    JPanel panel = new JPanel(new BorderLayout());
    findCombo = new JComboBox();
    findCombo.setEditable(true);
    replaceCombo = new JComboBox();
    replaceCombo.setEditable(true);

    // create inputs
    GridLayout gridLayout = new GridLayout(2, 2);
    gridLayout.setVgap(5);
    JPanel inputPanel = new JPanel(gridLayout);
    inputPanel.add(new JLabel("Find:"));
    inputPanel.add(findCombo);
    inputPanel.add(new JLabel("Replace with:"));
    inputPanel.add(replaceCombo);
    inputPanel.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));

    // create direction panel
    ButtonGroup directionGroup = new ButtonGroup();
    forwardButton = new JRadioButton("Forward", true);
    forwardButton.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
    directionGroup.add(forwardButton);
    backwardButton = new JRadioButton("Backward");
    backwardButton.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
    directionGroup.add(backwardButton);

    JPanel directionPanel = new JPanel(new GridLayout(2, 1));
    directionPanel.add(forwardButton);
    directionPanel.add(backwardButton);
    directionPanel.setBorder(BorderFactory.createTitledBorder("Direction"));

    // create scope panel
    ButtonGroup scopeGroup = new ButtonGroup();
    allButton = new JRadioButton("All", true);
    allButton.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
    selectedLinesButton = new JRadioButton("Selected Lines");
    selectedLinesButton.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
    scopeGroup.add(allButton);
    scopeGroup.add(selectedLinesButton);

    JPanel scopePanel = new JPanel(new GridLayout(2, 1));
    scopePanel.add(allButton);
    scopePanel.add(selectedLinesButton);
    scopePanel.setBorder(BorderFactory.createTitledBorder("Scope"));

    // create options
    caseCheck = new JCheckBox("Case Sensitive");
    caseCheck.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
    wholeWordCheck = new JCheckBox("Whole Word");
    wholeWordCheck.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
    wrapCheck = new JCheckBox("Wrap Search");
    wrapCheck.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
    JPanel optionsPanel = new JPanel(new GridLayout(3, 1));
    optionsPanel.add(caseCheck);
    optionsPanel.add(wholeWordCheck);
    optionsPanel.add(wrapCheck);
    optionsPanel.setBorder(BorderFactory.createTitledBorder("Options"));

    // create panel with options
    JPanel options = new JPanel(new GridLayout(1, 2));

    JPanel radios = new JPanel(new GridLayout(2, 1));
    radios.add(directionPanel);
    radios.add(scopePanel);

    options.add(optionsPanel);
    options.add(radios);
    options.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 8));

    // create buttons
    ButtonBarBuilder builder = new ButtonBarBuilder();
    findButton = new JButton(new FindAction());
    builder.addFixed(findButton);
    builder.addRelatedGap();
    replaceButton = new JButton(new ReplaceAction());
    builder.addFixed(replaceButton);
    builder.addRelatedGap();
    replaceAllButton = new JButton(new ReplaceAllAction());
    builder.addFixed(replaceAllButton);
    builder.addUnrelatedGap();
    builder.addFixed(new JButton(new CloseAction()));
    builder.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));

    // tie it up!
    panel.add(inputPanel, BorderLayout.NORTH);
    panel.add(options, BorderLayout.CENTER);
    panel.add(builder.getPanel(), BorderLayout.SOUTH);

    dialog.getContentPane().add(panel);
    dialog.pack();
    UISupport.initDialogActions(dialog, null, findButton);
  }
Пример #10
0
  public NameBean() {

    setLayout(LAYOUT.copy());

    cLast = new ChoiceWidget();
    cLast.addChangeListener(changeSupport);
    cLast.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            String msg = getReplaceAllMsg();
            if (msg != null) {
              cAll.setVisible(true);
              cAll.setToolTipText(msg);
            }
          }
        });
    cLast.setIgnoreCase(true);
    cFirst = new ChoiceWidget();
    cFirst.addChangeListener(changeSupport);
    cFirst.setIgnoreCase(true);
    tSuff = new TextFieldWidget("", 10);
    tSuff.addChangeListener(changeSupport);
    tNick = new TextFieldWidget("", 10);
    tNick.addChangeListener(changeSupport);

    cAll = new JCheckBox();
    cAll.setBorder(new EmptyBorder(1, 1, 1, 1));
    cAll.setVisible(false);
    cAll.setRequestFocusEnabled(false);

    add(new JLabel(PropertyName.getLabelForFirstName()));
    add(cFirst);

    add(new JLabel(PropertyName.getLabelForLastName()));
    add(cLast);
    add(cAll);

    add(new JLabel(PropertyName.getLabelForSuffix()));
    add(tSuff);

    add(new JLabel(Gedcom.getName("NICK")));
    add(tNick);

    // listen to selection of global and ask for confirmation
    cAll.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String msg = getReplaceAllMsg();
            if (msg != null && cAll.isSelected()) {
              int rc =
                  DialogHelper.openDialog(
                      RESOURCES.getString("choice.global.enable"),
                      DialogHelper.QUESTION_MESSAGE,
                      msg,
                      Action2.yesNo(),
                      NameBean.this);
              cAll.setSelected(rc == 0);
            }
          }
        });

    // we're done aside from declaring the default focus
    defaultFocus = cFirst;
  }
  protected boolean exportApplicationPrompt() throws IOException, SketchException {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.add(Box.createVerticalStrut(6));

    // Box panel = Box.createVerticalBox();

    // Box labelBox = Box.createHorizontalBox();
    //    String msg = "<html>Click Export to Application to create a standalone, " +
    //      "double-clickable application for the selected plaforms.";

    //    String msg = "Export to Application creates a standalone, \n" +
    //      "double-clickable application for the selected plaforms.";
    String line1 = "Export to Application creates double-clickable,";
    String line2 = "standalone applications for the selected plaforms.";
    JLabel label1 = new JLabel(line1, SwingConstants.CENTER);
    JLabel label2 = new JLabel(line2, SwingConstants.CENTER);
    label1.setAlignmentX(Component.LEFT_ALIGNMENT);
    label2.setAlignmentX(Component.LEFT_ALIGNMENT);
    //    label1.setAlignmentX();
    //    label2.setAlignmentX(0);
    panel.add(label1);
    panel.add(label2);
    int wide = label2.getPreferredSize().width;
    panel.add(Box.createVerticalStrut(12));

    final JCheckBox windowsButton = new JCheckBox("Windows");
    // windowsButton.setMnemonic(KeyEvent.VK_W);
    windowsButton.setSelected(Preferences.getBoolean("export.application.platform.windows"));
    windowsButton.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            Preferences.setBoolean(
                "export.application.platform.windows", windowsButton.isSelected());
          }
        });

    final JCheckBox macosxButton = new JCheckBox("Mac OS X");
    // macosxButton.setMnemonic(KeyEvent.VK_M);
    macosxButton.setSelected(Preferences.getBoolean("export.application.platform.macosx"));
    macosxButton.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            Preferences.setBoolean("export.application.platform.macosx", macosxButton.isSelected());
          }
        });

    final JCheckBox linuxButton = new JCheckBox("Linux");
    // linuxButton.setMnemonic(KeyEvent.VK_L);
    linuxButton.setSelected(Preferences.getBoolean("export.application.platform.linux"));
    linuxButton.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            Preferences.setBoolean("export.application.platform.linux", linuxButton.isSelected());
          }
        });

    JPanel platformPanel = new JPanel();
    // platformPanel.setLayout(new BoxLayout(platformPanel, BoxLayout.X_AXIS));
    platformPanel.add(windowsButton);
    platformPanel.add(Box.createHorizontalStrut(6));
    platformPanel.add(macosxButton);
    platformPanel.add(Box.createHorizontalStrut(6));
    platformPanel.add(linuxButton);
    platformPanel.setBorder(new TitledBorder("Platforms"));
    // Dimension goodIdea = new Dimension(wide, platformPanel.getPreferredSize().height);
    // platformPanel.setMaximumSize(goodIdea);
    wide = Math.max(wide, platformPanel.getPreferredSize().width);
    platformPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    panel.add(platformPanel);

    //  Box indentPanel = Box.createHorizontalBox();
    //  indentPanel.add(Box.createHorizontalStrut(new JCheckBox().getPreferredSize().width));
    final JCheckBox showStopButton = new JCheckBox("Show a Stop button");
    // showStopButton.setMnemonic(KeyEvent.VK_S);
    showStopButton.setSelected(Preferences.getBoolean("export.application.stop"));
    showStopButton.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            Preferences.setBoolean("export.application.stop", showStopButton.isSelected());
          }
        });
    showStopButton.setEnabled(Preferences.getBoolean("export.application.fullscreen"));
    showStopButton.setBorder(new EmptyBorder(3, 13, 6, 13));
    //  indentPanel.add(showStopButton);
    //  indentPanel.setAlignmentX(Component.LEFT_ALIGNMENT);

    final JCheckBox fullScreenButton = new JCheckBox("Full Screen (Present mode)");
    // fullscreenButton.setMnemonic(KeyEvent.VK_F);
    fullScreenButton.setSelected(Preferences.getBoolean("export.application.fullscreen"));
    fullScreenButton.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            boolean sal = fullScreenButton.isSelected();
            Preferences.setBoolean("export.application.fullscreen", sal);
            showStopButton.setEnabled(sal);
          }
        });
    fullScreenButton.setBorder(new EmptyBorder(3, 13, 3, 13));

    JPanel optionPanel = new JPanel();
    optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.Y_AXIS));
    optionPanel.add(fullScreenButton);
    optionPanel.add(showStopButton);
    //    optionPanel.add(indentPanel);
    optionPanel.setBorder(new TitledBorder("Options"));
    wide = Math.max(wide, platformPanel.getPreferredSize().width);
    // goodIdea = new Dimension(wide, optionPanel.getPreferredSize().height);
    optionPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    // optionPanel.setMaximumSize(goodIdea);
    panel.add(optionPanel);

    Dimension good;
    // label1, label2, platformPanel, optionPanel
    good = new Dimension(wide, label1.getPreferredSize().height);
    label1.setMaximumSize(good);
    good = new Dimension(wide, label2.getPreferredSize().height);
    label2.setMaximumSize(good);
    good = new Dimension(wide, platformPanel.getPreferredSize().height);
    platformPanel.setMaximumSize(good);
    good = new Dimension(wide, optionPanel.getPreferredSize().height);
    optionPanel.setMaximumSize(good);

    //    JPanel actionPanel = new JPanel();
    //    optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.X_AXIS));
    //    optionPanel.add(Box.createHorizontalGlue());

    //    final JDialog frame = new JDialog(editor, "Export to Application");

    //    JButton cancelButton = new JButton("Cancel");
    //    cancelButton.addActionListener(new ActionListener() {
    //      public void actionPerformed(ActionEvent e) {
    //        frame.dispose();
    //        return false;
    //      }
    //    });

    // Add the buttons in platform-specific order
    //    if (PApplet.platform == PConstants.MACOSX) {
    //      optionPanel.add(cancelButton);
    //      optionPanel.add(exportButton);
    //    } else {
    //      optionPanel.add(exportButton);
    //      optionPanel.add(cancelButton);
    //    }
    String[] options = {"Export", "Cancel"};
    final JOptionPane optionPane =
        new JOptionPane(
            panel,
            JOptionPane.PLAIN_MESSAGE,
            // JOptionPane.QUESTION_MESSAGE,
            JOptionPane.YES_NO_OPTION,
            null,
            options,
            options[0]);

    final JDialog dialog = new JDialog(this, "Export Options", true);
    dialog.setContentPane(optionPane);

    optionPane.addPropertyChangeListener(
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent e) {
            String prop = e.getPropertyName();

            if (dialog.isVisible()
                && (e.getSource() == optionPane)
                && (prop.equals(JOptionPane.VALUE_PROPERTY))) {
              // If you were going to check something
              // before closing the window, you'd do
              // it here.
              dialog.setVisible(false);
            }
          }
        });
    dialog.pack();
    dialog.setResizable(false);

    Rectangle bounds = getBounds();
    dialog.setLocation(
        bounds.x + (bounds.width - dialog.getSize().width) / 2,
        bounds.y + (bounds.height - dialog.getSize().height) / 2);
    dialog.setVisible(true);

    Object value = optionPane.getValue();
    if (value.equals(options[0])) {
      return jmode.handleExportApplication(sketch);
    } else if (value.equals(options[1]) || value.equals(new Integer(-1))) {
      // closed window by hitting Cancel or ESC
      statusNotice("Export to Application canceled.");
    }
    return false;
  }
Пример #12
0
  protected FontOptions(@NotNull ColorAndFontOptions options, final String title) {
    setLayout(new MigLayout("ins 0, gap 5, flowx"));
    Insets borderInsets =
        new Insets(
            IdeBorderFactory.TITLED_BORDER_TOP_INSET,
            IdeBorderFactory.TITLED_BORDER_LEFT_INSET,
            0,
            IdeBorderFactory.TITLED_BORDER_RIGHT_INSET);
    setBorder(IdeBorderFactory.createTitledBorder(title, false, borderInsets));
    myOptions = options;
    add(myOnlyMonospacedCheckBox, "sgx b, sx 2");

    add(new JLabel(ApplicationBundle.message("primary.font")), "newline, ax right");
    add(myPrimaryCombo, "sgx b");
    add(new JLabel(ApplicationBundle.message("editbox.font.size")), "gapleft 20");
    add(myEditorFontSizeField);
    add(new JLabel(ApplicationBundle.message("editbox.line.spacing")), "gapleft 20");
    add(myLineSpacingField);

    add(
        new JLabel(
            ApplicationBundle.message("label.fallback.fonts.list.description"),
            MessageType.INFO.getDefaultIcon(),
            SwingConstants.LEFT),
        "newline, sx 5");
    add(myUseSecondaryFontCheckbox, "newline, ax right");
    add(mySecondaryCombo, "sgx b");
    JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0));
    myEnableLigaturesCheckbox.setBorder(null);
    panel.add(myEnableLigaturesCheckbox);
    myLigaturesInfoLinkLabel =
        new LinkLabel<Void>(
            ApplicationBundle.message("ligatures.more.info"),
            null,
            new LinkListener<Void>() {
              @Override
              public void linkSelected(LinkLabel aSource, Void aLinkData) {
                BrowserUtil.browse(
                    "https://confluence.jetbrains.com/display/IDEADEV/Support+for+Ligatures+in+Editor");
              }
            });
    myLigaturesInfoLinkLabel.setBorder(new EmptyBorder(0, 5, 0, 0));
    panel.add(myLigaturesInfoLinkLabel);
    add(panel, "newline, sx 2");

    myOnlyMonospacedCheckBox.setBorder(null);
    myUseSecondaryFontCheckbox.setBorder(null);
    mySecondaryCombo.setEnabled(false);

    myOnlyMonospacedCheckBox.setSelected(
        EditorColorsManager.getInstance().isUseOnlyMonospacedFonts());
    myOnlyMonospacedCheckBox.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            EditorColorsManager.getInstance()
                .setUseOnlyMonospacedFonts(myOnlyMonospacedCheckBox.isSelected());
            myPrimaryCombo.setMonospacedOnly(myOnlyMonospacedCheckBox.isSelected());
            mySecondaryCombo.setMonospacedOnly(myOnlyMonospacedCheckBox.isSelected());
          }
        });
    myPrimaryCombo.setMonospacedOnly(myOnlyMonospacedCheckBox.isSelected());
    myPrimaryCombo.setRenderer(RENDERER);

    mySecondaryCombo.setMonospacedOnly(myOnlyMonospacedCheckBox.isSelected());
    mySecondaryCombo.setRenderer(RENDERER);

    myUseSecondaryFontCheckbox.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            mySecondaryCombo.setEnabled(myUseSecondaryFontCheckbox.isSelected());
            syncFontFamilies();
          }
        });
    ItemListener itemListener =
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
              syncFontFamilies();
            }
          }
        };
    myPrimaryCombo.addItemListener(itemListener);
    mySecondaryCombo.addItemListener(itemListener);

    ActionListener actionListener =
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            syncFontFamilies();
          }
        };
    myPrimaryCombo.addActionListener(actionListener);
    mySecondaryCombo.addActionListener(actionListener);

    myEditorFontSizeField
        .getDocument()
        .addDocumentListener(
            new DocumentAdapter() {
              @Override
              public void textChanged(DocumentEvent event) {
                if (myIsInSchemeChange || !SwingUtilities.isEventDispatchThread()) return;
                String selectedFont = myPrimaryCombo.getFontName();
                if (selectedFont != null) {
                  FontPreferences fontPreferences = getFontPreferences();
                  fontPreferences.register(selectedFont, getFontSizeFromField());
                }
                updateDescription(true);
              }
            });
    myEditorFontSizeField.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() != KeyEvent.VK_UP && e.getKeyCode() != KeyEvent.VK_DOWN) return;
            boolean up = e.getKeyCode() == KeyEvent.VK_UP;
            try {
              int value = Integer.parseInt(myEditorFontSizeField.getText());
              value += (up ? 1 : -1);
              value =
                  Math.min(
                      OptionsConstants.MAX_EDITOR_FONT_SIZE,
                      Math.max(OptionsConstants.MIN_EDITOR_FONT_SIZE, value));
              myEditorFontSizeField.setText(String.valueOf(value));
            } catch (NumberFormatException ignored) {
            }
          }
        });

    myLineSpacingField
        .getDocument()
        .addDocumentListener(
            new DocumentAdapter() {
              @Override
              public void textChanged(DocumentEvent event) {
                if (myIsInSchemeChange) return;
                float lineSpacing = getLineSpacingFromField();
                if (getLineSpacing() != lineSpacing) {
                  setCurrentLineSpacing(lineSpacing);
                }
                updateDescription(true);
              }
            });
    myLineSpacingField.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() != KeyEvent.VK_UP && e.getKeyCode() != KeyEvent.VK_DOWN) return;
            boolean up = e.getKeyCode() == KeyEvent.VK_UP;
            try {
              float value = Float.parseFloat(myLineSpacingField.getText());
              value += (up ? 1 : -1) * .1F;
              value =
                  Math.min(
                      OptionsConstants.MAX_EDITOR_LINE_SPACING,
                      Math.max(OptionsConstants.MIN_EDITOR_LINE_SPACING, value));
              myLineSpacingField.setText(String.format(Locale.ENGLISH, "%.1f", value));
            } catch (NumberFormatException ignored) {
            }
          }
        });
    myEnableLigaturesCheckbox.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            getFontPreferences().setUseLigatures(myEnableLigaturesCheckbox.isSelected());
          }
        });
  }
Пример #13
0
  public SceneLayoutApp() {
    super();
    new Pair();
    final JFrame frame = new JFrame("Scene Layout");

    final JPanel panel = new JPanel(new BorderLayout());
    frame.setContentPane(panel);
    final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setMaximumSize(screenSize);
    frame.setSize(screenSize);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    final JMenuBar mb = new JMenuBar();
    frame.setJMenuBar(mb);

    final JMenu jMenu = new JMenu("File");
    mb.add(jMenu);
    mb.add(new JMenu("Edit"));
    mb.add(new JMenu("Help"));
    JMenu menu = new JMenu("Look and Feel");

    //
    // Get all the available look and feel that we are going to use for
    // creating the JMenuItem and assign the action listener to handle
    // the selection of menu item to change the look and feel.
    //
    UIManager.LookAndFeelInfo[] lookAndFeelInfos = UIManager.getInstalledLookAndFeels();
    for (int i = 0; i < lookAndFeelInfos.length; i++) {
      final UIManager.LookAndFeelInfo lookAndFeelInfo = lookAndFeelInfos[i];
      JMenuItem item = new JMenuItem(lookAndFeelInfo.getName());
      item.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              try {
                //
                // Set the look and feel for the frame and update the UI
                // to use a new selected look and feel.
                //
                UIManager.setLookAndFeel(lookAndFeelInfo.getClassName());
                SwingUtilities.updateComponentTreeUI(frame);
              } catch (ClassNotFoundException e1) {
                e1.printStackTrace();
              } catch (InstantiationException e1) {
                e1.printStackTrace();
              } catch (IllegalAccessException e1) {
                e1.printStackTrace();
              } catch (UnsupportedLookAndFeelException e1) {
                e1.printStackTrace();
              }
            }
          });
      menu.add(item);
    }

    mb.add(menu);
    jMenu.add(new JMenuItem(new scene.action.QuitAction()));

    panel.add(new JScrollPane(desktopPane), BorderLayout.CENTER);
    final JToolBar bar = new JToolBar();

    panel.add(bar, BorderLayout.NORTH);

    final JComboBox comboNewWindow =
        new JComboBox(
            new String[] {"320:180", "320:240", "640:360", "640:480", "1280:720", "1920:1080"});

    comboNewWindow.addActionListener(new CreateSceneWindowAction());

    comboNewWindow.setBorder(BorderFactory.createTitledBorder("Create New Window"));
    bar.add(comboNewWindow);
    bar.add(
        new AbstractAction("Progress Bars") {

          /** Invoked when an action occurs. */
          @Override
          public void actionPerformed(ActionEvent e) {
            new ProgressBarAnimator();
          }
        });
    bar.add(
        new AbstractAction("Sliders") {

          /** Invoked when an action occurs. */
          @Override
          public void actionPerformed(ActionEvent e) {
            new SliderBarAnimator();
          }
        });

    final JCheckBox permaViz = new JCheckBox();
    permaViz.setText("Show the dump window");
    permaViz.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));

    dumpWindow = new JInternalFrame("perma dump window");
    dumpWindow.setContentPane(new JScrollPane(permText));

    permaViz.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            dumpWindow.setVisible(permaViz.isSelected());
          }
        });

    comboNewWindow.setMaximumSize(comboNewWindow.getPreferredSize());

    permaViz.setSelected(false);
    bar.add(new CreateWebViewV1Action());
    bar.add(new CreateWebViewV2Action());
    bar.add(permaViz);
    desktopPane.add(dumpWindow);
    dumpWindow.setSize(400, 400);
    dumpWindow.setResizable(true);
    dumpWindow.setClosable(false);
    dumpWindow.setIconifiable(false);
    final JMenuBar m = new JMenuBar();
    final JMenu cmenu = new JMenu("Create");
    m.add(cmenu);
    final JMenuItem menuItem =
        new JMenuItem(
            new AbstractAction("new") {
              @Override
              public void actionPerformed(ActionEvent e) {
                Runnable runnable =
                    new Runnable() {
                      public void run() {
                        Object[] in = (Object[]) XSTREAM.fromXML(permText.getText());

                        final JInternalFrame ff = new JInternalFrame();

                        final ScenePanel c = new ScenePanel();
                        ff.setContentPane(c);
                        desktopPane.add(ff);
                        final Dimension d = (Dimension) in[0];
                        c.setMaximumSize(d);
                        c.setPreferredSize(d);

                        ff.setSize(d.width + 50, d.height + 50);
                        ScenePanel.panes.put(c, (List<Pair<Point, ArrayList<URL>>>) in[1]);

                        c.invalidate();
                        c.repaint();

                        ff.pack();
                        ff.setClosable(true);

                        ff.setMaximizable(false);
                        ff.setIconifiable(false);
                        ff.setResizable(false);
                        ff.show();
                      }
                    };

                SwingUtilities.invokeLater(runnable);
              }
            });
    cmenu.add(menuItem);
    //        JMenuBar menuBar = new JMenuBar();

    //        getContentPane().add(menuBar);

    dumpWindow.setJMenuBar(m);
    frame.setVisible(true);
  }
Пример #14
0
  public CommonPanel(JFrame ownerFrame, IFileSelector fileSelectionPanel) {
    //		try {
    //			FileHandler fh = new FileHandler("log.txt");
    //			Logger.getLogger(CommonPanel.class.getName()).addHandler(fh);
    //		}catch(IOException ex) {
    //			Logger.getLogger(CommonPanel.class.getName()).log(Level.SEVERE, null, ex);
    //		}catch(SecurityException ex) {
    //			Logger.getLogger(CommonPanel.class.getName()).log(Level.SEVERE, null, ex);
    //		}
    this.ownerFrame = ownerFrame;
    this.fileSelectionPanel = fileSelectionPanel;
    this.fontSizeTF = new JTextField(4);
    fontSizeTF.setToolTipText("Enter the font size, e.g. 12, 10.5, 22.7");
    fontSizeTF.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (!fontSizeSpecRB.isSelected()) fontSizeSpecRB.setSelected(true);
          }
        });
    fontSizeTF.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent e) {
            super.mousePressed(e);
            if (!fontSizeSpecRB.isSelected()) fontSizeSpecRB.setSelected(true);
            System.out.println("fontSizeTF mousePressed");
          }

          @Override
          public void mouseExited(MouseEvent e) {
            MouseEvent event =
                new MouseEvent(
                    fontSizeSpecRB,
                    e.getID(),
                    e.getWhen(),
                    e.getModifiers(),
                    1,
                    1,
                    1,
                    e.isPopupTrigger(),
                    e.getButton());
            fontSizeSpecRB.dispatchEvent(event);
          }

          @Override
          public void mouseEntered(MouseEvent e) {
            MouseEvent event =
                new MouseEvent(
                    fontSizeSpecRB,
                    e.getID(),
                    e.getWhen(),
                    e.getModifiers(),
                    1,
                    1,
                    1,
                    e.isPopupTrigger(),
                    e.getButton());
            fontSizeSpecRB.dispatchEvent(event);
          }
        });
    String fontSizeRBToolTip =
        "<html>When this option is selected it enforces that"
            + "<br> the entered font size is used when creating the output file.";
    this.fontSizeSpecRB = new JRadioButton("Use the font size ");
    fontSizeSpecRB.setOpaque(false);
    fontSizeSpecRB.setToolTipText(fontSizeRBToolTip);
    JPanel fontSizeSpecPanel = new JPanel();
    fontSizeSpecPanel.setToolTipText(fontSizeRBToolTip);
    // pass events to radiobutton
    fontSizeSpecPanel.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent e) {
            MouseEvent event =
                new MouseEvent(
                    fontSizeSpecRB,
                    e.getID(),
                    e.getWhen(),
                    e.getModifiers(),
                    1,
                    1,
                    1,
                    e.isPopupTrigger(),
                    e.getButton());
            fontSizeSpecRB.dispatchEvent(event);
          }

          @Override
          public void mouseReleased(MouseEvent e) {
            MouseEvent event =
                new MouseEvent(
                    fontSizeSpecRB,
                    e.getID(),
                    e.getWhen(),
                    e.getModifiers(),
                    1,
                    1,
                    e.getClickCount(),
                    e.isPopupTrigger(),
                    e.getButton());
            fontSizeSpecRB.dispatchEvent(event);
          }

          @Override
          public void mouseExited(MouseEvent e) {
            MouseEvent event =
                new MouseEvent(
                    fontSizeSpecRB,
                    e.getID(),
                    e.getWhen(),
                    e.getModifiers(),
                    1,
                    1,
                    e.getClickCount(),
                    e.isPopupTrigger(),
                    e.getButton());
            fontSizeSpecRB.dispatchEvent(event);
          }

          @Override
          public void mouseEntered(MouseEvent e) {
            MouseEvent event =
                new MouseEvent(
                    fontSizeSpecRB,
                    e.getID(),
                    e.getWhen(),
                    e.getModifiers(),
                    1,
                    1,
                    e.getClickCount(),
                    e.isPopupTrigger(),
                    e.getButton());
            fontSizeSpecRB.dispatchEvent(event);
          }
        });
    fontSizeSpecPanel.add(fontSizeSpecRB);
    fontSizeSpecPanel.add(fontSizeTF);
    fontSizeSpecPanel.setBorder(BorderFactory.createEtchedBorder());
    fontSizeSpecPanel.setOpaque(false);
    this.fitTextToWidthRB = new JRadioButton("Fit text to page width ");
    fitTextToWidthRB.setBorder(BorderFactory.createEtchedBorder());
    fitTextToWidthRB.setBorderPainted(true);
    fitTextToWidthRB.setOpaque(false);
    fitTextToWidthRB.setToolTipText(
        "<html>Don't care about the font size, but make sure"
            + "<br> the width of input file content will fit into "
            + "<br>a whole width of a 'pdf' page.");

    ButtonGroup fontBG = new ButtonGroup();
    fontBG.add(fontSizeSpecRB);
    fontBG.add(fitTextToWidthRB);
    fitTextToWidthRB.setSelected(true);

    double p = TableLayout.PREFERRED;
    TableLayout fontSelectPL =
        new TableLayout(new double[] {.5, p, p, p, .5}, new double[] {.5, p, .5});
    JPanel fontSelectP = new JPanel(fontSelectPL);
    fontSelectP.setOpaque(false);
    fontSelectP.add(fontSizeSpecPanel, "1,1,L,C");
    fontSelectP.add(new JLabel(" or "), "2,1,C,C");
    fontSelectP.add(fitTextToWidthRB, "3,1,R,F");

    String[] fonts = {
      BaseFont.COURIER,
      BaseFont.HELVETICA,
      BaseFont.SYMBOL,
      BaseFont.TIMES_ROMAN,
      BaseFont.ZAPFDINGBATS
    }; // , "fonts/lucon.ttf"};
    // load font files from the fonts folder
    String fontFolder = "fonts";
    String[] fontFileNames = new String[0];
    //		Logger.getLogger(CommonPanel.class.getName()).log(Level.INFO,
    //				"ownerFrame must be instanceof Txt2PDFConverterIN is it?="
    //				+(ownerFrame instanceof Txt2PDFConverterIN)
    //				+"; ownerFrame.getClass().getName()="+ownerFrame.getClass().getName());
    if (ownerFrame instanceof Txt2PDFConverterIN)
      try {
        fontFileNames = getResourceListing(this.getClass(), fontFolder + "/");
      } catch (Exception ex) {
        // ignore, it could happen when fonts folder doesn't exist, it does
        // happen when debugging since the folder doesn't exist.
        // But the folder always is packed in the compact(IN) version of the program.
      }
    else {
      fontFileNames = new File(fontFolder).list();
    }
    //		Logger.getLogger(CommonPanel.class.getName()).log(Level.INFO,
    //				"fontFileNames=" + Arrays.toString(fontFileNames));
    int initialFontsSize = fonts.length;
    if (fontFileNames.length > 0) {
      int newFontsSize = initialFontsSize + fontFileNames.length;
      fonts = Arrays.copyOf(fonts, newFontsSize);
      for (int i = initialFontsSize; i < newFontsSize; i++)
        fonts[i] = fontFolder + "/" + fontFileNames[i - initialFontsSize];
    }
    this.fontCB = new JComboBox(fonts);
    fontCB.setBorder(BorderFactory.createEtchedBorder());
    fontCB.setToolTipText("Select the font to use for output.");
    String[] encodings = {BaseFont.CP1252, BaseFont.CP1250, BaseFont.CP1257, BaseFont.MACROMAN};
    this.encodingCB = new JComboBox(encodings);
    encodingCB.setBorder(BorderFactory.createEtchedBorder());
    encodingCB.setToolTipText("Select encoding used by the input file.");
    this.portraitRB = new JRadioButton("Portrait ");
    portraitRB.setBorder(BorderFactory.createEtchedBorder());
    portraitRB.setBorderPainted(true);
    portraitRB.setOpaque(false);
    portraitRB.setToolTipText("The output file will have pages in portrait orientation.");
    this.landscapeRB = new JRadioButton("Landscape ");
    landscapeRB.setBorder(BorderFactory.createEtchedBorder());
    landscapeRB.setBorderPainted(true);
    landscapeRB.setOpaque(false);
    landscapeRB.setToolTipText("The output file will have pages in landscape orientation.");
    ButtonGroup pageOrientBG = new ButtonGroup();
    pageOrientBG.add(portraitRB);
    pageOrientBG.add(landscapeRB);
    portraitRB.setSelected(true);

    // panel with page orientation settings
    TableLayout pageOrientPL =
        new TableLayout(new double[] {5, p, p, p, 5}, new double[] {TableLayout.FILL});
    JPanel pageOrientP = new JPanel(pageOrientPL);
    pageOrientP.setOpaque(false);
    pageOrientP.add(portraitRB, "1,0,L,F");
    pageOrientP.add(new JLabel(" or "), "2,0,C,C");
    pageOrientP.add(landscapeRB, "3,0,R,F");
    pageOrientP.setBorder(BorderFactory.createEtchedBorder());

    TableLayout encodeOrientPL =
        new TableLayout(
            new double[] {10, p, 5, p, TableLayout.FILL, p, 10}, new double[] {.5, p, .5});
    JPanel fontEncodeOrientP = new JPanel(encodeOrientPL);
    fontEncodeOrientP.setOpaque(false);
    fontEncodeOrientP.add(fontCB, "1,1,L,F");
    fontEncodeOrientP.add(encodingCB, "3,1,L,F");
    fontEncodeOrientP.add(pageOrientP, "5,1,R,F");

    this.overwriteOutputFileChB = new JCheckBox("Overwrite output file ");
    overwriteOutputFileChB.setToolTipText(
        "When selected it will overwrite the output file if it exists.");
    overwriteOutputFileChB.setBorder(BorderFactory.createEtchedBorder());
    overwriteOutputFileChB.setBorderPainted(true);
    overwriteOutputFileChB.setOpaque(false);
    int bW = 80;
    int bH = 30;
    this.convertB = new JButton(copnvertAction);
    convertB.setPreferredSize(new Dimension(bW, bH));
    convertB.setToolTipText("Convert the input 'txt' file applying all the selected settings.");
    this.exitB = new JButton(exitAction);
    exitB.setPreferredSize(new Dimension(bW, bH));
    exitB.setToolTipText("Exit the program.");
    TableLayout buttonPL =
        new TableLayout(new double[] {.25, p, .5, p, .25}, new double[] {5, p, 5});
    JPanel buttonP = new JPanel(buttonPL);
    buttonP.setOpaque(false);
    buttonP.add(convertB, "1,1,C,C");
    buttonP.add(exitB, "3,1,C,C");

    JLabel infoL = new JLabel("<html><p>&nbsp Select conversion settings.</p>");
    TableLayout layout =
        new TableLayout(
            new double[] {.5, p, .5}, new double[] {.5, p, 5, p, 5, p, 5, p, 10, p, .5});
    setLayout(layout);
    add(infoL, "1,1,L,C");
    add(fontSelectP, "1,3,F,C");
    add(fontEncodeOrientP, "1,5,F,C");
    add(overwriteOutputFileChB, "1,7,C,F");
    add(buttonP, "1,9,F,C");
  }