1 package org.columba.mail.gui.frame.util; 17 18 import javax.swing.JComponent ; 19 import javax.swing.JSplitPane ; 20 21 22 public class SplitPane extends JSplitPane { 23 public JSplitPane splitPane = new JSplitPane (); 24 JComponent header; 25 JComponent message; 26 JComponent attachment; 27 boolean hide = false; 28 int last = 0; 29 int lastAttach = 0; 30 31 public SplitPane() { 32 super(); 33 } 34 35 public SplitPane(JComponent header, JComponent message, 36 JComponent attachment) { 37 super(); 38 this.header = header; 39 this.message = message; 40 this.attachment = attachment; 41 42 setBorder(null); 43 splitPane.setBorder(null); 44 45 splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); 48 setOrientation(JSplitPane.VERTICAL_SPLIT); 49 50 setDividerLocation(0.75); 51 52 setResizeWeight(0.25); 55 56 splitPane.setDividerLocation(0.9); 57 splitPane.setResizeWeight(0.9); 58 59 add(header, JSplitPane.TOP); 62 add(splitPane, JSplitPane.BOTTOM); 63 splitPane.add(message, JSplitPane.TOP); 64 splitPane.add(attachment, JSplitPane.BOTTOM); 65 66 } 69 70 public void hideAttachmentViewer() { 71 if (hide == true) { 72 return; 73 } 74 75 last = getDividerLocation(); 76 lastAttach = splitPane.getDividerLocation(); 77 78 remove(splitPane); 79 remove(header); 80 81 add(header, JSplitPane.TOP); 82 add(message, JSplitPane.BOTTOM); 83 84 hide = true; 85 86 setDividerLocation(last); 87 } 88 89 public void showAttachmentViewer() { 90 if (hide == false) { 91 return; 92 } 93 94 last = getDividerLocation(); 95 96 remove(header); 97 remove(message); 98 99 splitPane.add(message, JSplitPane.TOP); 100 splitPane.add(attachment, JSplitPane.BOTTOM); 101 102 add(header, JSplitPane.TOP); 103 add(splitPane, JSplitPane.BOTTOM); 104 105 setDividerLocation(last); 106 splitPane.setDividerLocation(lastAttach); 107 108 hide = false; 109 } 110 } 111 | Popular Tags |