I'm looking for a solution (library) to generate and/or display a dynamic seating chart using Java (and Swing/JFace).
There should be possibilities to add color to single seats and for defining events. Is there any ready to use library or standard-procedure?
Thanks in advance
there no required looking for some solution or library (sure google can returns that), but could be so easilly done by implements JToggleButton & Icon (or Color), very siple example
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class TheaterJToggle {
private int rows = 6;
private int columns = 8;
private Icon res = (UIManager.getIcon("OptionPane.errorIcon"));
public TheaterJToggle() {
JPanel panel = new JPanel(new GridLayout(columns, rows));
for (int row = 0; row < rows; row++) {
for (int column = 0; column < columns; column++) {
final JToggleButton button = new JToggleButton("Row " + row + " seat " + column);
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
AbstractButton abstractButton = (AbstractButton) actionEvent.getSource();
boolean selected = abstractButton.getModel().isSelected();
if (selected) {
button.setIcon(res);
} else {
button.setIcon(null);
}
}
});
panel.add(button);
}
}
final JFrame frame = new JFrame("JToggleButton Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(panel);
frame.pack();
frame.setLocation(150, 150);
frame.setVisible(true);
}
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
TheaterJToggle theaterJToggle = new TheaterJToggle();
}
});
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.