Форум программистов, компьютерный форум, киберфорум
Java SE (J2SE)
Войти
Регистрация
Восстановить пароль
Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.80/5: Рейтинг темы: голосов - 5, средняя оценка - 4.80
0 / 0 / 0
Регистрация: 08.06.2010
Сообщений: 9

shedule

08.06.2010, 21:05. Показов 1087. Ответов 3
Метки нет (Все метки)

Студворк — интернет-сервис помощи студентам
Я сделала все зто. но мне надо закончить последний class "Save".Вы можете помочь мне.когда "Save"button нажмите тогда надо уменшать количество свободных мест(Number of free place).там есть три Java code.но надо заполнить AirSystemGUI код.вот код:

Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
import java.awt.*;
import java.awt.event.*;
 
import javax.swing.*;
 
import java.io.*;
import java.util.*; 
/**
 * Displays the information in an address book.
 *
 * @author  Sabdirova Aidyn
 * @version 1.0.0
 */
public class AirSystemGUI extends JPanel {
 
    /* Delimiter */
    private final String  DELIM = "_";
 
     private static PrintWriter  stdErr =
            new PrintWriter(System.err, true);
 
    
    /* Window width in pixels */
    static private int  WIDTH = 450;
 
    /* Window height in pixels */
    static private int  HEIGHT = 300;
    private JLabel name;
    private JLabel date;
    private JLabel surname;
    
    private JTextArea nameText;
    private JTextArea dateText;
    private JTextArea surnameText;
    
    private JButton saveButton;
    private JButton cancelButton;
    private JButton  openButton;
    private JButton  displayButton;
    private JButton  orderButton;
    private JLabel  numberOfEntriesLabel;
    private JTextField  fileNameTextField;
    private JTextField  dateOfFlightTextField;
    private JTextField  numberOfRouteTextField;
    private JTextField  numberOfFreePlaceTextField;
    private JList  dateList;
    private JTextArea  statusTextArea;
 
    private AirSystem airSystem;
 
    /**
     * Creates a window.
     *
     * @param args  not used.
     */
    public static void main(String[] args) {
 
        JFrame frame = new JFrame("Air System");
        frame.setResizable(false);
        frame.setContentPane(new AirSystemGUI());
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setVisible(true);
    }
 
    /**
     * Creates a graphical user interface.
     */
    public AirSystemGUI() {
 
        setBackground(Color.blue);
 
        // Create the components
        openButton = new JButton("Open File");
        displayButton = new JButton("Display");
        orderButton = new JButton("Order");
        numberOfEntriesLabel = new JLabel("0 entries");
        fileNameTextField = new JTextField("", 17);
        dateOfFlightTextField = new JTextField("", 7);
        numberOfRouteTextField = new JTextField("", 5);
        numberOfFreePlaceTextField = new JTextField("", 2);
        dateList = new JList();
        statusTextArea = new JTextArea(4, 50);
 
        // Customize the components
        dateList.setVisibleRowCount(8);
        dateList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        dateList.setFixedCellHeight(16);
        dateList.setFixedCellWidth(130);
        numberOfEntriesLabel.setHorizontalAlignment(JLabel.CENTER);
        dateOfFlightTextField.setEditable(false);
        numberOfRouteTextField.setEditable(false);
        numberOfFreePlaceTextField.setEditable(false);
        statusTextArea.setEditable(false);
 
        // Register the listeners for the buttons
        openButton.addActionListener(new OpenButtonListener());
        displayButton.addActionListener(new DisplayButtonListener());
        orderButton.addActionListener(new OrderButtonListener());
        // North panel
        JPanel northPanel = new JPanel();
 
        northPanel.add(new JLabel("File name: "));
        northPanel.add(fileNameTextField);
        northPanel.add(openButton);
 
        // West panel
        JPanel westPanel= new JPanel(new BorderLayout());
        westPanel.add(numberOfEntriesLabel,BorderLayout.CENTER);
        westPanel.add(new JScrollPane(dateList), BorderLayout.NORTH);
        westPanel.add(displayButton, BorderLayout.SOUTH);
        
        JPanel eastPanel= new JPanel(new BorderLayout());
        eastPanel.add(orderButton, BorderLayout.SOUTH);
        // Center panel
        JPanel centerPanel = new JPanel();
        JPanel infoPanel = new JPanel(new BorderLayout());
        GridLayout layout = new GridLayout(3, 1);
        JPanel labelsPanel = new JPanel(layout);
        JPanel valuesPanel = new JPanel(layout);
 
        layout.setVgap(10);
        labelsPanel.add(new JLabel ("Date Of Flight: "));
        labelsPanel.add(new JLabel ("Number Of Route: "));
        labelsPanel.add(new JLabel("Number Of Free Place: "));
        valuesPanel.add(dateOfFlightTextField);
        valuesPanel.add(numberOfRouteTextField);
        valuesPanel.add(numberOfFreePlaceTextField);
        infoPanel.add(labelsPanel, BorderLayout.WEST);
        infoPanel.add(valuesPanel, BorderLayout.CENTER);
        centerPanel.add(infoPanel);
 
        // Arrange panels in window
        setLayout(new BorderLayout());
        add(northPanel, BorderLayout.NORTH);
        add(westPanel, BorderLayout.WEST);
        add(eastPanel, BorderLayout.EAST);
        add(centerPanel, BorderLayout.CENTER);
        add(statusTextArea, BorderLayout.SOUTH);
 
        airSystem = new AirSystem();
    }
 
