Class JsonSplitPane

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class JsonSplitPane extends JPanel
Split-pane panel that displays a JSON file in two synchronized views: colorized raw text on the left and a collapsible tree on the right, with a shared search bar along the bottom.

Layout

 ┌─────────────────────────────────────────────────┐
 │  filename                        (header label) │
 ├───────────────────────┬─────────────────────────┤
 │  Raw JSON (colored)   │  Collapsible tree        │
 │  JsonRawPane          │  JsonTreePane            │
 │                       │  path breadcrumb (SOUTH) │
 ├───────────────────────┴─────────────────────────┤
 │  [ Search: ][_____________][ ▲ ][ ▼ ][ ✕ ] n/m  │
 └─────────────────────────────────────────────────┘
 

The divider starts at 45 % of the panel width so the raw-text side gets a little more room by default — raw JSON tends to be wide while tree nodes tend to be narrow.

Threading

loadFile(File) returns immediately. File I/O and Gson parsing are done on a SwingWorker background thread; both panes are updated on the EDT when parsing completes. Parse errors are displayed inline — the raw pane shows the error message in red and the tree pane is cleared.

Delegation

  • Raw-text colorization and search highlighting are handled by JsonRawPane.
  • Tree construction, path breadcrumb, copy menu, and tree filtering are handled by JsonTreePane.
  • The search field, navigation buttons, and match count are handled by JsonSearchBar, which calls into both panes.
See Also:
  • Constructor Details

    • JsonSplitPane

      public JsonSplitPane()
      Create an empty JsonSplitPane with a "drop a file" prompt in the header, empty content in both halves, and a ready search bar.
  • Method Details

    • getHeader

      public JPanel getHeader()
      Access the header panel, so that it can be added to.
    • loadFile

      public void loadFile(File file)
      Load, parse, and display the given JSON file.

      Returns immediately. File I/O and parsing happen on a background thread; both panes and the search bar are updated on the EDT when the worker finishes. If the file cannot be read or contains invalid JSON the error is shown inline — no dialog is raised.

      Parameters:
      file - the JSON file to display; must not be null