consolidate duplicate code into super class.
parent
297ed6c188
commit
141fcc7e1c
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
@ -38,6 +39,10 @@ abstract class CardsTablePanel extends TexturedPanel {
|
|||
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();
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue