* Create the frame.
*/
- public HouseFeaturesGUI(RuralHouse RH, Date FirstDay, Date LastDay) {
+ public HouseFeaturesGUI(RuralHouse RH, final Date FirstDay, final Date LastDay) {
this.rh = RH;
this.getContentPane().setLayout(null);
setBounds(100, 100, 500, 583);
scrollPane.setBounds(40, 311, 376, 183);
contentPane.add(scrollPane);
- JTable table = new JTable() {
+ table = new JTable() {
private static final long serialVersionUID = 1L;
public boolean isCellEditable(int row, int column) {
Date firstDay = (Date) table.getModel().getValueAt(row, 1);
Date lastDay = (Date) table.getModel().getValueAt(row, 2);
if (FirstDay != null && LastDay != null) {
- if (FirstDay.before(firstDay) || FirstDay.equals(firstDay)
- && LastDay.after(lastDay)
- || LastDay.equals(lastDay)) {
- setBackground(Color.GREEN);
+ if (LastDay.before(lastDay) || FirstDay.after(firstDay)) {
+ setBackground(Color.RED);
setForeground(Color.BLACK);
} else {
- setBackground(Color.RED);
+ setBackground(Color.GREEN);
setForeground(Color.BLACK);
}
}
jComboBox1 = new JComboBox<RuralHouse>(v);
- comboBox_o = new JComboBox<Offer>();
+ comboBox_o = new JComboBox<Offer>(((RuralHouse)jComboBox1.getSelectedItem()).getAllOffers());
+ DateFormat dateformat1 = DateFormat.getDateInstance(1, jCalendar1.getLocale());
+ jTextField1.setText(dateformat1.format(((Offer) comboBox_o.getSelectedItem()).getFirstDay()));
+ jTextField2.setText(dateformat1.format(((Offer) comboBox_o.getSelectedItem()).getLastDay()));
jComboBox1.setBounds(new Rectangle(115, 12, 115, 20));
jLabel1.setText("List of houses:");
scrollPane.setBounds(23, 113, 536, 271);
contentPane.add(scrollPane);
- JTable table = new JTable() {
+ table = new JTable() {
private static final long serialVersionUID = 1L;
public boolean isCellEditable(int row, int column) {