Gridarta Editor
DoubleButtonList.java
Go to the documentation of this file.
1 /*
2  * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games.
3  * Copyright (C) 2000-2023 The Gridarta Developers.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 package net.sf.gridarta.gui.utils.tabbedpanel;
21 
22 import java.awt.BorderLayout;
23 import java.awt.Component;
24 import java.awt.Container;
25 import javax.swing.AbstractButton;
26 import javax.swing.JPanel;
28 import org.jetbrains.annotations.NotNull;
29 import org.jetbrains.annotations.Nullable;
30 
36 public class DoubleButtonList {
37 
41  @NotNull
42  private final Container buttons = new JPanel();
43 
48  @NotNull
49  private final ButtonList leftButtonList;
50 
55  @NotNull
56  private final ButtonList rightButtonList;
57 
62  public DoubleButtonList(@NotNull final Location location) {
63  leftButtonList = new ButtonList(location);
64  rightButtonList = new ButtonList(location);
65  buttons.setLayout(new BorderLayout());
66  buttons.add(leftButtonList.getButtons(), location.getBorderLocationStandardLocation());
67  buttons.add(rightButtonList.getButtons(), location.getBorderLocationAlternativeLocation());
68  }
69 
75  public void addButtonListListener(@NotNull final ButtonListListener listener) {
78  }
79 
86  public void addButton(@NotNull final AbstractButton button, final boolean alternativeLocation) {
87  final ButtonList buttonList = alternativeLocation ? rightButtonList : leftButtonList;
88  buttonList.addButton(button);
89  buttons.validate();
90  }
91 
98  public void removeButton(@NotNull final AbstractButton button, final boolean alternativeLocation) {
99  final ButtonList buttonList = alternativeLocation ? rightButtonList : leftButtonList;
100  buttonList.removeButton(button);
101  buttons.validate();
102  }
103 
110  public void selectButton(@NotNull final AbstractButton button, final boolean alternativeLocation) {
111  final ButtonList buttonList = alternativeLocation ? rightButtonList : leftButtonList;
112  buttonList.selectButton(button);
113  }
114 
121  @Nullable
122  public AbstractButton getSelectedButton(final boolean alternativeLocation) {
123  final ButtonList buttonList = alternativeLocation ? rightButtonList : leftButtonList;
124  return buttonList.getSelectedButton();
125  }
126 
131  @NotNull
132  public Component getButtons() {
133  return buttons;
134  }
135 
140  public int getButtonCount() {
142  }
143 
144 }
net.sf.gridarta.gui.utils.tabbedpanel.DoubleButtonList.removeButton
void removeButton(@NotNull final AbstractButton button, final boolean alternativeLocation)
Removes a button.
Definition: DoubleButtonList.java:98
net.sf.gridarta.gui.utils.tabbedpanel.DoubleButtonList.rightButtonList
final ButtonList rightButtonList
The Container that contains all buttons in the alternative location.
Definition: DoubleButtonList.java:56
net.sf.gridarta.gui.utils.tabbedpanel.DoubleButtonList.addButtonListListener
void addButtonListListener(@NotNull final ButtonListListener listener)
Adds a ButtonListListener to be notified.
Definition: DoubleButtonList.java:75
net.sf.gridarta
Base package of all Gridarta classes.
net.sf.gridarta.gui.utils.tabbedpanel.DoubleButtonList
A list of buttons divided into two parts.
Definition: DoubleButtonList.java:36
net.sf
net.sf.gridarta.gui.utils.tabbedpanel.ButtonList.removeButton
void removeButton(@NotNull final AbstractButton button)
Removes a button.
Definition: ButtonList.java:128
net.sf.gridarta.gui.utils.tabbedpanel.ButtonList
A list of buttons where at most one button is active at any time.
Definition: ButtonList.java:41
net.sf.gridarta.gui.utils.tabbedpanel.ButtonList.addButton
void addButton(@NotNull final AbstractButton button)
Adds a button.
Definition: ButtonList.java:101
net.sf.gridarta.gui
Graphical User Interface of Gridarta.
net.sf.gridarta.gui.utils.tabbedpanel.DoubleButtonList.getButtons
Component getButtons()
Returns the Container that contains all buttons.
Definition: DoubleButtonList.java:132
net
net.sf.gridarta.gui.utils.tabbedpanel.ButtonList.getButtonCount
int getButtonCount()
Returns the total number of buttons.
Definition: ButtonList.java:194
net.sf.gridarta.gui.utils.tabbedpanel.DoubleButtonList.selectButton
void selectButton(@NotNull final AbstractButton button, final boolean alternativeLocation)
Selects a button.
Definition: DoubleButtonList.java:110
net.sf.gridarta.gui.utils.tabbedpanel.DoubleButtonList.buttons
final Container buttons
The Container that contains all buttons.
Definition: DoubleButtonList.java:42
net.sf.gridarta.gui.utils.tabbedpanel.ButtonList.getSelectedButton
AbstractButton getSelectedButton()
Returns the currently selected button.
Definition: ButtonList.java:177
net.sf.gridarta.gui.utils.tabbedpanel.ButtonList.addButtonListListener
void addButtonListListener(@NotNull final ButtonListListener listener)
Adds a ButtonListListener to be notified.
Definition: ButtonList.java:93
net.sf.gridarta.gui.utils.borderpanel.Location
A location.
Definition: Location.java:33
net.sf.gridarta.gui.utils.tabbedpanel.ButtonListListener
Interface for listeners interested in ButtonList related events.
Definition: ButtonListListener.java:30
net.sf.gridarta.gui.utils.borderpanel
Definition: BorderPanel.java:20
net.sf.gridarta.gui.utils.tabbedpanel.DoubleButtonList.addButton
void addButton(@NotNull final AbstractButton button, final boolean alternativeLocation)
Adds a button.
Definition: DoubleButtonList.java:86
net.sf.gridarta.gui.utils.tabbedpanel.ButtonList.getButtons
Component getButtons()
Returns the Container that contains all buttons.
Definition: ButtonList.java:186
net.sf.gridarta.gui.utils
Definition: AnimationComponent.java:20
net.sf.gridarta.gui.utils.tabbedpanel.DoubleButtonList.getSelectedButton
AbstractButton getSelectedButton(final boolean alternativeLocation)
Returns the currently selected button.
Definition: DoubleButtonList.java:122
net.sf.gridarta.gui.utils.tabbedpanel.DoubleButtonList.leftButtonList
final ButtonList leftButtonList
The Container that contains all buttons in the standard location.
Definition: DoubleButtonList.java:49
net.sf.gridarta.gui.utils.tabbedpanel.ButtonList.selectButton
void selectButton(@NotNull final AbstractButton button)
Selects a button.
Definition: ButtonList.java:148
net.sf.gridarta.gui.utils.tabbedpanel.DoubleButtonList.DoubleButtonList
DoubleButtonList(@NotNull final Location location)
Creates a new instance.
Definition: DoubleButtonList.java:62
net.sf.gridarta.gui.utils.tabbedpanel.DoubleButtonList.getButtonCount
int getButtonCount()
Returns the total number of buttons.
Definition: DoubleButtonList.java:140