KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > shark > corbaclient > RefreshingRate


1 package org.enhydra.shark.corbaclient;
2
3 import java.awt.*;
4 import java.awt.event.*;
5
6 import javax.swing.*;
7
8 /**
9  * Used to set the refreshing rate in seconds and to hold it's value.
10  *
11  * @author Sasa Bojanic
12  * @version 1.0
13  */

14 public class RefreshingRate extends ActionPanel {
15
16    private static Dimension textFieldDimension=new Dimension(100,20);
17
18    private JTextField refreshingRateField;
19
20    int refreshingRateInSeconds;
21
22    public RefreshingRate (Window parent,int refreshingRateInSeconds){
23       super();
24       this.refreshingRateInSeconds=refreshingRateInSeconds;
25       super.init();
26       super.initDialog(parent,
27          ResourceManager.getLanguageDependentString("DialogSetRefreshingRateInSeconds"),
28          true,true);
29    }
30
31    protected void createActions () {}
32
33    protected Component createCenterComponent (){
34       JPanel panel = new JPanel();
35
36       panel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
37       panel.setLayout(new BoxLayout(panel,BoxLayout.X_AXIS));
38
39       JLabel rrl=new JLabel(ResourceManager.getLanguageDependentString("NewValueKey")+":");
40       panel.add(rrl);
41
42       refreshingRateField=new JTextField(String.valueOf(refreshingRateInSeconds));
43       refreshingRateField.setMinimumSize(new Dimension(textFieldDimension));
44       refreshingRateField.setMaximumSize(new Dimension(textFieldDimension));
45       refreshingRateField.setPreferredSize(new Dimension(textFieldDimension));
46       panel.add(refreshingRateField);
47
48       return panel;
49    }
50
51    protected void applyChanges () {
52       int rrins;
53       try {
54          rrins=Integer.valueOf(refreshingRateField.getText()).intValue();
55       } catch (Exception JavaDoc ex) {
56          JOptionPane.showMessageDialog(myDialog,
57             ResourceManager.getLanguageDependentString("ErrorEnteredValueIsNotAllowed"),
58             ResourceManager.getLanguageDependentString("DialogSetRefreshingRate"),
59             JOptionPane.ERROR_MESSAGE);
60             return;
61       }
62       if (rrins<=0) {
63          JOptionPane.showMessageDialog(myDialog,
64             ResourceManager.getLanguageDependentString("ErrorEnteredValueIsNotAllowed"),
65             ResourceManager.getLanguageDependentString("DialogSetRefreshingRate"),
66             JOptionPane.ERROR_MESSAGE);
67             return;
68       }
69       refreshingRateInSeconds=rrins;
70       myDialog.dispose();
71    }
72
73    protected void cancelChanges () {
74       myDialog.dispose();
75    }
76
77    public int getRefreshingRate (){
78       return refreshingRateInSeconds;
79    }
80
81    public void setRefreshingRate (int rris) {
82       refreshingRateInSeconds=rris;
83    }
84
85
86 }
87
88
Popular Tags