-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppPanel.java
More file actions
104 lines (91 loc) · 3.52 KB
/
AppPanel.java
File metadata and controls
104 lines (91 loc) · 3.52 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
import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.border.Border;
import java.awt.*;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
public class AppPanel extends JPanel {
protected Font textFont = new Font("Arial",Font.PLAIN,20);
protected Font headingTextFont = new Font("Arial",Font.PLAIN,45);
protected Border border = BorderFactory.createLineBorder(Color.LIGHT_GRAY, 1);
protected Border emptyBorder = BorderFactory.createEmptyBorder(20, 20, 20, 20);
protected Color appColour = new Color(126,217,87);
protected Color whiteColour = new Color(255,255,255);
protected String imagePath = System.getProperty("user.dir")+"\\images";
static protected String productInfoPath = System.getProperty("user.dir")+"\\ProductInformations";
public AppPanel(){
}
protected int indexOf(String element, String[] array){
for(int i=0;i<array.length;i++){
if(array[i].equals(element)){
return i;
}
}
return 0;
}
protected void changeConstraintPosition(GridBagConstraints constraint, int column, int row){
constraint.fill = GridBagConstraints.HORIZONTAL;
constraint.gridx = column;
constraint.gridy = row;
}
protected void changeConstraintPadding(GridBagConstraints constraint, int paddingX, int paddingY){
Insets currentInsects = new Insets(paddingY,paddingX,paddingY,paddingX);
constraint.insets = currentInsects;
}
protected void changeConstraintGridSpan(GridBagConstraints constraint, int xSpan, int ySpan){
constraint.gridwidth = xSpan;
constraint.gridheight = ySpan;
}
protected void addToPane(JComponent component,GridBagConstraints constraint,GridBagLayout gridBag, Container pane){
gridBag.setConstraints(component,constraint);
pane.add(component);
}
protected static String getContents(String file, String dropDownBox){
String currentString = "";
FileReader reader;
BufferedReader fileReader;
try {
reader = new FileReader(productInfoPath+"\\"+file);
fileReader = new BufferedReader(reader);
}
catch(IOException e) {
System.out.println("ERROR");
return "";
}
boolean startRecordingData = false;
try {
for (String line = fileReader.readLine(); line!=null;line = fileReader.readLine()){
if(line.equals("NEW DROPDOWN BOX "+dropDownBox)){
startRecordingData = true;
continue;
}
if(startRecordingData){
if(line.contains("NEW DROPDOWN BOX")){
break;
}
currentString+=line+"\n";
}
}
}
catch(IOException e){ }
System.out.println("text: ");
System.out.println(currentString);
return currentString;
}
protected ImageIcon getImage(String name){
try {
return new ImageIcon(ImageIO.read(new File(imagePath+"\\"+name)));
}
catch (IOException ex) {
try {
new ImageIcon(ImageIO.read(new File(imagePath + "\\ImageNotFound.png")));
}
catch (IOException e) {
e.printStackTrace();
}
}
return null;
}
}