Add toString to GUI_ViewBuses
This commit is contained in:
parent
67c81d22d6
commit
1db0ce7ca7
@ -33,7 +33,7 @@ public class Bus extends CivilVehicle {
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder s = new StringBuilder();
|
StringBuilder s = new StringBuilder();
|
||||||
s.append(String.format("\nID: %s, Campaign ID: %s\n",this.getUID() , getCampaign().getUID()));
|
s.append(String.format("ID: %s, Campaign ID: %s\n",this.getUID() , getCampaign().getUID()));
|
||||||
s.append(super.toString());
|
s.append(super.toString());
|
||||||
return s.toString();
|
return s.toString();
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,10 @@ import javax.swing.JButton;
|
|||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import javax.swing.table.DefaultTableModel;
|
import javax.swing.table.DefaultTableModel;
|
||||||
import javax.swing.JTable;
|
import javax.swing.JTable;
|
||||||
|
import javax.swing.ListSelectionModel;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.DropMode;
|
||||||
|
import javax.swing.JTextPane;
|
||||||
|
|
||||||
public class GUI_ViewBuses {
|
public class GUI_ViewBuses {
|
||||||
|
|
||||||
@ -26,10 +30,11 @@ public class GUI_ViewBuses {
|
|||||||
private static JButton Almansoor;
|
private static JButton Almansoor;
|
||||||
private static JLabel lblTime;
|
private static JLabel lblTime;
|
||||||
private static JLabel lblDate;
|
private static JLabel lblDate;
|
||||||
JLabel lblStatus;
|
private JLabel lblStatus;
|
||||||
private JLabel lblDestination;
|
private JLabel lblDestination;
|
||||||
private JLabel lblDistrict;
|
private JLabel lblDistrict;
|
||||||
private JLabel lblDistrictValue;
|
private JLabel lblDistrictValue;
|
||||||
|
private JTextPane textPane;
|
||||||
|
|
||||||
|
|
||||||
public GUI_ViewBuses(ArrayList<Campaign> campaign , PDate currenttimeManager) {
|
public GUI_ViewBuses(ArrayList<Campaign> campaign , PDate currenttimeManager) {
|
||||||
@ -75,6 +80,13 @@ public class GUI_ViewBuses {
|
|||||||
table.setCellSelectionEnabled(true);
|
table.setCellSelectionEnabled(true);
|
||||||
DefaultTableModel model = new DefaultTableModel();
|
DefaultTableModel model = new DefaultTableModel();
|
||||||
model.setColumnIdentifiers(busColNames);
|
model.setColumnIdentifiers(busColNames);
|
||||||
|
ListSelectionModel model2 = table.getSelectionModel();
|
||||||
|
model2.addListSelectionListener(e -> {
|
||||||
|
if (!model2.isSelectionEmpty()) {
|
||||||
|
int row = model2.getMinSelectionIndex();
|
||||||
|
textPane.setText(((Bus)vehicles.get(row)).toString());
|
||||||
|
}
|
||||||
|
});
|
||||||
table.getTableHeader().setBackground(new Color(17,17,17));
|
table.getTableHeader().setBackground(new Color(17,17,17));
|
||||||
table.getTableHeader().setFont(new Font("Rockwell", Font.PLAIN, 18));
|
table.getTableHeader().setFont(new Font("Rockwell", Font.PLAIN, 18));
|
||||||
table.getTableHeader().setForeground(Color.WHITE);
|
table.getTableHeader().setForeground(Color.WHITE);
|
||||||
@ -169,6 +181,16 @@ public class GUI_ViewBuses {
|
|||||||
lblDistrictValue.setBounds(247, 371, 129, 12);
|
lblDistrictValue.setBounds(247, 371, 129, 12);
|
||||||
frame.getContentPane().add(lblDistrictValue);
|
frame.getContentPane().add(lblDistrictValue);
|
||||||
|
|
||||||
|
textPane = new JTextPane();
|
||||||
|
textPane.setFont(new Font("Rockwell", Font.PLAIN, 16));
|
||||||
|
textPane.setForeground(Color.WHITE);
|
||||||
|
textPane.setBackground(Color.BLACK);
|
||||||
|
|
||||||
|
JScrollPane scrolltext = new JScrollPane(textPane);
|
||||||
|
scrolltext.setBounds(523, 271, 384, 133);
|
||||||
|
frame.getContentPane().add(scrolltext);
|
||||||
|
|
||||||
|
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user