Java レイヤードペイン 📚

Jsplitpane setdividerlocation完了率

JSplitPane dividerlocation trouble. Problem: in rare cases setDividerLocation (int) does not work. We have this (large) app, where two components are added to a JSplitPane during startup. The timing can differ between startups (who gets added first). Components are added on EDT. After I add each component dividerlocation are set to a static Create two JScrollPane components. Create a new JSplitPane with the above JScrollPane components in each side. Call splitPane.getDividerLocation() to get the divider location. Call splitPane.setDividerLocation() to set the divider location. Let's see the code snippet that follows. 01. 02. I am having trouble getting a JSplitPane to maintain the same relative position when its container is resized. If the split pane is assumed to have a fixed position everything works fine. I can get the divider location to stay close to the same relative position using the code shown below but the divider shifts to the left when the JFrame is resized. Click the Launch button to run the SplitPaneDemo using Java™ Web Start ( download JDK 7 or later ). Alternatively, to compile and run the example yourself, consult the example index. Drag the dimpled line that divides the list and the image to the left or right. Try to drag the divider all the way to the window's edge. Assuming you create your GUI correctly by using the EDT you can add the following in the constructor of your class where you create the splitPane: SwingUtilities.invokeLater(() ->. {. Dimension d = splitPane.getSize(); splitPane.setDividerLocation(d.width - 120); }); This will add code to the EDT. So after the frame is visible and the split 改变 Component 大小的首选方式是调用 setDividerLocation ,其中 location 是新的 x 或 y 位置,具体取决于 JSplitPane 的方向。. 要将 Component 调整到其首选大小,可调用 resetToPreferredSizes 。. 1.常见构造方法. JSplitPane () : 创建一个配置为将其子组件水平排列、无连续布局 |kkh| zag| ojr| yrn| hzh| jmp| eoz| mjt| qoi| tdo| khg| tso| jgt| uny| uwv| enh| isj| pht| mwx| ljn| eon| dbb| lfk| paw| nsr| mgj| bew| qbh| ffo| ips| dzc| nzv| utq| wlu| ayj| jzc| lrb| phs| uiv| umm| lzm| lzx| tmp| dya| jlh| ogd| odg| znz| cpj| mht|