1. /*
  2. * @(#)MotifOptionPaneUI.java 1.14 00/02/02
  3. *
  4. * Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
  5. *
  6. * This software is the proprietary information of Sun Microsystems, Inc.
  7. * Use is subject to license terms.
  8. *
  9. */
  10. package com.sun.java.swing.plaf.motif;
  11. import javax.swing.*;
  12. import javax.swing.plaf.basic.BasicOptionPaneUI;
  13. import javax.swing.plaf.ComponentUI;
  14. import java.awt.Color;
  15. import java.awt.Component;
  16. import java.awt.Container;
  17. import java.awt.Dimension;
  18. import java.awt.Graphics;
  19. import java.awt.Insets;
  20. import java.awt.Rectangle;
  21. /**
  22. * Provides the CDE/Motif look and feel for a JOptionPane.
  23. * <p>
  24. * <strong>Warning:</strong>
  25. * Serialized objects of this class will not be compatible with
  26. * future Swing releases. The current serialization support is appropriate
  27. * for short term storage or RMI between applications running the same
  28. * version of Swing. A future release of Swing will provide support for
  29. * long term persistence.
  30. *
  31. * @version 1.14 02/02/00
  32. * @author Scott Violet
  33. */
  34. public class MotifOptionPaneUI extends BasicOptionPaneUI
  35. {
  36. /**
  37. * Creates a new MotifOptionPaneUI instance.
  38. */
  39. public static ComponentUI createUI(JComponent x) {
  40. return new MotifOptionPaneUI();
  41. }
  42. /**
  43. * Creates and returns a Container containin the buttons. The buttons
  44. * are created by calling <code>getButtons</code>.
  45. */
  46. protected Container createButtonArea() {
  47. Container b = super.createButtonArea();
  48. if(b != null && b.getLayout() instanceof ButtonAreaLayout) {
  49. ((ButtonAreaLayout)b.getLayout()).setCentersChildren(false);
  50. }
  51. return b;
  52. }
  53. /**
  54. * Returns null, CDE/Motif does not impose a minimum size.
  55. */
  56. public Dimension getMinimumOptionPaneSize() {
  57. return null;
  58. }
  59. protected Container createSeparator() {
  60. return new JPanel() {
  61. public Dimension getPreferredSize() {
  62. return new Dimension(10, 2);
  63. }
  64. public void paint(Graphics g) {
  65. int width = getWidth();
  66. g.setColor(Color.darkGray);
  67. g.drawLine(0, 0, width, 0);
  68. g.setColor(Color.white);
  69. g.drawLine(0, 1, width, 1);
  70. }
  71. };
  72. }
  73. /**
  74. * Creates and adds a JLabel representing the icon returned from
  75. * <code>getIcon</code> to <code>top</code>. This is messaged from
  76. * <code>createMessageArea</code>
  77. */
  78. protected void addIcon(Container top) {
  79. /* Create the icon. */
  80. Icon sideIcon = getIcon();
  81. if (sideIcon != null) {
  82. JLabel iconLabel = new JLabel(sideIcon);
  83. iconLabel.setVerticalAlignment(SwingConstants.CENTER);
  84. top.add(iconLabel, "West");
  85. }
  86. }
  87. }