⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e826. getting and setting the divider location in a jsplitpane container.txt

📁 这里面包含了一百多个JAVA源文件
💻 TXT
字号:
The location of a divider is measured in pixels from either the left edge (in the case of a horizontal split pane) or the top edge (in the case of a vertical split pane). 
There are two ways to set the location of the divider. The first is to specify an absolute location based on the distance in pixels from the left or top edge. The second is to specify a proportional location based on the distance from the left or top edge. For example, a proportional location of 0 sets the divider at the left or top edge. A proportional location of 1 sets the divider at the right or bottom edge. A proportional location of .5 sets the divider at the center. 

    // Create a left-right split pane
    JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftComponent, rightComponent);
    
    // Get current location; result is number of pixels from the left edge
    int loc = pane.getDividerLocation();
    
    // Set a new location using an absolution location; center the divider
    loc = (int)((pane.getBounds().getWidth()-pane.getDividerSize())/2);
    pane.setDividerLocation(loc);
    
    double propLoc = .5D;
    // Set a proportional location
    pane.setDividerLocation(propLoc);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -