01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: *
19: */
20: package org.apache.mina.example.udp;
21:
22: import java.awt.GridBagConstraints;
23: import java.awt.GridBagLayout;
24: import java.awt.Insets;
25:
26: import javax.swing.JLabel;
27: import javax.swing.JPanel;
28: import javax.swing.JTextField;
29: import javax.swing.SwingUtilities;
30:
31: /**
32: * Class the represents a client connection using a JPanel
33: *
34: * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
35: * @version $Rev$, $Date$
36: */
37: public class ClientPanel extends JPanel {
38:
39: private static final long serialVersionUID = 1L;
40:
41: private JTextField textField;
42:
43: public ClientPanel(String label) {
44: super ();
45:
46: setPreferredSize(MemoryMonitor.PANEL_SIZE);
47:
48: setLayout(new GridBagLayout());
49: GridBagConstraints c = new GridBagConstraints();
50:
51: c.insets = new Insets(5, 5, 5, 5);
52: c.anchor = GridBagConstraints.CENTER;
53:
54: c.gridwidth = GridBagConstraints.REMAINDER;
55: add(new JLabel(label), c);
56:
57: c.gridwidth = 1;
58: add(new JLabel("Memory Used : "));
59: textField = new JTextField(10);
60: textField.setEditable(false);
61: add(textField, c);
62: }
63:
64: public void updateTextField(final long val) {
65: System.out.println("New value for textfield - " + val);
66: SwingUtilities.invokeLater(new Runnable() {
67: public void run() {
68: textField.setText(String.valueOf(val));
69: }
70: });
71: }
72: }
|