Beispiel #1
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);
  }