1 7 package org.openharmonise.him.displaycomponents.table.title; 8 9 import java.awt.Component ; 10 import java.awt.event.ComponentAdapter ; 11 import java.awt.event.ComponentEvent ; 12 import java.beans.PropertyChangeEvent ; 13 import java.beans.PropertyChangeListener ; 14 15 import javax.swing.JSplitPane ; 16 17 26 public class TitleBarSplitPane extends JSplitPane { 27 28 private static int HEIGHT = 30; 29 30 33 public TitleBarSplitPane() { 34 super(); 35 this.setup(); 36 } 37 38 41 public TitleBarSplitPane(int newOrientation) { 42 super(newOrientation); 43 this.setup(); 44 } 45 46 50 public TitleBarSplitPane(int newOrientation, boolean newContinuousLayout) { 51 super(newOrientation, newContinuousLayout); 52 this.setup(); 53 } 54 55 60 public TitleBarSplitPane( 61 int newOrientation, 62 Component newLeftComponent, 63 Component newRightComponent) { 64 super(newOrientation, newLeftComponent, newRightComponent); 65 this.setup(); 66 } 67 68 74 public TitleBarSplitPane( 75 int newOrientation, 76 boolean newContinuousLayout, 77 Component newLeftComponent, 78 Component newRightComponent) { 79 super( 80 newOrientation, 81 newContinuousLayout, 82 newLeftComponent, 83 newRightComponent); 84 this.setup(); 85 } 86 87 90 public void setDividerLocation(double loc) { 91 super.setDividerLocation(new Integer (HEIGHT).intValue()); 92 } 93 94 97 public void setExtDividerLocation(int loc) { 98 super.setDividerLocation(new Integer (HEIGHT).intValue()); 99 } 100 101 private void setup() { 102 this.setOneTouchExpandable(true); 103 this.setContinuousLayout(true); 104 this.setDividerSize(0); 105 this.setExtDividerLocation(HEIGHT); 106 } 107 108 public class DividerListener 109 extends ComponentAdapter 110 implements PropertyChangeListener { 111 double percentage = 1.0; 112 boolean ignore = false; 113 114 public void propertyChange(PropertyChangeEvent event) { 115 String prop = event.getPropertyName(); 116 JSplitPane split = (JSplitPane ) event.getSource(); 117 if (prop.equals("lastDividerLocation")) { 118 if (ignore) { 119 ignore = false; 120 } else { 121 setExtDividerLocation(new Integer (HEIGHT).intValue()); 122 } 123 } 124 } 125 126 public void componentResized(ComponentEvent event) { 127 ignore = true; 128 setExtDividerLocation(new Integer (HEIGHT).intValue()); 129 repaint(); 130 } 131 } 132 133 } 134 | Popular Tags |