174 * do not have system menus.
175 */
176 protected void addSubComponents() {
177 add(iconButton);
178 add(maxButton);
179 add(closeButton);
180 }
181
182 protected PropertyChangeListener createPropertyChangeListener() {
183 return new MetalPropertyChangeHandler();
184 }
185
186 protected LayoutManager createLayout() {
187 return new MetalTitlePaneLayout();
188 }
189
190 class MetalPropertyChangeHandler
191 extends BasicInternalFrameTitlePane.PropertyChangeHandler
192 {
193 public void propertyChange(PropertyChangeEvent evt) {
194 String prop = (String)evt.getPropertyName();
195 if( prop.equals(JInternalFrame.IS_SELECTED_PROPERTY) ) {
196 Boolean b = (Boolean)evt.getNewValue();
197 iconButton.putClientProperty("paintActive", b);
198 closeButton.putClientProperty("paintActive", b);
199 maxButton.putClientProperty("paintActive", b);
200 }
201 else if ("JInternalFrame.messageType".equals(prop)) {
202 updateOptionPaneState();
203 frame.repaint();
204 }
205 super.propertyChange(evt);
206 }
207 }
208
209 class MetalTitlePaneLayout extends TitlePaneLayout {
210 public void addLayoutComponent(String name, Component c) {}
211 public void removeLayoutComponent(Component c) {}
212 public Dimension preferredLayoutSize(Container c) {
213 return minimumLayoutSize(c);
214 }
225 if (frame.isIconifiable()) {
226 width += 16 + (frame.isMaximizable() ? 2 :
227 (frame.isClosable() ? 10 : 4));
228 }
229 FontMetrics fm = frame.getFontMetrics(getFont());
230 String frameTitle = frame.getTitle();
231 int title_w = frameTitle != null ? SwingUtilities2.stringWidth(
232 frame, fm, frameTitle) : 0;
233 int title_length = frameTitle != null ? frameTitle.length() : 0;
234
235 if (title_length > 2) {
236 int subtitle_w = SwingUtilities2.stringWidth(frame, fm,
237 frame.getTitle().substring(0, 2) + "...");
238 width += (title_w < subtitle_w) ? title_w : subtitle_w;
239 }
240 else {
241 width += title_w;
242 }
243
244 // Compute height.
245 int height = 0;
246 if (isPalette) {
247 height = paletteTitleHeight;
248 } else {
249 int fontHeight = fm.getHeight();
250 fontHeight += 7;
251 Icon icon = frame.getFrameIcon();
252 int iconHeight = 0;
253 if (icon != null) {
254 // SystemMenuBar forces the icon to be 16x16 or less.
255 iconHeight = Math.min(icon.getIconHeight(), 16);
256 }
257 iconHeight += 5;
258 height = Math.max(fontHeight, iconHeight);
259 }
260
261 return new Dimension(width, height);
262 }
263
264 public void layoutContainer(Container c) {
265 boolean leftToRight = MetalUtils.isLeftToRight(frame);
393 }
394 background = MetalLookAndFeel.getWindowTitleInactiveBackground();
395 foreground = MetalLookAndFeel.getWindowTitleInactiveForeground();
396 shadow = MetalLookAndFeel.getControlDarkShadow();
397 bumps = inactiveBumps;
398 gradientKey = "InternalFrame.inactiveTitleGradient";
399 }
400
401 if (!MetalUtils.drawGradient(this, g, gradientKey, 0, 0, width,
402 height, true)) {
403 g.setColor(background);
404 g.fillRect(0, 0, width, height);
405 }
406
407 g.setColor( shadow );
408 g.drawLine ( 0, height - 1, width, height -1);
409 g.drawLine ( 0, 0, 0 ,0);
410 g.drawLine ( width - 1, 0 , width -1, 0);
411
412
413 int titleLength = 0;
414 int xOffset = leftToRight ? 5 : width - 5;
415 String frameTitle = frame.getTitle();
416
417 Icon icon = frame.getFrameIcon();
418 if ( icon != null ) {
419 if( !leftToRight )
420 xOffset -= icon.getIconWidth();
421 int iconY = ((height / 2) - (icon.getIconHeight() /2));
422 icon.paintIcon(frame, g, xOffset, iconY);
423 xOffset += leftToRight ? icon.getIconWidth() + 5 : -5;
424 }
425
426 if(frameTitle != null) {
427 Font f = getFont();
428 g.setFont(f);
429 FontMetrics fm = SwingUtilities2.getFontMetrics(frame, g, f);
430 int fHeight = fm.getHeight();
431
432 g.setColor(foreground);
433
|
174 * do not have system menus.
175 */
176 protected void addSubComponents() {
177 add(iconButton);
178 add(maxButton);
179 add(closeButton);
180 }
181
182 protected PropertyChangeListener createPropertyChangeListener() {
183 return new MetalPropertyChangeHandler();
184 }
185
186 protected LayoutManager createLayout() {
187 return new MetalTitlePaneLayout();
188 }
189
190 class MetalPropertyChangeHandler
191 extends BasicInternalFrameTitlePane.PropertyChangeHandler
192 {
193 public void propertyChange(PropertyChangeEvent evt) {
194 String prop = evt.getPropertyName();
195 if( prop.equals(JInternalFrame.IS_SELECTED_PROPERTY) ) {
196 Boolean b = (Boolean)evt.getNewValue();
197 iconButton.putClientProperty("paintActive", b);
198 closeButton.putClientProperty("paintActive", b);
199 maxButton.putClientProperty("paintActive", b);
200 }
201 else if ("JInternalFrame.messageType".equals(prop)) {
202 updateOptionPaneState();
203 frame.repaint();
204 }
205 super.propertyChange(evt);
206 }
207 }
208
209 class MetalTitlePaneLayout extends TitlePaneLayout {
210 public void addLayoutComponent(String name, Component c) {}
211 public void removeLayoutComponent(Component c) {}
212 public Dimension preferredLayoutSize(Container c) {
213 return minimumLayoutSize(c);
214 }
225 if (frame.isIconifiable()) {
226 width += 16 + (frame.isMaximizable() ? 2 :
227 (frame.isClosable() ? 10 : 4));
228 }
229 FontMetrics fm = frame.getFontMetrics(getFont());
230 String frameTitle = frame.getTitle();
231 int title_w = frameTitle != null ? SwingUtilities2.stringWidth(
232 frame, fm, frameTitle) : 0;
233 int title_length = frameTitle != null ? frameTitle.length() : 0;
234
235 if (title_length > 2) {
236 int subtitle_w = SwingUtilities2.stringWidth(frame, fm,
237 frame.getTitle().substring(0, 2) + "...");
238 width += (title_w < subtitle_w) ? title_w : subtitle_w;
239 }
240 else {
241 width += title_w;
242 }
243
244 // Compute height.
245 int height;
246 if (isPalette) {
247 height = paletteTitleHeight;
248 } else {
249 int fontHeight = fm.getHeight();
250 fontHeight += 7;
251 Icon icon = frame.getFrameIcon();
252 int iconHeight = 0;
253 if (icon != null) {
254 // SystemMenuBar forces the icon to be 16x16 or less.
255 iconHeight = Math.min(icon.getIconHeight(), 16);
256 }
257 iconHeight += 5;
258 height = Math.max(fontHeight, iconHeight);
259 }
260
261 return new Dimension(width, height);
262 }
263
264 public void layoutContainer(Container c) {
265 boolean leftToRight = MetalUtils.isLeftToRight(frame);
393 }
394 background = MetalLookAndFeel.getWindowTitleInactiveBackground();
395 foreground = MetalLookAndFeel.getWindowTitleInactiveForeground();
396 shadow = MetalLookAndFeel.getControlDarkShadow();
397 bumps = inactiveBumps;
398 gradientKey = "InternalFrame.inactiveTitleGradient";
399 }
400
401 if (!MetalUtils.drawGradient(this, g, gradientKey, 0, 0, width,
402 height, true)) {
403 g.setColor(background);
404 g.fillRect(0, 0, width, height);
405 }
406
407 g.setColor( shadow );
408 g.drawLine ( 0, height - 1, width, height -1);
409 g.drawLine ( 0, 0, 0 ,0);
410 g.drawLine ( width - 1, 0 , width -1, 0);
411
412
413 int titleLength;
414 int xOffset = leftToRight ? 5 : width - 5;
415 String frameTitle = frame.getTitle();
416
417 Icon icon = frame.getFrameIcon();
418 if ( icon != null ) {
419 if( !leftToRight )
420 xOffset -= icon.getIconWidth();
421 int iconY = ((height / 2) - (icon.getIconHeight() /2));
422 icon.paintIcon(frame, g, xOffset, iconY);
423 xOffset += leftToRight ? icon.getIconWidth() + 5 : -5;
424 }
425
426 if(frameTitle != null) {
427 Font f = getFont();
428 g.setFont(f);
429 FontMetrics fm = SwingUtilities2.getFontMetrics(frame, g, f);
430 int fHeight = fm.getHeight();
431
432 g.setColor(foreground);
433
|