gpt4 book ai didi

java - 如何在基于 Java Swing 的 GUI 中隐藏/取消隐藏 SplitPane

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:14:05 25 4
gpt4 key购买 nike

我需要在我的代码中隐藏 Slit Pane,如下图所示。我不知道如何在 Java Swing 基本 GUI 中隐藏/取消隐藏拆分 Pane 。在我的代码中,我将拆分 Pane 分成两个水平部分,然后我将拆分 Pane 的右侧部分分成两个垂直部分。我想隐藏/取消隐藏拆分 Pane 的左侧部分。

enter image description here

enter image description here

import java.awt.*;
import java.awt.Event.*;
import javax.swing.*;

class DemoSwingDesign extends JFrame {

boolean b = false;
public static JSplitPane splitpane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true);
public static JSplitPane splitpane1 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true);

public DemoSwingDesign() {
JFrame frame = new JFrame("Split Pain");
frame.setSize(300, 300);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setDefaultLookAndFeelDecorated(true);
frame.setLayout(new GridLayout());
//Defining Split Pane


//splitpane size
splitpane.setDividerLocation(150);
splitpane1.setDividerLocation(90);
splitpane.setContinuousLayout(true);
splitpane.setOneTouchExpandable(true);

JTabbedPane jtp = new JTabbedPane();
jtp.setName("XRay");

JTabbedPane jtp1 = new JTabbedPane();
JTabbedPane jtp2 = new JTabbedPane();
jtp1.setName("Set");
jtp2.setName("OK");

JPanel jp = new JPanel(new BorderLayout());

JComponent Lefttabbedpane = new JTabbedPane();
jp.add(jtp, -1);
Lefttabbedpane = jtp;
splitpane.add(splitpane1, "right");

splitpane.setLeftComponent(new JScrollPane(jtp2));
splitpane1.setTopComponent(new JScrollPane(jtp1));
splitpane1.setBottomComponent(new JScrollPane(Lefttabbedpane));
frame.add(splitpane);
frame.setVisible(true);
}
}

class Temp {

public static void main(String args[]) {
DemoSwingDesign d = new DemoSwingDesign();
}
}

最佳答案

可能您正在寻找这个:JSplitPane.setOneTouchExpandable(boolean)

关于java - 如何在基于 Java Swing 的 GUI 中隐藏/取消隐藏 SplitPane,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9662274/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com