You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Luis Reis <Lu...@netcabo.pt> on 2002/06/09 01:03:32 UTC

Chainsaw control-panel

Hi,

I was getting a bit annoyed by the pause/resume button changing of size,
so I wrote a little patch to make the buttons size fixed. I've also
changed their layout to appear horizontally on the right side of the
first row instead of being the third column of the whole panel. This
also fixes the annoyance of the filter input lines not being evenly
spaced.

I think the exit button is in surplus, because there's already a exit
option in the file menu and most possibly in the window decoration, so,
maybe a "Hide control-panel" button should be more useful in it's place.

Hope you won't get annoyed by this,
Thanks you,
Luis Reis

Proposed patch:


diff -u -r1.3 ControlPanel.java
--- src/java/org/apache/log4j/chainsaw/ControlPanel.java	27 Mar 2002
09:25:24 -0000	1.3
+++ src/java/org/apache/log4j/chainsaw/ControlPanel.java	8 Jun 2002
22:45:35 -0000
@@ -8,6 +8,9 @@
 
 import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;
+import java.awt.FlowLayout;
+import java.awt.Dimension;
+import java.awt.Insets;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import javax.swing.BorderFactory;
@@ -40,6 +43,7 @@
         setBorder(BorderFactory.createTitledBorder("Controls: "));
         final GridBagLayout gridbag = new GridBagLayout();
         final GridBagConstraints c = new GridBagConstraints();
+	final Dimension d = new Dimension(80,24);
         setLayout(gridbag);
 
         // Pad everything
@@ -99,6 +103,7 @@
 
 
         c.fill = GridBagConstraints.HORIZONTAL;
+	c.gridwidth = 2;
         c.gridy++;
         final JTextField threadField = new JTextField("");
         threadField.getDocument().addDocumentListener(new
DocumentListener () {@@ -166,30 +171,19 @@
         add(msgField);
 
         // Add the 3rd column of buttons
-        c.weightx = 0;
-        c.fill = GridBagConstraints.HORIZONTAL;
-        c.anchor = GridBagConstraints.EAST;
         c.gridx = 2;
-
         c.gridy = 0;
-        final JButton exitButton = new JButton("Exit");
-        exitButton.setMnemonic('x');
-        exitButton.addActionListener(ExitAction.INSTANCE);
-        gridbag.setConstraints(exitButton, c);
-        add(exitButton);
-
-        c.gridy++;
-        final JButton clearButton = new JButton("Clear");
-        clearButton.setMnemonic('c');
-        clearButton.addActionListener(new ActionListener() {
-                public void actionPerformed(ActionEvent aEvent) {
-                    aModel.clear();
-                }
-            });
-        gridbag.setConstraints(clearButton, c);
-        add(clearButton);
+        c.gridwidth = 1;
+        c.weightx = 0;
+        c.weighty = 0;
+        c.fill = GridBagConstraints.NONE;
+        c.anchor = GridBagConstraints.EAST;
+	final JPanel buttonPanel = new JPanel();
+        gridbag.setConstraints(buttonPanel, c);
+        add(buttonPanel);
+        buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT,1,1));
 
-        c.gridy++;
+	final Insets insets = new Insets(2,2,2,2);
         final JButton toggleButton = new JButton("Pause");
         toggleButton.setMnemonic('p');
         toggleButton.addActionListener(new ActionListener() {
@@ -199,7 +193,30 @@
                         aModel.isPaused() ? "Resume" : "Pause");
                 }
             });
-        gridbag.setConstraints(toggleButton, c);
-        add(toggleButton);
+	toggleButton.setMargin(insets);
+	toggleButton.setPreferredSize(d);
+	toggleButton.setMinimumSize(d);
+        buttonPanel.add(toggleButton);
+	
+        final JButton clearButton = new JButton("Clear");
+        clearButton.setMnemonic('c');
+        clearButton.addActionListener(new ActionListener() {
+                public void actionPerformed(ActionEvent aEvent) {
+                    aModel.clear();
+                }
+            });
+	clearButton.setMargin(insets);
+	clearButton.setPreferredSize(d);
+	clearButton.setMinimumSize(d);
+        buttonPanel.add(clearButton);
+
+        final JButton exitButton = new JButton("Exit");
+        exitButton.setMnemonic('x');
+        exitButton.addActionListener(ExitAction.INSTANCE);
+	exitButton.setMargin(insets);
+	exitButton.setPreferredSize(d);
+	exitButton.setMinimumSize(d);
+        buttonPanel.add(exitButton);
+
     }
 }



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>