public void changeSelected(GameObjectPanel selected) { if (selected == selectedPanel) { selectedPanel.deSelect(); myWorldManager.setActiveObject("", -1); selectedPanel = null; return; } if (selectedPanel != null) selectedPanel.deSelect(); selectedPanel = selected; myWorldManager.setActiveObject( selected.getType(), myWorldManager.getNames(selected.getType()).indexOf(selected.getName())); }
@Override public void actionPerformed(ActionEvent e) { myTableDialog.stopEditing(); myWM.setData(myGTM); myPanel.refreshTab(myType); myTableDialog.setVisible(false); }
@Override public void actionPerformed(ActionEvent e) { GameTableModel gtm = myWM.getTableModel(myType); myTableDialog = new TableDialog( gtm, new DialogListener( myWM, gtm, myPanel, myType)); myTableDialog.setVisible(true); myTableDialog.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); }
private JScrollPane makeTab(String type) { JPanel panel = new JPanel(); GroupLayout layout = new GroupLayout(panel); layout.setAutoCreateGaps(true); layout.setAutoCreateContainerGaps(true); panel.setLayout(layout); JScrollPane scroll = new JScrollPane( panel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); scroll.setLayout(new ScrollPaneLayout()); SequentialGroup sg = layout.createSequentialGroup(); ParallelGroup pg = layout.createParallelGroup(); String editString = "Edit " + type + "s"; JButton editType = new JButton(editString); editType.addActionListener(new EditListener(myWorldManager, type, this)); sg.addComponent(editType); pg.addComponent(editType); List<String> tileNames = myWorldManager.getNames(type); for (int n = 0; n < tileNames.size(); n++) { GameObjectPanel gop = new GameObjectPanel(type, myWorldManager.getImage(type, n), tileNames.get(n), this); panel.add(gop); sg.addComponent(gop, 50, 50, 50); pg.addComponent(gop, 170, 170, 170); } layout.setVerticalGroup(sg); layout.setHorizontalGroup(pg); panel.revalidate(); panel.repaint(); scroll.setMaximumSize(new Dimension(200, 500)); return scroll; }