-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFrame.java
More file actions
117 lines (82 loc) · 2.84 KB
/
Frame.java
File metadata and controls
117 lines (82 loc) · 2.84 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
package cg;
/**
* Created by kreisso on 09.07.2018.
*/
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.text.NumberFormat;
import javax.swing.*;
public class Frame extends JFrame
implements Operations{
/**
*
*/
private static final long serialVersionUID = 1L;
private JLabel sourceLebel;
private JLabel destinyLabel;
private JLabel howManyLabel;
private JButton doneButton;
private Chooser chooserSource;
private Chooser chooserDestiny;
private JFormattedTextField howManyTextField;
private NumberFormat amountFormat;
public Frame() {
super("Copying guy by Maciej Polak");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new GridBagLayout());
GridBagConstraints grid = new GridBagConstraints();
grid.fill = GridBagConstraints.HORIZONTAL;
grid.insets = new Insets(5, 10, 5, 5);
grid.gridx = 0;
grid.gridy = 0;
sourceLebel = new JLabel("Source path: ");
this.add(sourceLebel, grid);
grid.gridx = 1;
chooserSource = new Chooser(0);
this.add(chooserSource, grid);
grid.gridx = 0;
grid.gridy = 1;
destinyLabel = new JLabel("Destiny path: ");
this.add(destinyLabel, grid);
grid.gridx = 1;
chooserDestiny = new Chooser(1);
this.add(chooserDestiny, grid);
grid.gridx = 0;
grid.gridy = 2;
howManyLabel = new JLabel("How many copies: ");
this.add(howManyLabel, grid);
grid.gridx = 1;
howManyTextField = new JFormattedTextField(amountFormat);
howManyTextField.setColumns(5);
this.add(howManyTextField, grid);
grid.gridx = 2;
doneButton = new JButton("Ok");
doneButton.addActionListener( new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
Object source = e.getSource();
if(source == doneButton)
{
try {
makeCopies(chooserSource.textField.getText(), chooserDestiny.textField.getText(), Integer.parseInt((String) howManyTextField.getValue()));
System.out.println("cos");
} catch (IOException e1) {
System.out.println("cos2");
e1.printStackTrace();
}
}
}
});
this.add(doneButton, grid);
Dimension size = Toolkit.getDefaultToolkit().getScreenSize();
this.setVisible(true);
this.setBounds((size.width/2)-400, (size.height/2)-300, 800, 600);
this.setDefaultCloseOperation(3);
this.setResizable(false);
pack();
}
}