jsplitpane

JSplitPane in JLayeredPane

倖福魔咒の 提交于 2020-01-05 09:01:11
问题 I want the right content of an JSplitPane to fill the entire available space and the left content (panel) to be on top of the other panel. I was thinking about using a JLayeredPane to solve that problem but I couldn't get it to work. My class currently looks like this: public class LayeredPane extends JLayeredPane { private Component topComponent; private Component mainComponent; public LayeredPane() { setLayout(new GridBagLayout()); } public Component setTopComponent(Component c) { this

How do you get JSplitPane to keep the same proportional location if the user has moved the location of the divider

折月煮酒 提交于 2020-01-01 18:54:13
问题 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. The shift is larger if the JFrame is resized slowly. The shift is to the left if the JFrame is made smaller or larger. How do I get the divider

How to change the color or background color of JSplitPane divider?

无人久伴 提交于 2019-12-23 17:25:14
问题 I am trying to the set the background color for the JSplitPane divider. I've written the following code, but it doesn't seem to work. BasicSplitPaneUI ui = (BasicSplitPaneUI) splitPane.getUI(); BasicSplitPaneDivider divider = ui.getDivider(); divider.setBackground(Color.decode("#FFFACD")); I've even tried the suggestion given here How to set BackGround color to a divider in JSplitPane Can someone please point out the mistake or let me know any other approach? 回答1: This works for me

Java: JSplitPane duplicates top panel's contents to bottom panel when Timer is active

夙愿已清 提交于 2019-12-23 12:22:22
问题 So I have a JSplitPane, and two JPanels - one on top, one on the bottom. In both panels I overrode the paintComponent method and added my own graphics. In the bottom panel, I wanted to add an animation. When the panel does not repaint, it's fine, but as soon as the Timer (javax.swing.Timer) starts to call repaints, the bottom panel mimics the appearance of the top panel and glitches out. The actual animations are not refreshed, but rather it keeps on adding (like a dragged paintbrush instead

JSplitPane SetDividerLocation Problem

别说谁变了你拦得住时间么 提交于 2019-12-23 06:57:38
问题 I have a JSplitPane which when shown should split the pane by 50%. Now on giving an argument of 0.5 (as suggested) to setDividerLocation, Java seems to treat it as a normal number instead of a percentage. As in, the divider, instead of going to the middle of the pane, is almost at the start of the left pane (the pane is vertically split). Any work arounds? 回答1: Am I missing something? There seem to be a lot of rather convoluted answers to this question... but I think a simple setResizeWeight

Using JSplitPane with an AWT component

不问归期 提交于 2019-12-22 08:41:32
问题 I have an AWT canvas which I cannot convert to a Swing component (it comes from VTK). I wish to display a few of these canvases inside of a JSplitPane. I've read about mixing heavy and light weight components in Java and know that it's a pain in the butt, but I don't have a choice. If I wrap the AWT canvas inside of a JPanel and then put that on the split pane the split pane doesn't function at all. However, if I put the AWT canvas inside of a JPanel and then that inside of a JScrollPane and

JSplitPane: is there a way to show/hide one of the panes?

人走茶凉 提交于 2019-12-21 04:53:31
问题 I have a JSplitPane with two components, A and B, but sometimes I want to be able to hide B, so that either of the following are true: components A and B are visible in the JSplitPane only component A is visible in the space occupied by the JSplitPane Is there a way to do this? 回答1: Heck, I'll throw in an attempt at a solution... import java.awt.Dimension; import java.awt.event.*; import javax.swing.*; public class Test { public static void main(String[] args) { JFrame frame = new JFrame();

Resizing issue with canvas within jscrollpane within jsplitpane

こ雲淡風輕ζ 提交于 2019-12-16 19:41:29
问题 I'm creating an application using the NetBeans GUI Editor, in which I want to have a JSplitPane , the top component of which will be a Canvas within a JScrollPane and the bottom component will be a JTextArea , or something like that. When I pull the divider downwards, and thus increasing the size of the top component everything seem to resize just fine. The problem appears when I'm trying to push the divider upwards: The divider seems to go beneath the Canvas (and maybe beneath the

Resizing issue with canvas within jscrollpane within jsplitpane

爱⌒轻易说出口 提交于 2019-12-16 19:41:05
问题 I'm creating an application using the NetBeans GUI Editor, in which I want to have a JSplitPane , the top component of which will be a Canvas within a JScrollPane and the bottom component will be a JTextArea , or something like that. When I pull the divider downwards, and thus increasing the size of the top component everything seem to resize just fine. The problem appears when I'm trying to push the divider upwards: The divider seems to go beneath the Canvas (and maybe beneath the

JSplitPane setOneTouchExpandable(true) is not shown

我们两清 提交于 2019-12-13 19:29:50
问题 I'm using nested JSplitPane... I want to use OneTouchExpandable, but running the code is not shown... But in preview mode I can see it. Here complete code : import javax.swing.JPanel; import javax.swing.JFrame; import javax.swing.JSplitPane; import javax.swing.JLabel; import javax.swing.JButton; import javax.swing.JTextField; import javax.swing.GroupLayout; import javax.swing.GroupLayout.Alignment; import java.awt.Dimension; import java.util.logging.Level; import java.util.logging.Logger;