    /**
     * This inner class handles <code>openButton</code> events.
     */
    class OpenButtonListener implements ActionListener {
 
        /**
         * Loads address book data from the specified file and displays
         * the names in a list. Also displays, beneath the list, the number2
         * of names in the address book.
         *
         * @param event  the event object.
         */
        public void actionPerformed(ActionEvent event)  {
 
 
             try { 
                 
                   String file = fileNameTextField.getText(); 
                   BufferedReader  in =  
                                new BufferedReader(new FileReader(file)); 
                   
                   /* Removing all entries in the address book if it has any. */ 
                   airSystem.removeAllEntries(); 
                   
                   /* Clearing the status area. */ 
                   statusTextArea.removeAll(); 
                         
                   /* Read the first line in the specified file. */ 
                   String  line = in.readLine(); 
                         
                   /* The information of the person in the address book. */ 
                 String dateOfFlight = ""; 
                 int numberOfRoute;
                 int numberOfFreePlace; 
                  
                  /* Load the data of the specified file into the empty address book. */ 
                while (line != null)  { 
                         
                  StringTokenizer token =  
                                new StringTokenizer(line,  DELIM); 
                         
                        if( token.countTokens() != 3 ) { 
                             
                            /* A line does not have the expected number of tokens. */ 
                            statusTextArea.setText( "Badly-formed line:"+"\n"+line+"\"."); 
                         
                        } else { 
                             
                            /* Load the data of the current line into the now-empty address book. */ 
                            dateOfFlight = token.nextToken(); 
                            numberOfRoute = Integer.parseInt(token.nextToken()); 
                            numberOfFreePlace = Integer.parseInt(token.nextToken()); 
                                 
                            AirSystemEntry addressBE =  
                                            new AirSystemEntry(dateOfFlight,numberOfRoute,numberOfFreePlace); 
                            airSystem.addEntry( addressBE ); 
                    } 
                        
                        /* Read next line in the specified file. */ 
                        line = in.readLine(); 
                    } 
                   
                 /* Close the file. */ 
                   in.close(); 
                         
                   /* Display the names of the people in the names list. */ 
                   dateList.setListData( airSystem.getNames()); 
                    
                   /* Update the label that displays the number of people in the address book. */ 
                   numberOfEntriesLabel.setText( airSystem.getNumberOfEntries()+"entries" ); 
                       
                   /* Clears nameTextField, addressTextField, and telephoneTextField. */ 
                   dateOfFlightTextField.removeAll(); 
                   numberOfRouteTextField.removeAll(); 
                   numberOfFreePlaceTextField.removeAll(); 
                         
            } catch(FileNotFoundException fnfn) { 
                 
                /* The specified file does not exist. */ 
                 statusTextArea.setText( "The file does not exist." ); 
                  
            } catch (IOException ioe) { 
                 
                /* An error occurs while reading data from the specified file. */ 
                 statusTextArea.setText( ioe.toString() ); 
            } 
             
        } 
    } 
 
    /** 
     * This inner class handles displayButton events. 
     */ 
    class DisplayButtonListener implements ActionListener { 
 
