private JComboBox<String> comboFuelStations;
private JComboBox<FuelType> comboFuelTypes;
private JTextArea outputArea;
- private JPanel contentPane;
+ private JPanel contentPane = new JPanel();
private JList<String> listFuelStations;
private JTable tableFuelTypesPerStation;
private javax.swing.table.DefaultTableModel fuelTableModel;
}
float total = Main.getTotalStockLevelOfFuel(type, selectedStations);
- appendOutput(String.format("Total stock of %s across %d chosen fuel stations: %.2f L", type, indices.length, total));
+ appendOutput(String.format("Total stock of %s across %d chosen fuel stations: %.2f L", type, indices.length,
+ total));
});
buttonPanel.add(btnTotalPrice);
private JPanel createPricePanel() {
JPanel panel = new JPanel(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
- gbc.insets = new Insets(5,5,5,5);
+ gbc.insets = new Insets(5, 5, 5, 5);
gbc.fill = GridBagConstraints.HORIZONTAL;
JLabel lblPrice = new JLabel("New price per litre (€):");
station.set_price(type, newPrice);
appendOutput(String.format(
"Price changed of %s at %s to %.3f €/L.",
- type, getDisplayName(station), newPrice
- ));
+ type, getDisplayName(station), newPrice));
txtPrice.setText("");
} catch (NumberFormatException ex) {
showError("Please enter a valid number for the price.");
}
});
- gbc.gridx = 0; gbc.gridy = 0;
+ gbc.gridx = 0;
+ gbc.gridy = 0;
panel.add(lblPrice, gbc);
gbc.gridx = 1;
panel.add(txtPrice, gbc);
- gbc.gridx = 0; gbc.gridy = 1; gbc.gridwidth = 2;
+ gbc.gridx = 0;
+ gbc.gridy = 1;
+ gbc.gridwidth = 2;
panel.add(btnSave, gbc);
return panel;
private JPanel createStockPanel() {
JPanel panel = new JPanel(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
- gbc.insets = new Insets(5,5,5,5);
+ gbc.insets = new Insets(5, 5, 5, 5);
gbc.fill = GridBagConstraints.HORIZONTAL;
JLabel lblAmount = new JLabel("Amount (litre):");
station.set_stored_amount(value, type);
appendOutput(String.format(
"Changed stock of %s at %s to %.2f litre.",
- type, getDisplayName(station), value
- ));
+ type, getDisplayName(station), value));
txtAmount.setText("");
} else {
float updated = current + value;
station.add_stored_amount(value, type);
appendOutput(String.format(
"Stock changed of %s at %s by %.2f litre.",
- type, getDisplayName(station), value
- ));
+ type, getDisplayName(station), value));
txtAmount.setText("");
}
} catch (NumberFormatException ex) {
});
int y = 0;
- gbc.gridx = 0; gbc.gridy = y;
+ gbc.gridx = 0;
+ gbc.gridy = y;
panel.add(lblAmount, gbc);
gbc.gridx = 1;
panel.add(txtAmount, gbc);
y++;
- gbc.gridx = 0; gbc.gridy = y; gbc.gridwidth = 2;
+ gbc.gridx = 0;
+ gbc.gridy = y;
+ gbc.gridwidth = 2;
panel.add(rbAbsolute, gbc);
y++;
return panel;
}
- private int getCapacity(FuelStation station, FuelType type) throws NoSuchFuelTypeError {
+ private int getCapacity(FuelStation station, FuelType type) throws NoSuchFuelTypeError {
for (Fuel f : station.fuels) {
if (f.FUEL_TYPE == type) {
return f.CAPACITY;
JTextField txtAtrributes = new JTextField(15);
JLabel lblHint = new JLabel("Small: amount of vending machines, Medium: m^2, Large: supermarket-company");
- JButton btnAdd = new JButton("Add fuel station");
+ JButton btnAdd = new JButton("Add fuel station");
btnAdd.addActionListener(e -> {
try {
if (rbSmall.isSelected()) {
} else if (rbLarge.isSelected()) {
String supermarketCompany = txtAtrributes.getText().trim();
Main.addNewFuelStation(supermarketCompany);
- appendOutput("Fuel station with supermarket-company" + supermarketCompany + " has been added.");
+ appendOutput("Fuel station with supermarket-company" + supermarketCompany + " has been added.");
}
refreshStationNames();
txtAtrributes.setText("");
});
int y = 0;
- gbc.gridx = 0; gbc.gridy = y;
+ gbc.gridx = 0;
+ gbc.gridy = y;
gbc.gridwidth = 3;
panel.add(new JLabel("Type of new fuel station:"), gbc);
panel.add(rbLarge, gbc);
y++;
- gbc.gridx = 0; gbc.gridy = y;
+ gbc.gridx = 0;
+ gbc.gridy = y;
panel.add(lblAtrributes, gbc);
- gbc.gridx = 1; gbc.gridwidth = 2;
+ gbc.gridx = 1;
+ gbc.gridwidth = 2;
panel.add(txtAtrributes, gbc);
y++;
- gbc.gridx = 0; gbc.gridy = y;
+ gbc.gridx = 0;
+ gbc.gridy = y;
gbc.gridwidth = 3;
panel.add(lblHint, gbc);
private JPanel createOverviewPanel() {
JPanel panel = new JPanel(new BorderLayout());
- fuelTableModel = new DefaultTableModel(new Object[]{"Fuel station", "Station type", "Fuel", "Amount (L)", "Capacity (L)", "Price (€/L)"}, 0) {
+ fuelTableModel = new DefaultTableModel(
+ new Object[] { "Fuel station", "Station type", "Fuel", "Amount (L)", "Capacity (L)", "Price (€/L)" },
+ 0) {
@Override
public boolean isCellEditable(int row, int column) {
return false;