jsplitpane

Detecting JSplitPane Divider Movement

青春壹個敷衍的年華 提交于 2019-12-12 10:29:54
问题 Is there a way to detect when a JSplitPane divider is moved? Is there a way to add a listener for divider movement? JPanel panel1 = new JPanel(); JPanel panel2 = new JPanel(); JSplitPane sp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panel1, panel2); // What do I put here to be notified if the divider in sp is moved? 回答1: I think you're looking for addPropertyChangeListener from Container . Something like this... sp.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, new

How to make JSplitPane auto expand on mouse hover?

不羁的心 提交于 2019-12-11 19:45:06
问题 I want to make a Java program with Swing layout where there is a menu on the left that is expanded when a mouse hovers over the menu area, but auto contracts after your mouse leaves. I am trying to imitate the effect of something like mobile Youtube for Android, or Weebly's editor. Fro those who don't know, both layouts have menus on the left that expand when your mouse hovers over them. Then after your mouse leaves the area, the menu contracts again and is out of view. I was able to create

JSplitPane + MiGLayout: how to enable autoresizing

笑着哭i 提交于 2019-12-11 03:11:20
问题 I'm doing something wrong here: I want to have two JButtons in a JSplitPane in a JPanel in a a JFrame, where the buttons fill the JSplitPane. Here's what I get when I resize the JFrame: The buttons stay their normal size, and the JSplitPane doesn't allow adjusting.something How do I fix this? import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JSplitPane; import net.miginfocom.swing.MigLayout; public class SplitPaneQuestion { public static void

Swing JSplitPane problem

旧巷老猫 提交于 2019-12-11 00:22:31
问题 How to Split Component vertically into different parts? Is It possible in Swing? I want to assign different ScrollBar to each part ? 回答1: you should use the JSplitPane if you need each part to be on a diffrent scroller - just put them on to diffrent scroller pane. JPanel topPanel = new JPanel(); JScrollPane topScrollPane = new JScrollPane(topPanel); JPanel buttomPanel = new JPanel(); JScrollPane buttomScrollPane = new JScrollPane(buttomPanel); JSplitPane splitPane = new JSplitPane(JSplitPane

Animation for divider movement in JSplitPane

大兔子大兔子 提交于 2019-12-10 20:29:47
问题 In my code, the UI has the following components: JSplitPane: pane1: JTable pane2: JPanel with some texutal information. I am listening to the row selection events on the table and then setting the divider location of the splitpane appropriately so that the textual information is visible for some row and is hidden for some other rows. However, one problem with this approach is the switching to the divider location is very abrupt which gives very less time to the user to understand what

JScrollPane- Only Vertical Scroll?

﹥>﹥吖頭↗ 提交于 2019-12-10 17:47:03
问题 I have the following line of code: JSplitPane VPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,(new class1()),new JScrollPane(new class2())); I'd like class2 to ONLY have vertical scrolling please? Since my layout falls to bits otherwise. I am using GridBagLayout and it's too late to change the layout now. Is there a method to fix this? 回答1: +1 to trashgods comment. It doesn't seem to work- I'm just getting errors =[ To illustrate this: JScrollPane js=...; //Create a variable reference to the

How to set BackGround color to a divider in JSplitPane

[亡魂溺海] 提交于 2019-12-08 04:05:43
问题 I have created a divider in JSplitPane . I am unable to set the color of divider. I want to set the color of divider. Please help me how to set color of that divider. import javax.swing.*; import java.awt.*; import java.awt.event.*; public class SplitPaneDemo { JFrame frame; JPanel left, right; JSplitPane pane; int lastDividerLocation = -1; public static void main(String[] args) { SplitPaneDemo demo = new SplitPaneDemo(); demo.makeFrame(); demo.frame.addWindowListener(new WindowAdapter() {

Need the height of an invalidated Swing component

六眼飞鱼酱① 提交于 2019-11-30 20:23:14
The basic setup is this: I have a vertical JSplitPane that I want to have a fixed-size bottom component and a resizing top component, which I accomplished by calling setResizeWeight(1.0) . In this application there is a button to restore the "default" window configuration. The default height of the window is the desktop height, and the default divider location is 100 pixels from the bottom of the split pane. To set the divider location to 100px, I take the JSplitPane height - 100. The problem is, just before this I resize the JFrame, and since the code is in a button callback, the JSplitPane

how can you programmatically set the JSplitPane to hide the right/bottom component when OneTouchExpandable is set to true?

喜欢而已 提交于 2019-11-30 17:23:46
问题 In a JSplitPane , you have the setOneTouchExpandable method which provides you with 2 buttons to quickly fully hide or full show the JSplitPane . My question is how can you programmatically "click" the hide button on the JSplitPane ? I may have wrongly explained myself. I want the splitpane to show only one of the 2 components at start (this is what i mean by clicking). This works: import javax.swing.*; class SplitPaneDefault { public static void main(String[] args) { SwingUtilities

How to set JSplitPane-Divider collapse/expand State?

怎甘沉沦 提交于 2019-11-30 09:36:37
I have a JFrame with a JSplitPane that is OneTouchExpandable. I want to remember the last Divider position of the JSplitPane on JFrame dispose and restore the Position if the JFrame is reopened. It works well, but if the User expand one Side via the oneTouchExpandable UI-Widget then I store only the 'int'-Position on dispose and set the 'int'-Position back again with the consequence on JFrame-resizing the JSplitPane-Divider jumps to the collapsed Component preferredSize. How can I get/set the collapse/expand State? EDIT Now: the resize-Behavior is OK, but it is not exactly the same behavior