[英]Java: theater seating chart
I'm looking for a solution (library) to generate and/or display a dynamic seating chart using Java (and Swing/JFace). 我正在寻找一种使用Java(和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 没有必要寻找一些解决方案或库(确保Google可以返回它),但是可以通过实现JToggleButton&Icon(或Color)如此简单地完成,非常简单的示例
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();
}
});
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.