Giter Site home page Giter Site logo

swing-htabs's Introduction

swing-htabs Gitter Build Status

Hierarchical tabs for Swing.

Screenshot of swing-htabs

Background

The Java Swing UI doesn't have support for creating hierarchical tabs (tabs that are shown as a tree). We needed this for gngr. We couldn't find any existing libraries to achieve this, hence this project.

Status

The current status of this library is a proof-of-concept. We are using a little hack to indent the tab components in a custom JTabbedPane. It works fine in our tests, but we need more testing. Please see the contributing section below.

The Metal LAF has a small, known issue. The tabs in this LAF have a little notch that overlaps with the next tab, making it difficult to indent without looking odd. As a workaround we are indenting only the tab content.

The API will be stabilized after testing.

Contributing

We need more testing to complete this matrix:

JRE v/s LAF Metal GTK+ Nimbus Motif Windows Windows Classic MacOSX
Ubuntu14.x + OracleJRE8 - - -
Ubuntu14.10 + OpenJDK7 - - -
Windows XP + Oracle JVM 7 - -
MacOSX + OracleJRE8 - - -
Ubuntu14.04+tilingWindowMgr+OracleJVM7 issue - - -
TODO: More Windows versions - - - - - - -

How to test

Testing is easy; download the latest jar from the releases page. After running the jar file, you will see some randomly generated tabs, with the System LAF. Try switching to other LAFs using the radio buttons on the top. Append your report to this issue

Copyright and License

Copyright 2014 Uproot Labs India

Distributed under the Apache v2 License

swing-htabs's People

Contributors

chetankothari avatar gitter-badger avatar hrj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

swing-htabs's Issues

Exception while adding newChild/newSibling to empty JTabbedPane

Problem :

When the JTabbedPane is empty, an exception is thrown if we try to add newChild or newSibling.

Cause :

The reason for this exception is, when we add newChild or newSibling, we first get the activeTab from the JTabbedPane, and then add a new tab/sibling. But since there are no tabs we get an exception.

Quick Solution :

This could be handled by checking if there is any tab in the JTabbedPane before adding a new tab/sibling, if there is no tab then create a new tab and add it to the JTabbedPane.


I feel this is specific to the DemoApp and not the library.

Listener for tab close

It should be possible to register a listener than gets called whenever a tab is about to be closed. And, it should be possible to cancel the closure through the listener.

Use cases

  1. a tab with child tabs is being closed
    1. is collapsed -- could close only self or all children as well (possibly after confirmation)
    2. is not collapsed -- close only self if normal click, but close children also if Shift+Click, for example.
  2. a tab has dirty content
    a tab could have unsaved changes, and hence require confirmation before closing.

To cover all these use-cases, various contexts need to be available to the listener:

  1. tab is collapsed or not
  2. state of keyboard modifiers like SHIFT.

Automated builds

A simple ant script would do for now, since there are no dependencies nor are we publishing artifacts.

Test results for version 0.0

Please add your test results here for version 0.0 of swing-htabs.

Mention the OS and Java version, followed by the result of each Look and Feel.

Example

OS: Ubuntu
Java version: OpenJDK 7

  • Nimbus: works fine
  • GTK: problem, description
  • Motif: works fine

Dependency management

I'd be happy, if I could use some solutions from Google's Guava or the Apache Commons.
(For example see the TODO's in #12 )

Is there any plan, to use some dependency management in the project, and I'll be able to use some of these solutions, or should I implement these stuff?

Behavior after closing tab with children

There are three possibilities

  1. Promote the first child to be the parent. This is the current behavior and matches that of TreeStyleTabs. However, it is a little weird, because siblings of the first child tab suddenly become its children.
  2. Promote the whole sub-tree of the tab one level up. This is very intiuitive but when the closed tab is a root tab, it will suddenly create a number of new root tabs. Hence, the next alternative is:
  3. Use (2) except when the closed tab is root. In that case use (1).

(3) makes the most sense from a usability point of view.

However, we should see how this interacts with #3

Problems with non-reparenting window manager support.

Running swing-htabs-v0.0.jar while using a non-reparenting window manage like AwesomeWM, Xmonad, or dwm only a grey box is shown. This seems to be a problem with java having a hard coded list of window managers that support this parenting strategy. Some apps like minecraft have fixed this issue in current versions, but was present in earlier versions.

There are solutions and tools for users to fix this behavior. OpenJDK supports an environment variable, and there are a few tools that can 'fudge' the name of the window manager to one supported on the list.

Info from arch wiki's XMonad page: "The standard Java GUI toolkit has a hard-coded list of "non-reparenting" window managers. Since xmonad is not in that list, there can be some problems with running some Java applications. One of the most common problems is "gray blobs", when the Java application renders as a plain gray box instead of rendering the GUI."

This is reproducible for sure on Ubuntu 14.04 64bit under the Awesome window manager using java version "1.7.0_72", but I think it's present on all combinations and versions.

Configurability

Behavior should be configurable at run-time.

This includes:

  • Indentation amount (in pixels or some better unit)
  • New tab location (child of selection, sibling of selection, root, etc)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.