        /** 
         * Displays the address book entry for the selected person. 
         * 
         * @param event  the event object. 
         */ 
        public void actionPerformed(ActionEvent event) { 
 
            if ( airSystem.getNumberOfEntries()==0){   
                statusTextArea.setText("The empty");   
            }
            else if (dateList.getSelectedIndex()==-1)   {
                statusTextArea.setText("Please select a date");   
            }
            else if (airSystem.getNumberOfEntries()!=0)   {
                statusTextArea.setText((airSystem.getNames()[dateList.getSelectedIndex()])+" has been displayed.");   
            }
            dateOfFlightTextField.setText((airSystem.getNames()[dateList.getSelectedIndex()]));   
            numberOfRouteTextField.setText((airSystem.getEntry((airSystem.getNames()[dateList.getSelectedIndex()])).getNumberOfRoute());   
            numberOfFreePlaceTextField.setText(airSystem.getEntry((airSystem.getNames()[dateList.getSelectedIndex()])).getNumberOfFreePlace());   
        } 
    } 
    class OrderButtonListener implements ActionListener {
        
        
    
            JFrame orderPanel;
            public void actionPerformed(ActionEvent event)  {
                
                
                orderPanel = new JFrame("Order");
                orderPanel.setResizable(false);
                orderPanel.setVisible(true);
                orderPanel.setSize(350, 200);
                orderPanel.setDefaultCloseOperation(orderPanel.HIDE_ON_CLOSE);
                
                orderPanel.setBackground(Color.BLUE);
                
                surname = new JLabel("Surname:"); 
                name = new JLabel("Name:");
                 date = new JLabel("Date:");
                
                 surnameText = new JTextArea(15,10);
                 nameText = new JTextArea(15,10);
                 dateText = new JTextArea(15,10);
                 surnameText.setBackground(Color.lightGray);
                 nameText.setBackground(Color.lightGray);
                 dateText.setBackground(Color.lightGray);
                 dateText.setText(airSystem.getNames()[dateList.getSelectedIndex()]);       
                  saveButton = new JButton("Save");
                  cancelButton = new JButton("Cancel");
                  
                  JPanel all = new JPanel(new GridLayout(2,1));
                  
                  JPanel text = new JPanel(new GridLayout(5,1));
                  text.add(surnameText);
                  text.add(nameText);
                  text.add(dateText);
                  JPanel datePanel = new JPanel(new GridLayout(1,6));
                  text.add(datePanel);
                  
                  JPanel labels = new JPanel(new GridLayout(5,1));
                  labels.add(surname);
                  labels.add(name);
                  labels.add(date);
                  
                  JPanel up = new JPanel(new GridLayout(1,2));
                  up.add(labels);
                  up.add(text);
                  
                  JPanel down = new JPanel(new FlowLayout());
                  down.add(saveButton);
                  down.add(cancelButton);
                  down.setBackground(Color.BLUE);
                  
                  all.add(up);
                  all.add(down);
                  
                  orderPanel.add(all);
                  
                  cancelButton.addActionListener(new cancelButtonListener());
                  saveButton.addActionListener(new saveButtonListener());
            }
 
class cancelButtonListener implements ActionListener{
    
    public void actionPerformed(ActionEvent event)  {
        orderPanel.setVisible(false);
    }
}
class saveButtonListener implements ActionListener{
 
    /**public int showSaveDialog(Component parent)
    throws HeadlessException);*/
    private String dateOfFlight;
 
    /* Address of the entry */
    private int numberOfRoute;
 
    /* Telephone of the entry */
    private int numberOfFreePlace;
    
    public void actionPerformed(ActionEvent event)  {
    //  write here
    } 
}
    }
}
Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import java.util.ArrayList;
import java.util.Iterator;
 
/**
 * Maintains an address book.
 *
 * @author  author name
 * @version  1.0.0
 * @see AddressBookEntry
 */
public class AirSystem implements Iterable<AirSystemEntry>  {
 
    /* Collection of {@link AddressBookEntry} objects. */
    private ArrayList<AirSystemEntry>  entries;
 
    /**
     * Constructs an empty address book.
     */
    public AirSystem()  {
 
        this.entries = new ArrayList<AirSystemEntry>();
    }
 
