consolidate duplicate code into super class.

master
lodici 2017-02-04 17:06:12 +00:00
parent 297ed6c188
commit 141fcc7e1c
4 changed files with 6 additions and 16 deletions

View File

@ -10,7 +10,6 @@ import javax.swing.SwingUtilities;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.TableModelEvent;
import javax.swing.table.JTableHeader;
import magic.model.MagicCardDefinition;
import magic.ui.FontsAndBorders;
@ -33,10 +32,6 @@ public class CardTablePanelA extends CardsTablePanel {
// listener to change card image on selection
table.getSelectionModel().addListSelectionListener(getTableListSelectionListener());
// listener to sort on column header click
final JTableHeader header = table.getTableHeader();
header.addMouseListener(new ColumnListener());
// add table to scroll pane
scrollpane.setViewportView(table);
scrollpane.setBorder(FontsAndBorders.NO_BORDER);

View File

@ -12,7 +12,6 @@ import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.TableModelEvent;
import javax.swing.table.JTableHeader;
import magic.model.MagicCardDefinition;
import magic.model.MagicRandom;
import magic.ui.FontsAndBorders;
@ -32,10 +31,6 @@ public class CardTablePanelB extends CardsTablePanel
// listener to change card image on selection
table.getSelectionModel().addListSelectionListener(this);
// listener to sort on column header click
final JTableHeader header = table.getTableHeader();
header.addMouseListener(new ColumnListener());
// add table to scroll pane
scrollpane.setViewportView(table);
scrollpane.setBorder(FontsAndBorders.NO_BORDER);

View File

@ -5,6 +5,7 @@ import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.List;
import javax.swing.event.TableModelEvent;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableColumnModel;
import magic.data.GeneralConfig;
import magic.model.MagicCardDefinition;
@ -37,6 +38,10 @@ abstract class CardsTablePanel extends TexturedPanel {
if (!GeneralConfig.getInstance().isPreviewCardOnSelect()) {
table.addMouseMotionListener(getRowMouseOverListener());
}
// listener to sort on column header click
final JTableHeader header = table.getTableHeader();
header.addMouseListener(new ColumnListener());
setLayout(migLayout);
refreshLayout();
@ -84,7 +89,7 @@ abstract class CardsTablePanel extends TexturedPanel {
}
}
protected class ColumnListener extends MouseAdapter {
private class ColumnListener extends MouseAdapter {
@Override
public void mouseClicked(final MouseEvent e) {
final TableColumnModel colModel = table.getColumnModel();

View File

@ -10,7 +10,6 @@ import javax.swing.SwingUtilities;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.TableModelEvent;
import javax.swing.table.JTableHeader;
import magic.model.MagicCardDefinition;
import magic.model.MagicDeck;
import magic.ui.FontsAndBorders;
@ -35,10 +34,6 @@ public class DeckTablePanel extends CardsTablePanel {
this.listSelListener = getTableListSelectionListener();
table.getSelectionModel().addListSelectionListener(listSelListener);
// listener to sort on column header click
final JTableHeader header = table.getTableHeader();
header.addMouseListener(new ColumnListener());
// add table to scroll pane
scrollpane.setViewportView(table);
scrollpane.setBorder(FontsAndBorders.NO_BORDER);