-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
189 lines (150 loc) · 6.38 KB
/
Main.java
File metadata and controls
189 lines (150 loc) · 6.38 KB
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
import com.toedter.calendar.JDateChooser;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.*;
public class Main extends JFrame implements ActionListener {
//All Global Components
JLabel heading,subheading,licensor,licensee,Email1,Email2,software,date;
JTextField licenseename,licensorname,email1name,email2name,softwarename;
JPanel subpanel;
JDateChooser dateChooser;
JButton next;
public Main(){
setName("License Generator");
setSize(1000,700);
setResizable(false);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocationRelativeTo(null);
setLayout(null);
Container contentPane = getContentPane();
contentPane.setBackground(Color.decode("#E7EDF9"));
//All Components in Frame
heading=new JLabel("License Generator");
heading.setBounds(280,10,2000,100);
heading.setFont(new Font(Font.MONOSPACED,Font.BOLD,50));
heading.setForeground(Color.decode("#0068C8"));
add(heading);
subheading=new JLabel("License Information");
subheading.setBounds(60,100,500,100);
subheading.setFont(new Font(Font.SERIF,Font.BOLD,30));
subheading.setForeground(Color.decode("#0068C8"));
add(subheading);
subpanel=new JPanel();
subpanel.setBounds(60,180,880,420);
subpanel.setBorder(new EmptyBorder(10,10,10,10));
subpanel.setBackground(Color.decode("#ffffff"));
subpanel.setLayout(null);
add(subpanel);
licensor=new JLabel("Licensor");
licensor.setBounds(60,40,200,80);
licensor.setFont(new Font(Font.SERIF,Font.BOLD,20));
licensor.setForeground(Color.decode("#0068C8"));
subpanel.add(licensor);
Email1=new JLabel("Email");
Email1.setBounds(500,40,200,80);
Email1.setFont(new Font(Font.SERIF,Font.BOLD,20));
Email1.setForeground(Color.decode("#0068C8"));
subpanel.add(Email1);
licensorname=new JTextField("Owner/Developer name");
licensorname.setBounds(60,100,300,40);
subpanel.add(licensorname);
email1name=new JTextField("Owner/Developer Email");
email1name.setBounds(500,100,300,40);
subpanel.add(email1name);
licensee=new JLabel("Licensee");
licensee.setBounds(60,140,200,80);
licensee.setFont(new Font(Font.SERIF,Font.BOLD,20));
licensee.setForeground(Color.decode("#0068C8"));
subpanel.add(licensee);
Email2=new JLabel("Email");
Email2.setBounds(500,140,200,80);
Email2.setFont(new Font(Font.SERIF,Font.BOLD,20));
Email2.setForeground(Color.decode("#0068C8"));
subpanel.add(Email2);
licenseename=new JTextField("Individual/Entity getting rights");
licenseename.setBounds(60,200,300,40);
subpanel.add(licenseename);
email2name=new JTextField("Individual/Entity Enail");
email2name.setBounds(500,200,300,40);
subpanel.add(email2name);
software=new JLabel("Software");
software.setBounds(60,240,200,80);
software.setFont(new Font(Font.SERIF,Font.BOLD,20));
software.setForeground(Color.decode("#0068C8"));
subpanel.add(software);
date=new JLabel("Date");
date.setBounds(500,240,200,80);
date.setFont(new Font(Font.SERIF,Font.BOLD,20));
date.setForeground(Color.decode("#0068C8"));
subpanel.add(date);
softwarename=new JTextField("Software Name");
softwarename.setBounds(60,300,300,40);
subpanel.add(softwarename);
dateChooser = new JDateChooser();
dateChooser.setBounds(500, 300, 300, 40);
subpanel.add(dateChooser);
next=new JButton("Next");
next.setBounds(800,610,90,40);
next.setFont(new Font(Font.MONOSPACED,Font.BOLD,15));
next.setBackground(Color.decode("#0068C8"));
next.setForeground(Color.white);
next.addActionListener(this);
add(next);
setVisible(true);
}
public static void main(String[] args){
new Main();
}
@Override
public void actionPerformed(ActionEvent actionEvent) {
if (actionEvent.getSource()==next){
String inputFile = "LicenseInput.txt";
String outputFile = "License.txt";
String licensee=licenseename.getText();
String licensor=licensorname.getText();
String soft=softwarename.getText();
String dateoflicense= ((JTextField)dateChooser.getDateEditor().getUiComponent()).getText();
String searchlicensee="[Licensee]";
String searchLicensor="[Licensor]";
String searchSoft="[Software]";
String searchdate="[Date]";
//Adding user input in Template File/Replacing Template Values
try (BufferedReader reader = new BufferedReader(new FileReader(inputFile));
BufferedWriter writer = new BufferedWriter(new FileWriter(outputFile))) {
String line;
while ((line = reader.readLine()) != null) {
// Check if the line contains the specific text to replace
if (line.contains(searchlicensee)) {
// Replace the specific text with the new text
line = line.replace(searchlicensee, licensee);
}
if (line.contains(searchLicensor)){
line=line.replace(searchLicensor,licensor);
}
if (line.contains(searchSoft)){
line=line.replace(searchSoft,soft);
}
if (line.contains(searchdate)){
line=line.replace(searchdate,dateoflicense);
}
// Write the modified or unmodified line to the output file
writer.write(line);
writer.newLine();
}
System.out.println("File modification completed successfully.");
}
catch (IOException e) {
e.printStackTrace();
}
catch(Exception e){
e.printStackTrace();
}
//Changing Frame
setVisible(false);
new Conversion().setVisible(true);
}
}
}