7fd59977 |
1 | |
2 | //Title: OpenCASCADE Samples |
3 | //Version: |
4 | //Copyright: Copyright (c) 1999 |
5 | //Author: User Interface Group (Nizhny Novgorod) |
6 | //Company: Matra Datavision |
7 | //Description: |
8 | |
9 | |
10 | import java.awt.*; |
11 | import java.awt.event.*; |
12 | import javax.swing.*; |
13 | import java.util.*; |
14 | import util.*; |
15 | |
16 | public class SamplePanel extends JPanel |
17 | { |
18 | JPanel myViewPanel; |
19 | TracePanel myTracePanel = new TracePanel(); |
20 | |
21 | //=======================================================================// |
22 | // Constructor // |
23 | //=======================================================================// |
24 | public SamplePanel() |
25 | { |
26 | this(true); |
27 | } |
28 | |
29 | public SamplePanel(boolean isTracePanel) |
30 | { |
31 | try |
32 | { |
33 | jbInit(isTracePanel); |
34 | } |
35 | catch (Exception e) |
36 | { |
37 | e.printStackTrace(); |
38 | } |
39 | } |
40 | |
41 | private void jbInit(boolean isTracePanel) throws Exception |
42 | { |
43 | /* |
44 | setLayout(new BorderLayout()); |
45 | |
46 | myViewPanel = createViewPanel(); |
47 | myViewPanel.setVisible(false); |
48 | add(myViewPanel, BorderLayout.CENTER); |
49 | add(createToolbar(), BorderLayout.NORTH); |
50 | add(myTracePanel, BorderLayout.EAST); |
51 | */ |
52 | |
53 | setLayout(new GridBagLayout()); |
54 | setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); |
55 | |
56 | myViewPanel = createViewPanel(); |
57 | myViewPanel.setVisible(false); |
58 | add(createToolbar(), new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0, |
59 | GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, |
60 | new Insets(0, 0, 0, 0), 0, 0)); |
61 | add(myViewPanel, new GridBagConstraints(0, 1, 1, 1, 6.0, 1.0, |
62 | GridBagConstraints.CENTER, GridBagConstraints.BOTH, |
63 | new Insets(0, 0, 0, 0), 0, 0)); |
64 | if (isTracePanel) |
65 | { |
66 | add(myTracePanel, new GridBagConstraints(1, 1, 1, 1, 4.0, 1.0, |
67 | GridBagConstraints.CENTER, GridBagConstraints.BOTH, |
68 | new Insets(0, 0, 0, 0), 0, 0)); |
69 | } |
70 | } |
71 | |
72 | //-----------------------------------------------------------------------// |
73 | public JPanel createViewPanel() |
74 | { |
75 | return new ViewPanel(); |
76 | } |
77 | |
78 | //-----------------------------------------------------------------------// |
79 | public Component createToolbar() |
80 | { |
81 | JToolBar tools = new JToolBar() { |
82 | public Dimension getMinimumSize() { |
83 | return new Dimension(700, super.getMinimumSize().height); |
84 | } |
85 | }; |
86 | tools.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); |
87 | tools.setFloatable(false); |
88 | |
89 | return tools; |
90 | } |
91 | |
92 | //=======================================================================// |
93 | // Actions // |
94 | //=======================================================================// |
95 | public void traceMessage(String text, String title) |
96 | { |
97 | myTracePanel.setTitle(title); |
98 | myTracePanel.setText(text); |
99 | } |
100 | |
101 | //-----------------------------------------------------------------------// |
102 | public void setVisible(boolean b) |
103 | { |
104 | super.setVisible(b); |
105 | myViewPanel.setVisible(b); |
106 | if (b) this.validate(); |
107 | } |
108 | |
109 | //=======================================================================// |
110 | // Action Listener // |
111 | //=======================================================================// |
112 | public void actionPerformed(ActionEvent e) |
113 | { |
114 | } |
115 | |
116 | } |
117 | |