55import java .awt .event .ActionListener ;
66
77public class MainPanel {
8- private static class PanelContainer {
9- final JPanel totalGUI ;
10- final JPanel mainPanel ;
11-
12- PanelContainer () {
13- totalGUI = new JPanel ();
14- totalGUI .setLayout (new BorderLayout ());
15- mainPanel = new JPanel ();
16- mainPanel .setLayout (null );
17- totalGUI .add (mainPanel , BorderLayout .CENTER );
18- totalGUI .setOpaque (true );
19- }
20- }
21-
228 private static PanelContainer createBasePanel () {
239 return new PanelContainer ();
2410 }
@@ -31,11 +17,11 @@ private static void createTitlePanel(JPanel mainPanel) {
3117 mainPanel .add (Main .titlePanel );
3218
3319 // Create and add labels
34- Main .redLabel = createLabel ("Selected File Size: " , 43 , 0 , 150 , 30 );
35- Main .blueLabel = createLabel ("After zip/unzip the file size: " , 10 , 30 , 170 , 30 );
36-
37- Main .titlePanel .add (Main .redLabel );
38- Main .titlePanel .add (Main .blueLabel );
20+ Main .originalSizeLabel = createLabel ("Selected File Size: " , 43 , 0 , 150 , 30 );
21+ Main .compressedSizeLabel = createLabel ("After zip/unzip the file size: " , 10 , 30 , 170 , 30 );
22+
23+ Main .titlePanel .add (Main .originalSizeLabel );
24+ Main .titlePanel .add (Main .compressedSizeLabel );
3925 }
4026
4127 private static void createScorePanel (JPanel mainPanel ) {
@@ -46,11 +32,11 @@ private static void createScorePanel(JPanel mainPanel) {
4632 mainPanel .add (Main .scorePanel );
4733
4834 // Create and add score labels
49- Main .redScore = createLabel ("" , 0 , 0 , 100 , 30 );
50- Main .blueScore = createLabel ("" , 0 , 30 , 100 , 30 );
51-
52- Main .scorePanel .add (Main .redScore );
53- Main .scorePanel .add (Main .blueScore );
35+ Main .originalSizeValue = createLabel ("" , 0 , 0 , 100 , 30 );
36+ Main .compressedSizeValue = createLabel ("" , 0 , 30 , 100 , 30 );
37+
38+ Main .scorePanel .add (Main .originalSizeValue );
39+ Main .scorePanel .add (Main .compressedSizeValue );
5440 }
5541
5642 private static JLabel createLabel (String text , int x , int y , int width , int height ) {
@@ -77,18 +63,18 @@ private static void createButtonPanel(JPanel mainPanel, ActionListener listener)
7763 mainPanel .add (Main .buttonPanel );
7864
7965 // Create compression buttons
80- Main .ZH = createButton ("ZIP HuffZ" , 0 , 0 , 120 , 30 , listener );
81- Main .UH = createButton ("UNZIP HuffZ" , 130 , 0 , 120 , 30 , listener );
82- Main .ZL = createButton ("ZIP LmZWp" , 260 , 0 , 120 , 30 , listener );
83- Main .UL = createButton ("UNZIP LmZWp" , 390 , 0 , 120 , 30 , listener );
84- Main .EX = createButton ("EXIT" , 130 , 70 , 250 , 30 , listener );
66+ Main .huffmanCompressButton = createButton ("ZIP HuffZ" , 0 , 0 , 120 , 30 , listener );
67+ Main .huffmanDecompressButton = createButton ("UNZIP HuffZ" , 130 , 0 , 120 , 30 , listener );
68+ Main .lzwCompressButton = createButton ("ZIP LmZWp" , 260 , 0 , 120 , 30 , listener );
69+ Main .lzwDecompressButton = createButton ("UNZIP LmZWp" , 390 , 0 , 120 , 30 , listener );
70+ Main .exitButton = createButton ("EXIT" , 130 , 70 , 250 , 30 , listener );
8571
8672 // Add buttons to panel
87- Main .buttonPanel .add (Main .ZH );
88- Main .buttonPanel .add (Main .UH );
89- Main .buttonPanel .add (Main .ZL );
90- Main .buttonPanel .add (Main .UL );
91- Main .buttonPanel .add (Main .EX );
73+ Main .buttonPanel .add (Main .huffmanCompressButton );
74+ Main .buttonPanel .add (Main .huffmanDecompressButton );
75+ Main .buttonPanel .add (Main .lzwCompressButton );
76+ Main .buttonPanel .add (Main .lzwDecompressButton );
77+ Main .buttonPanel .add (Main .exitButton );
9278 }
9379
9480 public static JPanel createContentPane (ActionListener listener ) {
0 commit comments