use of javax.swing.JTable in project megameklab by MegaMek.
the class CriticalTransferHandler method importData.
@Override
public boolean importData(TransferSupport info) {
if (!info.isDrop()) {
return false;
}
if (info.getComponent() instanceof DropTargetCriticalList) {
DropTargetCriticalList<?> list = (DropTargetCriticalList<?>) info.getComponent();
location = Integer.parseInt(list.getName());
Transferable t = info.getTransferable();
try {
Mounted mount = getUnit().getEquipment(Integer.parseInt((String) t.getTransferData(DataFlavor.stringFlavor)));
if (!UnitUtil.isValidLocation(getUnit(), mount.getType(), location)) {
JOptionPane.showMessageDialog(null, mount.getName() + " can't be placed in " + getUnit().getLocationName(location) + "!", "Invalid Location", JOptionPane.INFORMATION_MESSAGE);
return false;
}
if (!getUnit().addCritical(location, new CriticalSlot(mount))) {
JOptionPane.showMessageDialog(null, "Location Full", "Location Full", JOptionPane.INFORMATION_MESSAGE);
} else {
changeMountStatus(mount, location, false);
}
} catch (Exception ex) {
ex.printStackTrace();
}
return true;
}
if ((info.getComponent() instanceof JTable) || (info.getComponent() instanceof JScrollPane)) {
try {
Transferable t = info.getTransferable();
Mounted mount = getUnit().getEquipment(Integer.parseInt((String) t.getTransferData(DataFlavor.stringFlavor)));
if (getUnit() instanceof BattleArmor) {
mount.setBaMountLoc(BattleArmor.MOUNT_LOC_NONE);
} else {
UnitUtil.removeCriticals(getUnit(), mount);
changeMountStatus(mount, Entity.LOC_NONE, false);
}
} catch (Exception ex) {
ex.printStackTrace();
}
return true;
}
return false;
}
use of javax.swing.JTable in project megameklab by MegaMek.
the class AeroBayTransferHandler method createTransferable.
@Override
protected Transferable createTransferable(JComponent c) {
if (c instanceof BayWeaponCriticalTree) {
return new StringSelection(((BayWeaponCriticalTree) c).encodeSelection());
} else {
JTable table = (JTable) c;
StringJoiner sj = new StringJoiner(",");
for (int row : table.getSelectedRows()) {
Mounted mount = (Mounted) ((CriticalTableModel) table.getModel()).getValueAt(row, CriticalTableModel.EQUIPMENT);
sj.add(Integer.toString(eSource.getEntity().getEquipmentNum(mount)));
}
return new StringSelection(sj.toString());
}
}
use of javax.swing.JTable in project JWildfire by thargor6.
the class TinaInternalFrame method getLayersTable.
private JTable getLayersTable() {
if (layersTable == null) {
layersTable = new JTable();
layersTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
layersTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
if (!e.getValueIsAdjusting()) {
tinaController.layersTableClicked();
}
}
});
}
return layersTable;
}
use of javax.swing.JTable in project JWildfire by thargor6.
the class TinaInternalFrame method getCreatePaletteColorsTable.
/**
* This method initializes createPaletteColorsTable
*
* @return javax.swing.JTable
*/
private JTable getCreatePaletteColorsTable() {
if (createPaletteColorsTable == null) {
createPaletteColorsTable = new JTable();
createPaletteColorsTable.setFont(Prefs.getPrefs().getFont("Dialog", Font.PLAIN, 10));
createPaletteColorsTable.setSize(new Dimension(177, 80));
}
return createPaletteColorsTable;
}
use of javax.swing.JTable in project JWildfire by thargor6.
the class TinaInternalFrame method getTabbedPane.
private JTabbedPane getTabbedPane() {
if (tabbedPane == null) {
tabbedPane = new JTabbedPane(JTabbedPane.TOP);
tabbedPane.addTab("Description", null, getPanel_60(), null);
tabbedPane.addTab("Code preview", null, getPanel_61(), null);
JPanel panel_1 = new JPanel();
tabbedPane.addTab("Macro buttons", null, panel_1, null);
panel_1.setLayout(new BorderLayout(0, 0));
JPanel panel_2 = new JPanel();
panel_2.setPreferredSize(new Dimension(120, 10));
panel_1.add(panel_2, BorderLayout.CENTER);
panel_2.setLayout(new BorderLayout(0, 0));
JScrollPane scrollPane_2 = new JScrollPane();
scrollPane_2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
scrollPane_2.setBorder(null);
panel_2.add(scrollPane_2, BorderLayout.CENTER);
macroButtonsTable = new JTable();
macroButtonsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
macroButtonsTable.setFont(Prefs.getPrefs().getFont("Dialog", Font.PLAIN, 10));
macroButtonsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
if (!e.getValueIsAdjusting()) {
tinaController.getJwfScriptController().macroButtonsTableClicked();
}
}
});
scrollPane_2.setViewportView(macroButtonsTable);
JPanel panel_3 = new JPanel();
FlowLayout flowLayout = (FlowLayout) panel_3.getLayout();
flowLayout.setHgap(0);
flowLayout.setVgap(1);
panel_3.setPreferredSize(new Dimension(124, 10));
panel_1.add(panel_3, BorderLayout.EAST);
JPanel panel_9 = new JPanel();
panel_9.setPreferredSize(new Dimension(116, 4));
panel_9.setMinimumSize(new Dimension(116, 8));
panel_9.setMaximumSize(new Dimension(32767, 8));
panel_3.add(panel_9);
macroButtonMoveUpBtn = new JButton();
macroButtonMoveUpBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
tinaController.getJwfScriptController().macroButtonMoveUp();
}
});
macroButtonMoveUpBtn.setToolTipText("Move the button one up in the list");
macroButtonMoveUpBtn.setText("Up");
macroButtonMoveUpBtn.setPreferredSize(new Dimension(58, 24));
macroButtonMoveUpBtn.setMinimumSize(new Dimension(58, 12));
macroButtonMoveUpBtn.setMaximumSize(new Dimension(58, 12));
macroButtonMoveUpBtn.setFont(Prefs.getPrefs().getFont("Dialog", Font.BOLD, 10));
macroButtonMoveUpBtn.setBounds(new Rectangle(9, 280, 125, 24));
panel_3.add(macroButtonMoveUpBtn);
macroButtonMoveDownBtn = new JButton();
macroButtonMoveDownBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
tinaController.getJwfScriptController().macroButtonMoveDown();
}
});
macroButtonMoveDownBtn.setToolTipText("Move the button one down in the list");
macroButtonMoveDownBtn.setText("Down");
macroButtonMoveDownBtn.setPreferredSize(new Dimension(58, 24));
macroButtonMoveDownBtn.setMinimumSize(new Dimension(58, 12));
macroButtonMoveDownBtn.setMaximumSize(new Dimension(58, 12));
macroButtonMoveDownBtn.setFont(Prefs.getPrefs().getFont("Dialog", Font.BOLD, 10));
macroButtonMoveDownBtn.setBounds(new Rectangle(9, 280, 125, 24));
panel_3.add(macroButtonMoveDownBtn);
JPanel panel_8 = new JPanel();
panel_8.setPreferredSize(new Dimension(116, 4));
panel_8.setMinimumSize(new Dimension(116, 8));
panel_8.setMaximumSize(new Dimension(32767, 8));
panel_3.add(panel_8);
macroButtonDeleteBtn = new JButton();
macroButtonDeleteBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
tinaController.getJwfScriptController().macroButtonDelete();
}
});
macroButtonDeleteBtn.setToolTipText("Delete the button");
macroButtonDeleteBtn.setText("Delete");
macroButtonDeleteBtn.setPreferredSize(new Dimension(116, 24));
macroButtonDeleteBtn.setFont(Prefs.getPrefs().getFont("Dialog", Font.BOLD, 10));
macroButtonDeleteBtn.setBounds(new Rectangle(9, 280, 125, 24));
panel_3.add(macroButtonDeleteBtn);
}
return tabbedPane;
}
Aggregations