예제 #1
0
  public TickerTablePanel(MultiBitFrame mainFrame, ExchangeController exchangeController) {
    this.exchangeController = exchangeController;
    this.controller = this.exchangeController;

    this.mainFrame = mainFrame;

    font = FontSizer.INSTANCE.getAdjustedDefaultFontWithDelta(-1);
    fontMetrics = getFontMetrics(font);

    // Switch the dark and light row highlighting for Windows.
    if (System.getProperty("os.name", "unknown").startsWith("Win")) {
      moduloRow = 1;
    } else {
      moduloRow = 0;
    }

    initUI();

    applyComponentOrientation(
        ComponentOrientation.getOrientation(controller.getLocaliser().getLocale()));
  }
예제 #2
0
  private void createTicker() {
    setBackground(ColorAndFontConstants.BACKGROUND_COLOR);
    setLayout(new GridBagLayout());
    setOpaque(false);
    setFocusable(false);

    setToolTipText(
        HelpContentsPanel.createMultilineTooltipText(
            new String[] {
              controller.getLocaliser().getString("tickerTablePanel.tooltip"),
              "\n ",
              controller.getLocaliser().getString("tickerTablePanel.tooltip.clickToConfigure")
            }));

    // on mouse click - view the exchanges tab
    MouseListener viewPreferencesMouseListener =
        new MouseAdapter() {
          @Override
          public void mouseReleased(MouseEvent arg0) {
            controller.displayView(View.PREFERENCES_VIEW);
          }
        };

    String tickerTooltipText =
        HelpContentsPanel.createMultilineTooltipText(
            new String[] {
              controller.getLocaliser().getString("tickerTablePanel.tooltip"),
              "\n ",
              controller.getLocaliser().getString("tickerTablePanel.tooltip.clickToConfigure")
            });

    addMouseListener(viewPreferencesMouseListener);

    GridBagConstraints constraints = new GridBagConstraints();

    tickerTableModel = new TickerTableModel(this.exchangeController);

    table = new JTable(tickerTableModel);
    table.setOpaque(true);
    table.setShowGrid(true);
    table.setGridColor(Color.lightGray);
    table.setBackground(ColorAndFontConstants.BACKGROUND_COLOR);
    table.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, SystemColor.windowBorder));

    table.setComponentOrientation(
        ComponentOrientation.getOrientation(controller.getLocaliser().getLocale()));
    table.setRowHeight(getFontMetrics(FontSizer.INSTANCE.getAdjustedDefaultFont()).getHeight());

    table.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    table.setRowSelectionAllowed(false);
    table.setColumnSelectionAllowed(false);
    table.getTableHeader().setReorderingAllowed(false);

    table.setToolTipText(tickerTooltipText);
    table.addMouseListener(viewPreferencesMouseListener);
    table.getTableHeader().addMouseListener(viewPreferencesMouseListener);
    table.getTableHeader().setToolTipText(tickerTooltipText);
    table.getTableHeader().setFont(FontSizer.INSTANCE.getAdjustedDefaultFontWithDelta(-1));

    int tableHeaderHeight =
        fontMetrics.getHeight()
            + table.getTableHeader().getInsets().top
            + table.getTableHeader().getInsets().bottom;

    // Windows 8 has slightly taller headers so add a tweak for that.
    if (System.getProperty("os.name", "unknown").startsWith("Win")) {
      tableHeaderHeight = tableHeaderHeight + WINDOWS_TABLE_HEADER_HEIGHT_TWEAK;
    }

    int tickerWidth = setupColumnWidths();
    setupTableHeaders();

    idealHeight =
        (fontMetrics.getHeight() + table.getRowMargin()) * tickerTableModel.getRowCount()
            + tableHeaderHeight
            + tickerTableModel.getRowCount()
            + 10;

    setPreferredSize(new Dimension(tickerWidth, idealHeight));

    scrollPane =
        new JScrollPane(
            table,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

    scrollPane.setComponentOrientation(
        ComponentOrientation.getOrientation(controller.getLocaliser().getLocale()));
    scrollPane.setBorder(BorderFactory.createEmptyBorder());
    scrollPane.setViewportBorder(BorderFactory.createEmptyBorder());
    scrollPane.addMouseListener(viewPreferencesMouseListener);

    setupScrollPane(tickerWidth);

    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.gridwidth = 1;
    constraints.weightx = 1;
    constraints.weighty = 1;
    constraints.anchor = GridBagConstraints.CENTER;

    add(scrollPane, constraints);
  }