Java Code Examples for javax.swing.JSplitPane#getTopComponent()

The following examples show how to use javax.swing.JSplitPane#getTopComponent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SimpleInternalFrame.java    From chipster with MIT License 6 votes vote down vote up
/**
 * Returns true if the frame is maximized
 * @return
 */
public boolean isMaximized(){
	if(this.getParent() instanceof JSplitPane){
		JSplitPane split = ((JSplitPane)this.getParent());
		if(split.getTopComponent() == this){
			if(split.getDividerLocation() == split.getHeight() - (gradientPanel.getHeight() + split.getDividerSize() + SPLIT_MARGIN)){
				logger.debug("is a maximized top component");
				return true;
			} else {
				logger.debug("is not a maximized component, but it is a top component");
				return false;
			}
		} else {
			if(split.getDividerLocation() == gradientPanel.getHeight()){
				logger.debug("is a maximized bottom component");
				return true;
			} else {
				logger.debug("is not a maximized component, but is is a bottom component");
				return false;
			}
		}
	} else {
		throw new IllegalStateException("SimpleInternalFrame is not on a split pane");
	}
}
 
Example 2
Source File: SimpleInternalFrame.java    From chipster with MIT License 6 votes vote down vote up
/**
    * Maximizes the frame if it is on a split pane and user double clicks 
    * to the title panel
    */
public void mouseClicked(MouseEvent e) {
	
	if(SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 2){
		if(this.getParent() instanceof JSplitPane){
			JSplitPane split = (JSplitPane)this.getParent();
			
			int maximizedDividerLocation = 0;
			
			if(split.getTopComponent() == this) {
				maximizedDividerLocation = split.getHeight() - (gradientPanel.getHeight() + split.getDividerSize() + SPLIT_MARGIN);
			} else {
				maximizedDividerLocation = gradientPanel.getHeight();
			}
			
			if (isMaximized()) {
				split.setDividerLocation(split.getLastDividerLocation());
			} else {
				split.setDividerLocation(maximizedDividerLocation);
			}
		}
	}
}
 
Example 3
Source File: JCompoundSplitPane.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private Component getFirstComponent(JSplitPane splitPane) {
    if (splitPane.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) {
        return splitPane.getLeftComponent();
    } else {
        return splitPane.getTopComponent();
    }
}
 
Example 4
Source File: JCompoundSplitPane.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
private Component getFirstComponent(JSplitPane splitPane) {
    if (splitPane.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) {
        return splitPane.getLeftComponent();
    } else {
        return splitPane.getTopComponent();
    }
}