Updated a bunch of stuff

This commit is contained in:
Drudoo 2016-09-26 11:48:51 +02:00
parent 0e528babd2
commit 09c643e294

View File

@ -44,6 +44,190 @@ import java.net.*;
import java.net.URI; import java.net.URI;
import java.net.URL; import java.net.URL;
public class Caller extends JPanel implements ItemListener,ActionListener, MouseListener,ClipboardOwner { public class Caller extends JPanel {
//Generally 'a' is airline windows and 'p' is phone book window
//Checkboxes to keep windows on top of all other windows
private static JCheckBox windowToFront;
private static JCheckBox a_windowToFront;
private static JCheckBox p_windowToFront;
//Text fields for phone number to call and for searching a manifest number
private JTextField callNumber;
private JTextField maniNumber;
//Booleans to check if window is on top or not.
private static boolean isOnTop;
private static boolean a_isOnTop;
private static boolean p_isOnTop;
//JFrame for our main window.
private static JFrame frame;
//String for filename to use with the log.
private static String fileName;
//Static integers to keep stats over all instances of the app
private static int stats_calls_made = 0;
private static int stats_calls_answered = 0;
private static int stats_calls_transfered_s = 0;
private static int stats_calls_transfered_a = 0;
//Frames for the two 'books'
private static JFrame phoneBookFrame;
private static JFrame airlineBookFrame;
//Cehck if each 'book' is open or not
private static boolean airlineOpen = false;
private static boolean phoneOpen = false;
//Speficy what role / phone number to use
private static int role;
//Last two digits of phonenumber
private static int phoneNumber;
//Full phonenumber
private static String fullPhoneNumber;
//IP address of phone.
private static String IPaddr;
//Specify layout mode
private GridLayout grid;
//Check if 'books' are visible
private static boolean phoneBookIsVisible = false;
private static boolean airlineBookIsVisible = false;
//Set text color.
private Color ASColor = Color.decode("#3399FF");
//Specify newline character
private final static String newline = "\n";
private static List<String> configList = new ArrayList<String>();
//Create constructor
public Caller(Container panel) {
//Load external configs from Config.txt
loadConfig();
//Define how the grid should be
grid = new GridLayout(0,1);
//Create checkbox and make it clickable.
windowToFront = new JCheckBox("Always on top");
windowToFront.addItemListener(this);
windowToFront.setSelected(false);
windowToFront.setOpaque(true);
windowToFront.setBackground(Color.BLACK);
//Create title and subtitle and set the window color.
JLabel title = new JLabel(configList.get(0));
title.setForeground(ASColor);
JLabel subTitle = new JLabel(configList.get(1));
subTitle.setForeground(ASColor);
windowToFront.setForeground(ASColor);
//Create buttons and set the labels of the
JButton call = new JButton(configList.get(2));
JButton answer = new JButton(configList.get(3));
JButton answerOther = new JButton(configList.get(4));
JButton transferToA1 = new JButton(configList.get(5));
JButton transferToA2 = new JButton(configList.get(6));
JButton redial = new JButton(configList.get(7));
//Set colors of each button
redial.setBackground(Color.BLACK);
call.setBackground(Color.BLACK);
answer.setBackground(Color.BLACK);
answerOther.setBackground(Color.BLACK);
transferToA1.setBackground(Color.BLACK);
transferToA2.setBackground(Color.BLACK);
//Setup phone number, IP and transfer labels
JLabel phoneN = new JLabel(configList.get(8)+phoneNumber);
phoneN.setForeground(ASColor);
JLabel ipLabel = new JLabel(configList.get(9)+IPaddr);
ipLabel.setForeground(ASColor);
JLabel transferCall = new JLabel(configList.get(10));
transferCall.setForeground(ASColor);
JLabel callOut = new JLabel(configList.get(11));
callOut.setForeground(ASColor);
//Setup phone number input field
callNumber = new JTextField();
//Add listeder to the input field, so we can right click
callNumber.addMouseListener(this);
//Hangup button
JButton hangUp = new JButton(configList.get(12));
hangUp.setBackground(Color.BLACK);
}
public static void main(String[] args) {
}
private static void loadConfig() {
String fileName = "Config.txt";
File f = new File(fileName);
if(f.exists() && !f.isDirectory()) {
BufferedReader reader = null;
BufferedReader tempReader = null;
try {
reader = new BufferedReader(new FileReader(f));
tempReader = reader;
String text = null;
String tempText = null;
while ((text = reader.readLine()) != null) {
configList.add(text);
}
for (int i = 0; i<2; i++) {
System.out.println(configList.get(i));
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (reader != null) {
reader.close();
}
} catch (IOException e) {
}
}
} else {
System.out.println("File Does not Exists");
}
}
} }