public void updatePageCounterField(int n) { if (pageCounterField == null) return; if (n == 0) { pageCounterField.setBackground(pageCounterFieldDefaultColor); pageCounterField.setForeground(Color.BLACK); pageCounterButton.setForeground(pageCounterButtonDefaultForeground); } else { pageCounterField.setBackground(pageCounterFieldColor); pageCounterField.setForeground(Color.WHITE); pageCounterButton.setForeground(pageCounterFieldColor); } pageCounterField.setText("" + n); }
/** Sets a textfield where the number of pages will be displayed */ public void setPageCounterField(JTextField _field, Color _color, JComponent _button) { pageCounterField = _field; pageCounterFieldDefaultColor = _field.getBackground(); pageCounterFieldColor = _color; this.pageCounterButton = _button; this.pageCounterButtonDefaultForeground = _button.getForeground(); }