Java GUI控件SwingX之JXTaskPane的使用示例

JXTaskPane 类似XP 左边的导航栏,在开发Swing应用的时候很好用的。

下面两张截图反应了JXTaskPane的动画效果。可以自由的卷起和展开。

   

JXTaskPane的的使用步骤:

1、新建一个 JXTaskPaneContainer 

2、新建{i}个JXTaskPane   (i>=1)

3、依次将 新建的JXTaskPane 添加到 JXTaskPaneContainer 中去。

4、最后将 JXTaskPaneContainer 添加到JFrame 中。

下面附上 SwingX的官方doc中的示例代码:

复制代码
JXFrame frame = new JXFrame();
 
 // a container to put all JXTaskPane together
 JXTaskPaneContainer taskPaneContainer = new JXTaskPaneContainer();
 
 // create a first taskPane with common actions
 JXTaskPane actionPane = new JXTaskPane();
 actionPane.setTitle("Files and Folders");
 actionPane.setSpecial(true);
 
 // actions can be added, a hyperlink will be created
 Action renameSelectedFile = createRenameFileAction();
 actionPane.add(renameSelectedFile);
 actionPane.add(createDeleteFileAction());
 
 // add this taskPane to the taskPaneContainer
 taskPaneContainer.add(actionPane);
 
 // create another taskPane, it will show details of the selected file
 JXTaskPane details = new JXTaskPane();
 details.setTitle("Details");
  
 // add standard components to the details taskPane
 JLabel searchLabel = new JLabel("Search:");
 JTextField searchField = new JTextField("");
 details.add(searchLabel);
 details.add(searchField);
 
 taskPaneContainer.add(details);
 
 // put the action list on the left 
 frame.add(taskPaneContainer, BorderLayout.EAST);
 
 // and a file browser in the middle
 frame.add(fileBrowser, BorderLayout.CENTER);
 
 frame.pack();
 frame.setVisible(true);
复制代码

默认JXTaskPane 的动画功能是起用的,你也可以关闭 :

只要 myJXTaskPane.setAnimated(false);  就可以了。

不过,遗憾的是,该GUI控件库被 Oracle/SUN公司收购后,就没有后续更新了,貌似最新的版本为1.6.5。

相关链接:

1、JXTaskPane 示例

2、swingx.zip下载

3、swingx-core-1.6.5或者http://www.java2s.com/Code/JarDownload/swingx/swingx-core-1.6.5-1.jar.zip或者我的百度云盘中去下载,  提取码:zppz。

 

posted @   rainbow70626  阅读(889)  评论(0编辑  收藏  举报
编辑推荐:
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
阅读排行:
· 终于写完轮子一部分:tcp代理 了,记录一下
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
点击右上角即可分享
微信分享提示