1 7 8 package com.sun.java.swing.plaf.motif; 9 10 import javax.swing.*; 11 import javax.swing.plaf.basic.BasicOptionPaneUI ; 12 import javax.swing.plaf.ComponentUI ; 13 import java.awt.Color ; 14 import java.awt.Component ; 15 import java.awt.Container ; 16 import java.awt.Dimension ; 17 import java.awt.Graphics ; 18 import java.awt.Insets ; 19 import java.awt.Rectangle ; 20 21 34 public class MotifOptionPaneUI extends BasicOptionPaneUI 35 { 36 39 public static ComponentUI createUI(JComponent x) { 40 return new MotifOptionPaneUI(); 41 } 42 43 47 protected Container createButtonArea() { 48 Container b = super.createButtonArea(); 49 50 if(b != null && b.getLayout() instanceof ButtonAreaLayout) { 51 ((ButtonAreaLayout)b.getLayout()).setCentersChildren(false); 52 } 53 return b; 54 } 55 56 59 public Dimension getMinimumOptionPaneSize() { 60 return null; 61 } 62 63 protected Container createSeparator() { 64 return new JPanel() { 65 66 public Dimension getPreferredSize() { 67 return new Dimension (10, 2); 68 } 69 70 public void paint(Graphics g) { 71 int width = getWidth(); 72 g.setColor(Color.darkGray); 73 g.drawLine(0, 0, width, 0); 74 g.setColor(Color.white); 75 g.drawLine(0, 1, width, 1); 76 } 77 }; 78 } 79 80 85 protected void addIcon(Container top) { 86 87 Icon sideIcon = getIcon(); 88 89 if (sideIcon != null) { 90 JLabel iconLabel = new JLabel(sideIcon); 91 92 iconLabel.setVerticalAlignment(SwingConstants.CENTER); 93 top.add(iconLabel, "West"); 94 } 95 } 96 97 } 98 | Popular Tags |