我的申请允许用户选择一种选择,根据用户选择,从构成部分中删除一个联合小组,增加新的联合小组,并重新验证该构成部分。
参看法典:
if (c != null) {
contentPane.remove(c);
iii
c = new AddBookInterface(theLibrary);
contentPane.add(c);
contentPane.revalidate();
break;
c is a Component
我有几家JPanels,用户可以妥善开关和开关。 然而,当我选择用户时添加这一联合小组时,事后添加的联合小组并没有适当负荷。 是什么原因?
public class RemoveBookInterface extends JPanel {
private Library theLibrary;
public RemoveBookInterface(Library theLibrary) {
this.theLibrary = theLibrary;
setSize(400, 400);
setLayout(new BorderLayout());
setVisible(true);
removeBook(theLibrary);
iii
public void removeBook(Library theLibrary) {
// prompt user for book id of book to remove
Long ID = Long
.parseLong(JOptionPane
.showInputDialog("Enter the library book ID for the book you want to remove"));
try {
// get library book info and store it to display in message
LibraryBook lb = theLibrary.getInventory().findLibraryBook(ID);
// remove book
theLibrary.removeBook(ID);
// display message indicating book was removed
JOptionPane
.showMessageDialog(
null,
"The following library book was removed:
"
+ lb.toString());
iii catch (Exception e1) {
JOptionPane.showMessageDialog(null, e1.getMessage());
iii
iii
iii