|
17 | 17 | import org.mage.card.arcane.ManaSymbols;
|
18 | 18 |
|
19 | 19 | import javax.swing.*;
|
| 20 | +import javax.swing.event.ListSelectionEvent; |
| 21 | +import javax.swing.event.ListSelectionListener; |
20 | 22 | import java.awt.*;
|
21 | 23 | import java.awt.event.*;
|
22 | 24 | import java.util.List;
|
@@ -152,7 +154,7 @@ private void initComponents() {
|
152 | 154 | setBackgroundPainter(mwPanelPainter);
|
153 | 155 |
|
154 | 156 | title = new ColorPane();
|
155 |
| - title.setFont(new Font("Times New Roman", 1, sizeMod(15))); |
| 157 | + title.setFont(new Font("Times New Roman", Font.BOLD, sizeMod(15))); |
156 | 158 | title.setEditable(false);
|
157 | 159 | title.setFocusCycleRoot(false);
|
158 | 160 | title.setOpaque(false);
|
@@ -186,11 +188,14 @@ private void initComponents() {
|
186 | 188 | rows.addMouseListener(new MouseAdapter() {
|
187 | 189 | @Override
|
188 | 190 | public void mousePressed(MouseEvent evt) {
|
189 |
| - if (SwingUtilities.isLeftMouseButton(evt)) { |
| 191 | + if (SwingUtilities.isLeftMouseButton(evt) && !rows.isSelectionEmpty()) { |
190 | 192 | objectMouseClicked(evt);
|
191 | 193 | }
|
192 | 194 | }
|
193 | 195 | });
|
| 196 | + } |
| 197 | + }); |
| 198 | + |
194 | 199 | rows.setSelectedIndex(0);
|
195 | 200 | rows.setFont(new Font("Times New Roman", 1, sizeMod(17)));
|
196 | 201 | rows.setBorder(BorderFactory.createEmptyBorder());
|
@@ -233,18 +238,16 @@ public void mousePressed(MouseEvent evt) {
|
233 | 238 |
|
234 | 239 | @Override
|
235 | 240 | public void mouseWheelMoved(MouseWheelEvent e) {
|
236 |
| - int notches = e.getWheelRotation(); |
237 |
| - int index = rows.getSelectedIndex(); |
238 |
| - |
239 |
| - if (notches < 0) { |
240 |
| - if (index > 0) { |
241 |
| - rows.setSelectedIndex(index - 1); |
242 |
| - rows.repaint(); |
243 |
| - } |
244 |
| - } else if (index < choices.size() - 1) { |
245 |
| - rows.setSelectedIndex(index + 1); |
246 |
| - rows.repaint(); |
| 241 | + int direction = e.getWheelRotation() < 0 ? -1 : +1; |
| 242 | + int index = rows.getSelectedIndex() + direction; |
| 243 | + if (index < 0) { |
| 244 | + index = 0; |
| 245 | + } else if (index >= choices.size()) { |
| 246 | + index = choices.size() - 1; |
247 | 247 | }
|
| 248 | + |
| 249 | + rows.setSelectedIndex(index); |
| 250 | + rows.repaint(); |
248 | 251 | }
|
249 | 252 |
|
250 | 253 | private void objectMouseClicked(MouseEvent event) {
|
|
0 commit comments