    /**
     * Adds the specified entry to this address book.
     *
     * @param entry  the entry to be added.
     */
    public void  addEntry(AirSystemEntry entry)  {
 
        this.entries.add(entry);
    }
 
    /**
     * Removes the specified entry from this address book.
     *
     * @param entry  the entry to be removed.
     */
    //public void  removeEntry(AirSystemEntry entry)  {
 
         //this.entries.remove(entry);
    //}
    public void removeEntry(int numberOfFreePlace) {
        this.entries.remove(numberOfFreePlace);
        
    }
 
    /**
     * Removes all the this.entries from this address book.
     */
    public void  removeAllEntries()  {
 
        this.entries.clear();
    }
 
    /**
     * Returns the first entry with the specified <code>name</code> in this
     * address book.
     *
     * @param name  the name of the entry.
     * @return  The object in the address book with the specified name.
     *          Returns <code>null</code> if the object with the
     *          specified name is not found.
     */
    public AirSystemEntry  getEntry(String dateOfFlight)  {
 
        for (AirSystemEntry entry : this.entries) {
 
            if (entry.getDateOfFlight().equals(dateOfFlight)) {
 
                return entry;
            }
        }
 
        return null;
    }
 
    /**
     * Returns an array with all the names in this address book.
     *
     * @return  an array with all the names in this address book.
     */
    public String[]  getNames()  {
 
        String[] result = new String[getNumberOfEntries()];
        int index = 0;
 
        for (AirSystemEntry entry : this.entries) {
            result[index++] = entry.getDateOfFlight();
        }
 
        return result;
    }
 
    /**
     * Returns an iterator over the this.entries in this address book.
     *
     * return  an {@link Iterator<AddressBookEntry>}
     */
    public Iterator<AirSystemEntry>  iterator() {
 
        return this.entries.iterator();
    }
 
    /**
     * Returns the number of this.entries in this address book.
     *
     * @return  the number of this.entries in this address book.
     */
    public int  getNumberOfEntries()  {
 
        return this.entries.size();
    }
 
    
}
Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/**
 * Stores information for one address book entry. The following information
 * is stored:
 * <ol>
 * <li>the name of a person, a <code>String</code>.</li>
 * <li>the address of a person, a <code>String</code>.</li>
 * <li>the telephone of a person, a <code>String</code>.</li>
 * </ol>
 *
 * @author  author name
 * @version  1.0.0
 */
public class AirSystemEntry {
 
    /* Name of the entry */
    private String dateOfFlight;
 
    /* Address of the entry */
    private int numberOfRoute;
 
    /* Telephone of the entry */
    private int numberOfFreePlace;
 
    /**
     * Constructs an <code>AddressBookEntry</code> object.
     *
     * @param initialName  the name of the person.
     * @param initialAddress   the address of the person.
     * @param initialTelephone   the telephone of the person.
     */
    public AirSystemEntry (String initialDateOfFlight, int initialNumberOfRoute,
            int initialNumberOfFreePlace) {
 
        this.dateOfFlight = initialDateOfFlight;
        this.numberOfRoute = initialNumberOfRoute;
        this.numberOfFreePlace = initialNumberOfFreePlace;
    }
 
    /**
     * Obtains the name of this entry.
     *
     * @return  the name of this entry.
     */
    public String  getDateOfFlight()  {
 
        return  this.dateOfFlight;
    }
 
    /**
     * Obtains the address of this entry.
     *
     * @return  the address of this entry.
     */
    public int  getNumberOfRoute()  {
 
        return  this.numberOfRoute;
    }
 
    /**
     * Obtains the telephone number of this entry.
     *
     * @return  the telephone number of this entry.
     */
    public int  getNumberOfFreePlace()  {
 
        return  this.numberOfFreePlace;
    }
    
    public void setNumberOfFreePlace(int n){
        
        //numberOfFreePlace -= n;
        numberOfFreePlace.setNumberOfFreePlace(n);
        setChanged();
    }
 
