Example #1
0
  private void show(int _current) {
    OpenDefinitionsDocument doc = _docs.get(_current);

    String text = getTextFor(doc);

    _label.setText(_displayManager.getName(doc));
    _label.setIcon(_displayManager.getIcon(doc));

    if (text.length() > 0) {
      // as wide as the text area wants, but only 200px high
      _textpane.setText(text);
      _scroller.setPreferredSize(_textpane.getPreferredScrollableViewportSize());
      if (_scroller.getPreferredSize().getHeight() > 200)
        _scroller.setPreferredSize(
            new Dimension((int) _scroller.getPreferredSize().getWidth(), 200));

      _scroller.setVisible(_showSource);
    } else _scroller.setVisible(false);

    Dimension d = _label.getMinimumSize();
    d.setSize(d.getWidth() + _padding * 2, d.getHeight() + _padding * 2);
    _label.setPreferredSize(d);
    _label.setHorizontalAlignment(SwingConstants.CENTER);
    _label.setVerticalAlignment(SwingConstants.CENTER);
    pack();
    centerH();
  }
Example #2
0
  private void updateFontColor() {
    Font mainFont = DrJava.getConfig().getSetting(OptionConstants.FONT_MAIN);
    Color backColor = DrJava.getConfig().getSetting(OptionConstants.DEFINITIONS_BACKGROUND_COLOR);
    Color fontColor = DrJava.getConfig().getSetting(OptionConstants.DEFINITIONS_NORMAL_COLOR);
    /* make it bigger */
    Font titleFont = mainFont.deriveFont((float) (mainFont.getSize() + 3));
    _antiAliasText = DrJava.getConfig().getSetting(OptionConstants.TEXT_ANTIALIAS).booleanValue();

    _label.setForeground(fontColor);
    _panel.setBackground(backColor);
    _label.setFont(titleFont);
    _textpane.setForeground(fontColor);
    _textpane.setFont(mainFont);
    ;
    _textpane.setBackground(backColor);
    _scroller.setBackground(backColor);
    _scroller.setBorder(new EmptyBorder(0, 0, 0, 0));
    _panel.setBorder(new LineBorder(fontColor, 1));
  }
Example #3
0
  public RecentDocFrame(MainFrame f) {
    super();
    _frame = f;
    _current = 0;
    _label =
        new JLabel("...") {
          // Enable anti-aliased text by overriding paintComponent.
          protected void paintComponent(Graphics g) {
            if (_antiAliasText && g instanceof Graphics2D) {
              Graphics2D g2d = (Graphics2D) g;
              g2d.setRenderingHint(
                  RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
            }
            super.paintComponent(g);
          }
        };
    _panel = new JPanel();
    _scroller = new JScrollPane();
    _textpane =
        new JTextPane() {
          // Enable anti-aliased text by overriding paintComponent.
          protected void paintComponent(Graphics g) {
            if (_antiAliasText && g instanceof Graphics2D) {
              Graphics2D g2d = (Graphics2D) g;
              g2d.setRenderingHint(
                  RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
            }
            super.paintComponent(g);
          }
        };

    _textpane.setText("...");
    _scroller.getViewport().add(_textpane);
    _scroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
    _scroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    _scroller.setMaximumSize(new Dimension(300, 200));

    _panel.setLayout(new BorderLayout());
    _panel.add(_label, BorderLayout.NORTH);
    _panel.add(_scroller, BorderLayout.SOUTH);

    getContentPane().add(_panel);
    pack();
    updateFontColor();
    _showSource = DrJava.getConfig().getSetting(OptionConstants.SHOW_SOURCE_WHEN_SWITCHING);
    DrJava.getConfig()
        .addOptionListener(OptionConstants.DEFINITIONS_BACKGROUND_COLOR, _colorListener);
    DrJava.getConfig().addOptionListener(OptionConstants.DEFINITIONS_NORMAL_COLOR, _colorListener);
    DrJava.getConfig().addOptionListener(OptionConstants.FONT_MAIN, _fontListener);
    DrJava.getConfig().addOptionListener(OptionConstants.TEXT_ANTIALIAS, _antialiasListener);
    DrJava.getConfig()
        .addOptionListener(OptionConstants.SHOW_SOURCE_WHEN_SWITCHING, _showSourceListener);
  }