1
+ package Textbook_selling_system ;
2
+
3
+ import java .awt .BorderLayout ;
4
+ import java .awt .EventQueue ;
5
+ import java .awt .Font ;
6
+ import java .awt .Toolkit ;
7
+
8
+ import javax .swing .JFrame ;
9
+ import javax .swing .JPanel ;
10
+ import javax .swing .JTextArea ;
11
+ import javax .swing .border .EmptyBorder ;
12
+ import javax .swing .JLabel ;
13
+ import javax .swing .JOptionPane ;
14
+ import javax .swing .JTextField ;
15
+ import javax .swing .JRadioButton ;
16
+ import javax .swing .JComboBox ;
17
+ import javax .swing .JButton ;
18
+ import java .awt .event .ActionListener ;
19
+ import java .awt .event .ActionEvent ;
20
+
21
+ public class Add_new_books extends JFrame {
22
+
23
+ private JPanel contentPane ;
24
+
25
+ /**
26
+ * Launch the application.
27
+ */
28
+ public static void main (String [] args ) {
29
+ EventQueue .invokeLater (new Runnable () {
30
+ public void run () {
31
+ try {
32
+ Add_new_books frame = new Add_new_books ();
33
+ frame .setVisible (true );
34
+ } catch (Exception e ) {
35
+ e .printStackTrace ();
36
+ }
37
+ }
38
+ });
39
+ }
40
+
41
+ /**
42
+ * Create the frame.
43
+ */
44
+ public Add_new_books () {
45
+ setIconImage (Toolkit .getDefaultToolkit ().getImage ("C:\\ Users\\ Soumyadeep\\ Desktop\\ Book Hub\\ 0 (Custom).jpg" ));
46
+
47
+ //setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
48
+ setBounds (450 , 319 , 1014 , 460 );
49
+ setResizable (false );
50
+ contentPane = new JPanel ();
51
+ contentPane .setBorder (new EmptyBorder (5 , 5 , 5 , 5 ));
52
+ setContentPane (contentPane );
53
+ contentPane .setLayout (null );
54
+
55
+ JLabel lblNewLabel = new JLabel ("Book's name :- " );
56
+ lblNewLabel .setFont (new Font ("Segoe UI" , Font .PLAIN , 20 ));
57
+ lblNewLabel .setBounds (59 , 25 , 145 , 32 );
58
+ contentPane .add (lblNewLabel );
59
+
60
+ JLabel label = new JLabel ("Writer's name :- " );
61
+ label .setFont (new Font ("Segoe UI" , Font .PLAIN , 20 ));
62
+ label .setBounds (59 , 101 , 145 , 32 );
63
+ contentPane .add (label );
64
+
65
+ JLabel label_1 = new JLabel ("Condition :- " );
66
+ label_1 .setFont (new Font ("Segoe UI" , Font .PLAIN , 20 ));
67
+ label_1 .setBounds (59 , 184 , 145 , 32 );
68
+ contentPane .add (label_1 );
69
+
70
+ JTextArea bkname = new JTextArea ();
71
+ bkname .setFont (new Font ("Segoe UI" , Font .PLAIN , 20 ));
72
+ bkname .setBounds (235 , 26 , 166 , 37 );
73
+ contentPane .add (bkname );
74
+
75
+ JTextArea wrtrname = new JTextArea ();
76
+ wrtrname .setFont (new Font ("Segoe UI" , Font .PLAIN , 20 ));
77
+ wrtrname .setBounds (235 , 102 , 166 , 37 );
78
+ contentPane .add (wrtrname );
79
+
80
+ JRadioButton rdbtnNewRadioButton = new JRadioButton (" Old" );
81
+ rdbtnNewRadioButton .setFont (new Font ("Segoe UI" , Font .PLAIN , 20 ));
82
+ rdbtnNewRadioButton .setSelected (false );
83
+ rdbtnNewRadioButton .setEnabled (false );
84
+ rdbtnNewRadioButton .setBounds (235 , 172 , 75 , 32 );
85
+ contentPane .add (rdbtnNewRadioButton );
86
+
87
+ JRadioButton rdbtnNewRadioButton_1 = new JRadioButton (" New" );
88
+ rdbtnNewRadioButton_1 .setFont (new Font ("Segoe UI" , Font .PLAIN , 20 ));
89
+ rdbtnNewRadioButton_1 .setSelected (true );
90
+ rdbtnNewRadioButton_1 .setEnabled (false );
91
+ rdbtnNewRadioButton_1 .setBounds (235 , 213 , 81 , 26 );
92
+ contentPane .add (rdbtnNewRadioButton_1 );
93
+
94
+ JLabel label_2 = new JLabel (" Published Date :- " );
95
+ label_2 .setFont (new Font ("Segoe UI" , Font .PLAIN , 20 ));
96
+ label_2 .setBounds (481 , 25 , 158 , 32 );
97
+ contentPane .add (label_2 );
98
+
99
+ JComboBox date = new JComboBox ();
100
+ for (int i =1 ;i <=31 ;i ++)
101
+ {
102
+ String str =String .valueOf (i );
103
+ date .addItem (str );
104
+ }
105
+ date .setBounds (662 , 32 , 48 , 27 );
106
+ contentPane .add (date );
107
+
108
+ JComboBox month = new JComboBox ();
109
+ month .setBounds (739 , 32 , 75 , 27 );
110
+ month .addItem ("Jan" );
111
+ month .addItem ("Feb" );
112
+ month .addItem ("Mar" );
113
+ month .addItem ("Apr" );
114
+ month .addItem ("May" );
115
+ month .addItem ("Jun" );
116
+ month .addItem ("Jul" );
117
+ month .addItem ("Aug" );
118
+ month .addItem ("Sep" );
119
+ month .addItem ("Oct" );
120
+ month .addItem ("Nov" );
121
+ month .addItem ("Dec" );
122
+ contentPane .add (month );
123
+
124
+ JComboBox year = new JComboBox ();
125
+ for (int i =1901 ;i <=2018 ;i ++)
126
+ {
127
+ String str =String .valueOf (i );
128
+ year .addItem (str );
129
+ }
130
+ year .setBounds (841 , 32 , 109 , 27 );
131
+ contentPane .add (year );
132
+
133
+ JLabel label_3 = new JLabel (" Subject's name :- " );
134
+ label_3 .setFont (new Font ("Segoe UI" , Font .PLAIN , 20 ));
135
+ label_3 .setBounds (481 , 184 , 158 , 32 );
136
+ contentPane .add (label_3 );
137
+
138
+ JComboBox <String > sub = new JComboBox <String >();
139
+ sub .setBounds (662 , 188 , 166 , 32 );
140
+ sub .addItem ("English" );
141
+ sub .addItem ("Hindi" );
142
+ sub .addItem ("Bengali" );
143
+ sub .addItem ("Maths" );
144
+ sub .addItem ("Physics" );
145
+ sub .addItem ("Chemistry" );
146
+ sub .addItem ("Biology" );
147
+ sub .addItem ("Computer" );
148
+ sub .addItem ("History" );
149
+ sub .addItem ("Geography" );
150
+ sub .addItem ("Others" );
151
+ contentPane .add (sub );
152
+
153
+ JLabel label_4 = new JLabel (" Price (INR) :- " );
154
+ label_4 .setFont (new Font ("Segoe UI" , Font .PLAIN , 20 ));
155
+ label_4 .setBounds (481 , 261 , 145 , 32 );
156
+ contentPane .add (label_4 );
157
+
158
+ JTextArea publs = new JTextArea ();
159
+ publs .setFont (new Font ("Segoe UI" , Font .PLAIN , 20 ));
160
+ publs .setBounds (662 , 102 , 166 , 37 );
161
+ contentPane .add (publs );
162
+
163
+ JLabel label_5 = new JLabel (" Publisher name :- " );
164
+ label_5 .setFont (new Font ("Segoe UI" , Font .PLAIN , 20 ));
165
+ label_5 .setBounds (481 , 101 , 169 , 32 );
166
+ contentPane .add (label_5 );
167
+
168
+ JTextArea price = new JTextArea ();
169
+ price .setFont (new Font ("Segoe UI" , Font .PLAIN , 20 ));
170
+ price .setBounds (662 , 262 , 166 , 37 );
171
+ contentPane .add (price );
172
+
173
+ JLabel label_6 = new JLabel ("Source :- " );
174
+ label_6 .setFont (new Font ("Segoe UI" , Font .PLAIN , 20 ));
175
+ label_6 .setBounds (59 , 261 , 145 , 32 );
176
+ contentPane .add (label_6 );
177
+
178
+ JTextArea src = new JTextArea ();
179
+ src .setFont (new Font ("Segoe UI" , Font .PLAIN , 20 ));
180
+ src .setBounds (235 , 262 , 166 , 37 );
181
+ contentPane .add (src );
182
+
183
+ JButton btnNewButton = new JButton ("Add" );
184
+ btnNewButton .addActionListener (new ActionListener () {
185
+ public void actionPerformed (ActionEvent e ) {
186
+ int a =JOptionPane .showConfirmDialog (btnNewButton ,"Are you sure?" );
187
+ //JOptionPane.setRootFrame(null);
188
+ if (a ==JOptionPane .YES_OPTION ){
189
+
190
+ String name =bkname .getText ();
191
+ String writer = wrtrname .getText ();
192
+ String condition ="New" ;
193
+ String source =src .getText ();
194
+ String publisher =publs .getText ();
195
+ String subject = (String ) sub .getSelectedItem ();
196
+ String prc =price .getText ();
197
+ String dt =(String ) date .getSelectedItem ();
198
+ String mnth =(String ) month .getSelectedItem ();
199
+ String yr =(String ) year .getSelectedItem ();
200
+
201
+ if (name != "" && writer != "" && source != null && prc != null && publisher != null )
202
+ {
203
+ String n ="\n " ;
204
+
205
+
206
+ JOptionPane .showMessageDialog (btnNewButton ,"Congratulations," +n +"Book is added sucessfully" +n +"Thankyou." );
207
+ }
208
+ else
209
+ {
210
+
211
+ JOptionPane .showMessageDialog (btnNewButton ,"Please,enter the informations" );
212
+ }
213
+ }
214
+
215
+ }
216
+ });
217
+ btnNewButton .setFont (new Font ("Segoe UI" , Font .PLAIN , 30 ));
218
+ btnNewButton .setBounds (376 , 318 , 197 , 80 );
219
+ contentPane .add (btnNewButton );
220
+ }
221
+ }
0 commit comments