-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGuiRefresh.java
More file actions
70 lines (66 loc) · 1.96 KB
/
GuiRefresh.java
File metadata and controls
70 lines (66 loc) · 1.96 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
/* Alec Snyder
* cs162
* Gui Program to get a new refresh token
*/
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.io.IOException;
public class GuiRefresh implements ActionListener
{
public JFrame frame;
private JButton confirm, cancel;
private JTextField field;
public GuiRefresh()
{
frame=new JFrame("Generate Refresh Token");
frame.setLayout(new GridLayout(5,1));
JLabel urlInstr=new JLabel("Please navigate to the following URL in a web browser:");
JTextArea url=new JTextArea();
url.setEditable(false);
url.setText(DriveRefreshGen.getURL());
JLabel codeInstr=new JLabel("Please copy the code that you see into the box below then press enter");
field=new JTextField(100);
confirm=new JButton("confirm");
cancel=new JButton("cancel");
cancel.addActionListener(this);
confirm.addActionListener(this);
frame.getRootPane().setDefaultButton(confirm);
JPanel bPanel=new JPanel();
bPanel.setLayout(new GridLayout(1,2));
bPanel.add(confirm);
bPanel.add(cancel);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(urlInstr);
frame.add(url);
frame.add(codeInstr);
frame.add(field);
frame.add(bPanel);
frame.pack();
frame.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==(Object)(cancel))
{
System.exit(0);
}
else if(e.getSource()==(Object)(confirm))
{
try
{
DriveRefreshGen.genRefresh(field.getText());
frame.dispose();
}
catch(IOException ex)
{
field.setText("");
new InvalidCodeGui();
}
}
}
public static void main(String[] args)
{
new GuiRefresh();
}
}