    /**
     * Returns the string representation of this entry in the following
     * format:  <i>name</i>_<i>address</i>_<i>telephone</i>
     *
     * @return  the string representation of this entry.
     */
    public String toString()  {
 
        return  getDateOfFlight() + "_" + getNumberOfRoute() + "_" + getNumberOfFreePlace();
    }
}
0
IT_Exp
Эксперт
34794 / 4073 / 2104
Регистрация: 17.06.2006
Сообщений: 32,602
Блог
08.06.2010, 21:05
Ответы с готовыми решениями:

Ejb shedule
Нужно настроить, чтоб задача выполнялась каждое утро Пожскажите, как лучше написать? сайчас вот так, ещё не успел проверить на...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
3
636 / 528 / 165
Регистрация: 01.04.2010
Сообщений: 1,843
09.06.2010, 08:10
Цитата Сообщение от anime Посмотреть сообщение
когда "Save"button нажмите тогда надо уменшать количество свободных мест(Number of free place)
Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class saveButtonListener implements ActionListener{
 
        public saveButtonListener(String dateOfFlight, int numberOfRoute, int numberOfFreePlace) {
                this.dateOfFlight = dateOfFlight;
                this.numberOfRoute = numberOfRoute;
                this.numberOfFreePlace = numberOfFreePlace;
        }
        private String dateOfFlight;
 
        /* Address of the entry */
        private int numberOfRoute;
 
        /* Telephone of the entry */
        private int numberOfFreePlace;
        
        public void actionPerformed(ActionEvent event)  {
          numberOfFreePlace--;
        } 
}
0
0 / 0 / 0
Регистрация: 08.06.2010
Сообщений: 9
10.06.2010, 10:14  [ТС]
спасибо за вашу ответу. но не работает. вы можете посмотреть еще раз.
0
636 / 528 / 165
Регистрация: 01.04.2010
Сообщений: 1,843
10.06.2010, 12:08
Я показал как это можно сделать при нажатии на кнопку, не более того. Как завязывать обработчик с твоими классами, это уж сама думай...
0
Надоела реклама? Зарегистрируйтесь и она исчезнет полностью.
Ответ Создать тему
Новые блоги и статьи
Автозаполнение реквизита при выборе элемента справочника
Maks 27.03.2026
Программный код из решения ниже на примере нетипового документа "ЗаявкаНаРемонтСпецтехники" разработанного в конфигурации КА2. При выборе "Спецтехники" (Тип Справочник. Спецтехника), заполняется. . .
Сумматор с применением элементов трёх состояний.
Hrethgir 26.03.2026
Тут. https:/ / fips. ru/ EGD/ ab3c85c8-836d-4866-871b-c2f0c5d77fbc Первый документ красиво выглядит, но без схемы. Это конечно не даёт никаких плюсов автору, но тем не менее. . . всё может быть. . .
Автозаполнение реквизитов при создании документа
Maks 26.03.2026
Программный код из решения ниже размещается в модуле объекта документа, в процедуре "ПриСозданииНаСервере". Алгоритм проверки заполнения реализован для исключения перезаписи значения реквизита,. . .
Команды формы и диалоговое окно
Maks 26.03.2026
1. Команда формы "ЗаполнитьЗапчасти". Программный код из решения ниже на примере нетипового документа "ЗаявкаНаРемонтСпецтехники" разработанного в конфигурации КА2. В качестве источника данных. . .
Кому нужен AOT?
DevAlt 26.03.2026
Решил сделать простой ланчер Написал заготовку: dotnet new console --aot -o UrlHandler var items = args. Split(":"); var tag = items; var id = items; var executable = args;. . .
Отправка уведомления на почту при изменении наименования справочника
Maks 24.03.2026
Программная отправка письма электронной почты на примере изменения наименования типового справочника "Склады" в конфигурации БП3. Перед реализацией необходимо выполнить настройку системной учетной. . .
модель ЗдравоСохранения 5. Меньше увольнений- больше дохода!
anaschu 24.03.2026
Теперь система здравосохранения уменьшает количество увольнений. 9TO2GP2bpX4 a42b81fb172ffc12ca589c7898261ccb/ https:/ / rutube. ru/ video/ a42b81fb172ffc12ca589c7898261ccb/ Слева синяя линия -. . .
Midnight Chicago Blues
kumehtar 24.03.2026
Такой Midnight Chicago Blues, знаешь?. . Когда вечерние улицы становятся ночными, а ты не можешь уснуть. Ты идёшь в любимый старый бар, и бармен наливает тебе виски. Ты смотришь на пролетающие. . .
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2026, CyberForum.ru