Programalama > JAVA - JSP

Etiketler: dialog, örneği

Ort. 0
Puan ver:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
import com.marinilli.b1.ac.pres.*;
import com.marinilli.b1.ac.pres.ui.memory.*;
import com.marinilli.b1.ac.util.*;
 
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
 
/**
 *
 *
 * @author Toygar Dündaralp
 * tdundaralp@gmail.com
 *
 *
 */
public class ConfigurationDialog extends JDialog
                                  implements ActionListener {
  JPanel panel1 = new JPanel();
  JSplitPane jSplitPane = new JSplitPane();
  MenuList list;
  OkCancelPane okCancelPane = new OkCancelPane(true);
 
 
  public ConfigurationDialog(String title, Configurable[] cv) {
    this(ServiceManager.getMainFrame(), title, cv);
  }
 
  private ConfigurationDialog(Frame frame,
                            String title,
                            Configurable[] cv) {
    super(frame, title , true);
    if (cv.length > 1) {
      list = new MenuList(new Layout(cv));
      list.setPreferredSize(new Dimension(112,122));
    }
    // UI init
    initGUI();
    pack();
    if (frame!=null)
      Utilities.center(this, frame);
    setVisible(true);
  }
 
  void initGUI() {
    okCancelPane.addActionListener(this);
    panel1.setLayout(new BorderLayout());
    getContentPane().add(panel1);
    panel1.add(jSplitPane, BorderLayout.CENTER);
    panel1.add(okCancelPane, BorderLayout.SOUTH);
    JScrollPane jsp = new JScrollPane(list);
    jSplitPane.add(jsp, JSplitPane.LEFT);
    jSplitPane.setDividerSize(6);
    setViewSizes();
  }
 
  private void setViewSizes() {
    int wm = 0;
    int hm = 0;
    for (int i = 0; i < list.getModel().getSize(); i++) {
      int w =list.getView(i).getComponent().getWidth();
      int h =list.getView(i).getComponent().getHeight();
      if (w>wm)
        wm=w;
      if (h>hm)
        hm=h;
    }
    Dimension max = new Dimension(wm, hm);
    for (int i = 0; i < list.getModel().getSize(); i++) {
      ((JComponent)list.getView(i).getComponent()).setPreferredSize(max);
      ((JComponent)list.getView(i).getComponent()).setMinimumSize(max);
      ((JComponent)list.getView(i).getComponent()).setMaximumSize(max);
    }
  }
 
  /**
   * The menuList appears on the left hand side of the ConfigurationDialog.
   */
  public class MenuList extends JList implements ListSelectionListener{
 
    public MenuList(Layout l) {
      super(l);
      addListSelectionListener(this);
      setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
      setCellRenderer(l);
      setSelectedIndex(0);
 
    }
 
    public View getView(int index) {
      return ((Layout)getModel()).getView(index);
    }
 
    public void valueChanged(ListSelectionEvent lse) {
      if (!lse.getValueIsAdjusting()) {
        Component c = getView(getSelectedIndex()).getComponent();
        jSplitPane.setRightComponent(c);
      }
    }
 
  }// - MenuList class
 
 
  /**
   * defines the menuList items layout
   * (order, look and correspondent Viewable object).
   */
  public class Layout extends DefaultListModel
                              implements ListCellRenderer {
    private Component[] categories;
 
    public Layout(Configurable[] cv) {
      super();
      categories = new Component[cv.length];
      for (int i = 0; i < cv.length; i++) {
        addElement(cv[i].getConfigurationView(true));
        categories[i] = cv[i].getCategory();
      }
    }
 
    public View getView(int index) {
      return (View) getElementAt(index);
    }
 
    public Component getCategory(int index) {
      return (Component) categories[index];
    }
 
    public Component getListCellRendererComponent(
        JList list,
        Object value,
        int index,
        boolean isSelected,
        boolean cellHasFocus) {
 
      Component c = getCategory(index);
      if (isSelected) {
        c.setEnabled(true);
        c.setForeground(Color.darkGray);
      else if (c instanceof JLabel)
        // just some special effect
        ((JLabel)c).setEnabled(false);
      return c;
    }
 
  }/// - Layout class
 
 
 
 
  public void actionPerformed(ActionEvent e) {
    String command = e.getActionCommand();
    if (command==CommonActions.CANCEL) {
      dispose();
    } else if (command==CommonActions.OK) {
      // for every View commits its values into the Viewable model
      for (int i = 0; i < list.getModel().getSize(); i++) {
        list.getView(i).doCommit();
      }
      dispose();
    }
  }//-actionPerformed()
 
}//- main class
 
 
toygar dündaralp
bahcivan ibrahim sitesi orman sk.


Yorumlar                 Yorum Yaz
Bu hazır kod'a ilk yorumu siz yapın!
KATEGORİLER
ASP - 240
ASP.NET - 24
C# - 75
C++ - 174
CGI - 8
DELPHI - 247
FLASH - 49
HTML - 536
PASCAL - 246
PERL - 11
PHP - 160
WML - 9
XML - 2
Copyright © 2002 - 2025 Hazır Kod - Tüm Hakları Saklıdır.
Siteden yararlanırken gizlilik ilkelerini okumanızı tavsiye ederiz.
hazirkod.com bir İSOBİL projesidir.