khammond 01/09/27 06:16:34
Modified: src/org/apache/jmeter/gui LoopControlPanel.java
Log:
Clean up GUI.
Revision Changes Path
1.5 +80 -41 jakarta-jmeter/src/org/apache/jmeter/gui/LoopControlPanel.java
Index: LoopControlPanel.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src/org/apache/jmeter/gui/LoopControlPanel.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- LoopControlPanel.java 2001/08/31 00:46:43 1.4
+++ LoopControlPanel.java 2001/09/27 13:16:34 1.5
@@ -55,30 +55,30 @@
package org.apache.jmeter.gui;
import javax.swing.*;
+import javax.swing.border.*;
+import java.awt.*;
import java.awt.event.*;
-import javax.swing.border.TitledBorder;
-import org.apache.jmeter.util.JMeterUtils;
+import org.apache.jmeter.util.JMeterUtils;
import org.apache.jmeter.control.LoopController;
/************************************************************
* Title: JMeter Description: Copyright: Copyright (c) 2000 Company: Apache
*
*@author Michael Stover
- *@created $Date: 2001/08/31 00:46:43 $
+ *@created $Date: 2001/09/27 13:16:34 $
*@version 1.0
***********************************************************/
public class LoopControlPanel extends JPanel implements ModelSupported,
KeyListener, ActionListener
{
- NamePanel namePanel;
LoopController model;
- JCheckBox infinite = new JCheckBox(JMeterUtils.getResString("infinite"));
- JTextField loops = new JTextField(5);
+ JCheckBox infinite;
+ JTextField loops;
private boolean displayName = true;
- private static String INFINITE = "infinite";
- private static String LOOPS = "loops";
+ private static String INFINITE = "Infinite Field";
+ private static String LOOPS = "Loops Field";
/************************************************************
* !ToDo (Constructor description)
@@ -113,10 +113,6 @@
***********************************************************/
public void updateGui()
{
- if (displayName)
- {
- namePanel.updateGui();
- }
setState();
}
@@ -136,6 +132,7 @@
else
{
loops.setEnabled(true);
+ new FocusRequester(loops);
}
}
@@ -146,7 +143,6 @@
***********************************************************/
public void keyPressed(KeyEvent e)
{
-
}
/************************************************************
@@ -165,54 +161,97 @@
***********************************************************/
public void keyReleased(KeyEvent e)
{
- try
+ String temp = e.getComponent().getName();
+ if (temp.equals(LOOPS))
{
- model.setLoops(Integer.parseInt(loops.getText()));
- }
- catch (NumberFormatException ex)
- {
- if(loops.getText().length() > 0)
+ try
{
- model.setLoops(-1);
- loops.setText("");
- loops.setEnabled(false);
- infinite.setSelected(true);
- JOptionPane.showMessageDialog(this, "You must enter a
valid number",
- "Invalid data",
JOptionPane.WARNING_MESSAGE);
+ model.setLoops(Integer.parseInt(loops.getText()));
}
- else
+ catch (NumberFormatException ex)
{
- model.setLoops(-1);
+ if (loops.getText().length() > 0)
+ {
+ // We need a standard warning/error dialog.
The problem with
+ // having it here is that the dialog is
centered over this
+ // LoopControlPanel instead of begin centered
in the entire
+ // JMeter GUI window.
+ JOptionPane.showMessageDialog(this, "You must
enter a valid number",
+ "Invalid data",
JOptionPane.WARNING_MESSAGE);
+ model.setLoops(-1);
+ loops.setText("");
+ }
+ else
+ {
+ model.setLoops(-1);
+ }
}
}
}
private void init()
{
- this.setLayout(new VerticalLayout(1, VerticalLayout.LEFT));
+ // The Loop Controller panel can be displayed standalone or inside
another panel.
+ // For standalone, we want to display the TITLE, NAME, etc.
(everything). However,
+ // if we want to display it within another panel, we just display the
Loop Count
+ // fields (not the TITLE and NAME).
+
+ // Standalone
if (displayName)
{
- namePanel = new NamePanel(model);
- this.add(namePanel);
+ this.setLayout(new VerticalLayout(5, VerticalLayout.LEFT,
VerticalLayout.TOP));
+
+ // MAIN PANEL
+ JPanel mainPanel = new JPanel();
+ Border margin = new EmptyBorder(10, 10, 5, 10);
+ mainPanel.setBorder(margin);
+ mainPanel.setLayout(new VerticalLayout(5,
VerticalLayout.LEFT));
+
+ // TITLE
+ JLabel panelTitleLabel = new
JLabel(JMeterUtils.getResString("loop_controller_title"));
+ Font curFont = panelTitleLabel.getFont();
+ int curFontSize = curFont.getSize();
+ curFontSize += 4;
+ panelTitleLabel.setFont(new Font(curFont.getFontName(),
curFont.getStyle(), curFontSize));
+ mainPanel.add(panelTitleLabel);
+
+ // NAME
+ NamePanel namePanel = new NamePanel(model);
+ mainPanel.add(namePanel);
+
+ // LOOP
+ mainPanel.add(createLoopCountPanel());
+
+ this.add(mainPanel);
+ }
+
+ // Embedded
+ else
+ {
+ this.add(createLoopCountPanel());
}
- this.add(createLoopCountPanel());
}
private JPanel createLoopCountPanel()
{
- JPanel loopPanel = new JPanel(new VerticalLayout(1,
VerticalLayout.LEFT));
-
loopPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
JMeterUtils.getResString("looping_control")));
+ JPanel loopPanel = new JPanel();
+
+ // LOOP LABEL
+ JLabel loopsLabel = new
JLabel(JMeterUtils.getResString("iterator_num"));
+ loopPanel.add(loopsLabel);
+
+ // TEXT FIELD
+ loops = new JTextField(5);
+ loopPanel.add(loops);
+ loops.setName(LOOPS);
+ loops.addKeyListener(this);
+
+ // FOREVER CHECKBOX
+ infinite = new JCheckBox(JMeterUtils.getResString("infinite"));
infinite.setActionCommand(INFINITE);
infinite.addActionListener(this);
loopPanel.add(infinite);
- JPanel entryPanel = new JPanel();
- entryPanel.add(Box.createHorizontalStrut(10));
- entryPanel.add(new JLabel(JMeterUtils.getResString("iterator_num")));
- loops.setName(LOOPS);
- loops.addKeyListener(this);
- setState();
- entryPanel.add(loops);
- loopPanel.add(entryPanel);
+
return loopPanel;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]