throw new IndexOutOfBoundsException(String.format(
"min (%d) > max (%d)", min, max));
}
throw new IndexOutOfBoundsException(String.format(
"min (%d) > max (%d)", min, max));
}
navButtons = new JButton[4];
navButtons[0] = createNavButton("<<", new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setIndex(GuiReaderNavBar.this.min);
navButtons = new JButton[4];
navButtons[0] = createNavButton("<<", new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setIndex(GuiReaderNavBar.this.min);
}
});
navButtons[1] = createNavButton(" < ", new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setIndex(index - 1);
}
});
navButtons[1] = createNavButton(" < ", new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setIndex(index - 1);
}
});
navButtons[2] = createNavButton(" > ", new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setIndex(index + 1);
}
});
navButtons[2] = createNavButton(" > ", new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setIndex(index + 1);
}
});
navButtons[3] = createNavButton(">>", new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setIndex(GuiReaderNavBar.this.max);
}
});
navButtons[3] = createNavButton(">>", new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setIndex(GuiReaderNavBar.this.max);
throw new IndexOutOfBoundsException(String.format(
"Index %d but min/max is [%d/%d]", index, min, max));
}
this.index = index;
throw new IndexOutOfBoundsException(String.format(
"Index %d but min/max is [%d/%d]", index, min, max));
}
this.index = index;
for (ActionListener listener : listeners) {
try {
listener.actionPerformed(new ActionEvent(this,
ActionEvent.ACTION_FIRST, "page changed"));
} catch (Exception e) {
for (ActionListener listener : listeners) {
try {
listener.actionPerformed(new ActionEvent(this,
ActionEvent.ACTION_FIRST, "page changed"));
} catch (Exception e) {
private void updateEnabled() {
navButtons[0].setEnabled(index > min);
navButtons[1].setEnabled(index > min);
private void updateEnabled() {
navButtons[0].setEnabled(index > min);
navButtons[1].setEnabled(index > min);
protected String computeLabel(int index,
@SuppressWarnings("unused") int min, int max) {
protected String computeLabel(int index,
@SuppressWarnings("unused") int min, int max) {
- return String.format(display, index, max, label);
+ if (max >= 0) {
+ return String.format(display, index, max, label);
+ }
+
+ return String.format(display, index, label);