- 001
- 002
- 003
- 004
- 005
- 006
- 007
- 008
- 009
- 010
- 011
- 012
- 013
- 014
- 015
- 016
- 017
- 018
- 019
- 020
- 021
- 022
- 023
- 024
- 025
- 026
- 027
- 028
- 029
- 030
- 031
- 032
- 033
- 034
- 035
- 036
- 037
- 038
- 039
- 040
- 041
- 042
- 043
- 044
- 045
- 046
- 047
- 048
- 049
- 050
- 051
- 052
- 053
- 054
- 055
- 056
- 057
- 058
- 059
- 060
- 061
- 062
- 063
- 064
- 065
- 066
- 067
- 068
- 069
- 070
- 071
- 072
- 073
- 074
- 075
- 076
- 077
- 078
- 079
- 080
- 081
- 082
- 083
- 084
- 085
- 086
- 087
- 088
- 089
- 090
- 091
- 092
- 093
- 094
- 095
- 096
- 097
- 098
- 099
- 100
private class MyException extends Exception
{
public MyException()
{
super("Вы не ввели название автомобиля для поиска");
}
}
private class MyExceptionNull extends Exception
{
public MyExceptionNull()
{
super("Вы ввели неверно: Используйте A-z и 1-9");
}
}
private void checkName(JTextField bName) throws MyException,MyExceptionNull
{
String sName = bName.getText();
if(sName.endsWith("э")||sName.endsWith("й")||sName.endsWith("щ")||sName.endsWith("п")||sName.endsWith("ч")||sName.endsWith("|")||sName.endsWith("+")||sName.endsWith("(")||sName.endsWith("/")||
sName.endsWith("а")||sName.endsWith("ц")||sName.endsWith("з")||sName.endsWith("р")||sName.endsWith("с")||sName.endsWith("~")||sName.endsWith("]")||sName.endsWith(")")||sName.endsWith("?")||
sName.endsWith("б")||sName.endsWith("у")||sName.endsWith("х")||sName.endsWith("о")||sName.endsWith("м")||sName.endsWith("ё")||sName.endsWith("[")||sName.endsWith("=")||sName.endsWith("%")||
sName.endsWith("в")||sName.endsWith("к")||sName.endsWith("ъ")||sName.endsWith("л")||sName.endsWith("и")||sName.endsWith(".")||sName.endsWith("}")||sName.endsWith("@")||sName.endsWith("^")||
sName.endsWith("г")||sName.endsWith("н")||sName.endsWith("ф")||sName.endsWith("ж")||sName.endsWith("т")||sName.endsWith("ю")||sName.endsWith("{")||sName.endsWith("#")||sName.endsWith("&")||
sName.endsWith("д")||sName.endsWith("ш")||sName.endsWith("ы")||sName.endsWith("я")||sName.endsWith("ь")||sName.endsWith("б")||sName.endsWith("-")||sName.endsWith("$")||sName.endsWith("*")||
sName.endsWith("е")||sName.endsWith("!")||sName.endsWith("<")||sName.endsWith(">")) throw new MyExceptionNull();
if(sName.contains(" ")) throw new MyException();
if(sName.length()==0) throw new MyException();
}
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
auto_list window = new auto_list();
//instance = window;
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
public auto_list() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize(){
instance = this;
frame = new JFrame("Список Автомобилей режим admin");
frame.setForeground(Color.GRAY);
frame.setResizable(false);
frame.setSize(816,308);
frame.setLocation(100, 100);
//frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Панель инструментов
JToolBar toolBar = new JToolBar();
frame.getContentPane().add(toolBar, BorderLayout.NORTH);
//Кнопка сохранить
save = new JButton("");
save.setIcon(new ImageIcon("C:\\Users\\Anton\\workspace\\Tech_prog\\image\\filesaveas_6703.png"));
toolBar.add(save);
save.setToolTipText("Сохранить список");
//Кнопка открыть
open = new JButton("");
open.setIcon(new ImageIcon("C:\\Users\\Anton\\workspace\\Tech_prog\\image\\1_folder_open_7120.png"));
toolBar.add(open);
open.setToolTipText("Открыть файл");
//Кнопка добавить
add = new JButton("");
add.setIcon(new ImageIcon("C:\\Users\\Anton\\workspace\\Tech_prog\\image\\list-add_9083.png"));
toolBar.add(add);
add.setToolTipText("Добавить в список");
//Кнопка редактировать
edit = new JButton("");
edit.setIcon(new ImageIcon("C:\\Users\\Anton\\workspace\\Tech_prog\\image\\edit_7777.png"));
toolBar.add(edit);
edit.setToolTipText("Редактировать");
//Кнопка убрать
minus = new JButton("");
minus.setIcon(new ImageIcon("C:\\Users\\Anton\\workspace\\Tech_prog\\image\\list-minus_9083.png"));
toolBar.add(minus);
minus.setToolTipText("Удалить из списка");
String[] columnsSearch = {"Владелец","Автомобиль","Год выпуска","Пробег","Неисправность","Работник станции","Время "};
String[][] dataSearch = {{"Щербаков А.В.","Audi A6","1995","260 000 км","Двигатель","Иванов А.С.","08.12.2016"},{"Устрицов В.В.","BMW x6","2008","107 000 км","Карбюратор","Синицин Г.В.","08.12.2016"},{"Безруков С.А.","Mercedes C63 AMG","2009","115 000 км","Фары передние","Иванов А.С.","08.12.2016"},{"Никифоров Г.А","Lada","1995","200 000 км","Бампер","Синицин Г.В.","08.12.2016"},{"Лобанов Е.В.","Mazda","1992","250 000 км","Лобовое стекло","Иванов А.С.","08.12.2016"}};
String[] columns ={"Владелец","Автомобиль","Год выпуска","Пробег","Неисправность","Работник станции","Время "};
String [][] data={{"Щербаков А.В.","Audi A6","1995","260 000 км","Двигатель","Иванов А.С.","08.12.2016"},{"Устрицов В.В.","BMW x6","2008","107 000 км","Карбюратор","Синицин Г.В.","08.12.2016"},{"Безруков С.А.","Mercedes C63 AMG","2009","115 000 км","Фары передние","Иванов А.С.","08.12.2016"},{"Никифоров Г.А","Lada","1995","200 000 км","Бампер","Синицин Г.В.","08.12.2016"},{"Лобанов Е.В.","Mazda","1992","250 000 км","Лобовое стекло","Иванов А.С.","08.12.2016"}};
model = new DefaultTableModel(data,columns);
modelSearch = new DefaultTableModel(dataSearch,columnsSearch);
autoSearch=new JTable(modelSearch);
auto=new JTable(model);
auto.setEnabled(false);
scrollSearch=new JScrollPane(autoSearch);
Работа одного из студентов, 3 курс. В строке 18 - условие которое защищает от некорректного ввода русских литер. Остальные приколы смотрите сами.