-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGui.java
More file actions
61 lines (47 loc) · 1.61 KB
/
Gui.java
File metadata and controls
61 lines (47 loc) · 1.61 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
import javax.swing.*;
//import java.applet.*;
import java.awt.event.*;
public class Gui {
public static void main(String[] args) {
JLabel background;
HuffmanCode h = new HuffmanCode();
JFrame f = new JFrame("Source Coding");
JLabel label = new JLabel("Enter a String");
label.setBounds(115, 70, 150, 30);
final JTextField tf = new JTextField();
tf.setBounds(110, 100, 150, 35);
tf.setBorder(null);
JButton b = new JButton("Run");
b.setBounds(135, 150, 100, 35);
b.setBorder(null);
JLabel lab = new JLabel("OUTPUT");
lab.setBounds(150, 100, 300, 300);
JTextArea i = new JTextArea();
i.setBounds(40, 270, 500, 95);
// Container c= f.getContentPane();
ImageIcon img = new ImageIcon("C:\\Users\\Pranita Gavali\\OneDrive\\Desktop//p7.jpg");
background = new JLabel("", img, JLabel.CENTER);
background.setBounds(-15, -15, 400, 500);
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String val = tf.getText();
String b = h.createHuffmanTree(val);
System.out.println(val);
// h.createHuffmanTree(val);
i.setText(b);
}
});
f.add(tf);
f.add(b);
f.add(i);
f.add(label);
f.add(lab);
f.add(background);
f.setSize(400, 500);
f.setLayout(null);
f.setVisible(true);
f.setVisible(true);
// making the frame visible
// function calling
}
}