Example usage for javax.swing JLayeredPane JLayeredPane

List of usage examples for javax.swing JLayeredPane JLayeredPane

Introduction

In this page you can find the example usage for javax.swing JLayeredPane JLayeredPane.

Prototype

public JLayeredPane() 

Source Link

Document

Create a new JLayeredPane

Usage

From source file:org.datavyu.controllers.component.MixerController.java

private void initView() {

    // Set default scale values
    minStart = 0;//  ww w  .ja  v a 2  s  .c o m

    listenerList = new EventListenerList();

    // Set up the root panel
    tracksPanel = new JPanel();
    tracksPanel.setLayout(new MigLayout("ins 0", "[left|left|left|left]rel push[right|right]", ""));
    tracksPanel.setBackground(Color.WHITE);

    if (Platform.isMac()) {
        osxGestureListener.register(tracksPanel);
    }

    // Menu buttons
    lockToggle = new JToggleButton("Lock all");
    lockToggle.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            lockToggleHandler(e);
        }
    });
    lockToggle.setName("lockToggleButton");

    bookmarkButton = new JButton("Add Bookmark");
    bookmarkButton.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            addBookmarkHandler();
        }
    });
    bookmarkButton.setEnabled(false);
    bookmarkButton.setName("bookmarkButton");

    JButton snapRegion = new JButton("Snap Region");
    snapRegion.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            snapRegionHandler(e);
        }
    });
    snapRegion.setName("snapRegionButton");

    JButton clearRegion = new JButton("Clear Region");
    clearRegion.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            clearRegionHandler(e);
        }
    });
    clearRegion.setName("clearRegionButton");

    zoomSlide = new JSlider(JSlider.HORIZONTAL, 1, 1000, 1);
    zoomSlide.addChangeListener(new ChangeListener() {
        public void stateChanged(final ChangeEvent e) {

            if (!isUpdatingZoomSlide && zoomSlide.getValueIsAdjusting()) {

                try {
                    isUpdatingZoomSlide = true;
                    zoomSetting = (double) (zoomSlide.getValue() - zoomSlide.getMinimum())
                            / (zoomSlide.getMaximum() - zoomSlide.getMinimum() + 1);
                    viewportModel.setViewportZoom(zoomSetting,
                            needleController.getNeedleModel().getCurrentTime());
                } finally {
                    isUpdatingZoomSlide = false;
                }
            }
        }
    });
    zoomSlide.setName("zoomSlider");
    zoomSlide.setBackground(tracksPanel.getBackground());

    JButton zoomRegionButton = new JButton("", zoomIcon);
    zoomRegionButton.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            zoomToRegion(e);
        }
    });
    zoomRegionButton.setName("zoomRegionButton");

    tracksPanel.add(lockToggle);
    tracksPanel.add(bookmarkButton);
    tracksPanel.add(snapRegion);
    tracksPanel.add(clearRegion);
    tracksPanel.add(zoomRegionButton);
    tracksPanel.add(zoomSlide, "wrap");

    timescaleController = new TimescaleController(mixerModel);
    timescaleController.addTimescaleEventListener(this);
    needleController = new NeedleController(this, mixerModel);
    regionController = new RegionController(mixerModel);
    tracksEditorController = new TracksEditorController(this, mixerModel);

    needleController.setTimescaleTransitionHeight(
            timescaleController.getTimescaleModel().getZoomWindowToTrackTransitionHeight());
    needleController
            .setZoomIndicatorHeight(timescaleController.getTimescaleModel().getZoomWindowIndicatorHeight());

    // Set up the layered pane
    layeredPane = new JLayeredPane();
    layeredPane.setLayout(new MigLayout("fillx, ins 0"));

    final int layeredPaneHeight = 272;
    final int timescaleViewHeight = timescaleController.getTimescaleModel().getHeight();

    final int needleHeadHeight = (int) Math.ceil(NeedleConstants.NEEDLE_HEAD_HEIGHT);
    final int tracksScrollPaneY = needleHeadHeight + 1;
    final int timescaleViewY = layeredPaneHeight - MixerConstants.HSCROLL_HEIGHT - timescaleViewHeight;
    final int tracksScrollPaneHeight = timescaleViewY - tracksScrollPaneY;
    final int tracksScrollBarY = timescaleViewY + timescaleViewHeight;
    final int needleAndRegionMarkerHeight = (timescaleViewY + timescaleViewHeight
            - timescaleController.getTimescaleModel().getZoomWindowIndicatorHeight()
            - timescaleController.getTimescaleModel().getZoomWindowToTrackTransitionHeight() + 1);

    // Set up filler component responsible for horizontal resizing of the
    // layout.
    {

        // Null args; let layout manager handle sizes.
        Box.Filler filler = new Filler(null, null, null);
        filler.setName("Filler");
        filler.addComponentListener(new SizeHandler());

        Map<String, String> constraints = Maps.newHashMap();
        constraints.put("wmin", Integer.toString(MixerConstants.MIXER_MIN_WIDTH));

        // TODO Could probably use this same component to handle vertical
        // resizing...
        String template = "id filler, h 0!, grow 100 0, wmin ${wmin}, cell 0 0 ";
        StrSubstitutor sub = new StrSubstitutor(constraints);

        layeredPane.setLayer(filler, MixerConstants.FILLER_ZORDER);
        layeredPane.add(filler, sub.replace(template), MixerConstants.FILLER_ZORDER);
    }

    // Set up the timescale layout
    {
        JComponent timescaleView = timescaleController.getView();

        Map<String, String> constraints = Maps.newHashMap();
        constraints.put("x", Integer.toString(TimescaleConstants.XPOS_ABS));
        constraints.put("y", Integer.toString(timescaleViewY));

        // Calculate padding from the right
        int rightPad = (int) (RegionConstants.RMARKER_WIDTH + MixerConstants.VSCROLL_WIDTH
                + MixerConstants.R_EDGE_PAD);
        constraints.put("x2", "(filler.w-" + rightPad + ")");
        constraints.put("y2", "(tscale.y+${height})");
        constraints.put("height", Integer.toString(timescaleViewHeight));

        String template = "id tscale, pos ${x} ${y} ${x2} ${y2}";
        StrSubstitutor sub = new StrSubstitutor(constraints);

        // Must call setLayer first.
        layeredPane.setLayer(timescaleView, MixerConstants.TIMESCALE_ZORDER);
        layeredPane.add(timescaleView, sub.replace(template), MixerConstants.TIMESCALE_ZORDER);
    }

    // Set up the scroll pane's layout.
    {
        tracksScrollPane = new JScrollPane(tracksEditorController.getView());
        tracksScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
        tracksScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        tracksScrollPane.setBorder(BorderFactory.createEmptyBorder());
        tracksScrollPane.setName("jScrollPane");

        Map<String, String> constraints = Maps.newHashMap();
        constraints.put("x", "0");
        constraints.put("y", Integer.toString(tracksScrollPaneY));
        constraints.put("x2", "(filler.w-" + MixerConstants.R_EDGE_PAD + ")");
        constraints.put("height", Integer.toString(tracksScrollPaneHeight));

        String template = "pos ${x} ${y} ${x2} n, h ${height}!";
        StrSubstitutor sub = new StrSubstitutor(constraints);

        layeredPane.setLayer(tracksScrollPane, MixerConstants.TRACKS_ZORDER);
        layeredPane.add(tracksScrollPane, sub.replace(template), MixerConstants.TRACKS_ZORDER);
    }

    // Create the region markers and set up the layout.
    {
        JComponent regionView = regionController.getView();

        Map<String, String> constraints = Maps.newHashMap();

        int x = (int) (TrackConstants.HEADER_WIDTH - RegionConstants.RMARKER_WIDTH);
        constraints.put("x", Integer.toString(x));
        constraints.put("y", "0");

        // Padding from the right
        int rightPad = MixerConstants.R_EDGE_PAD + MixerConstants.VSCROLL_WIDTH - 2;

        constraints.put("x2", "(filler.w-" + rightPad + ")");
        constraints.put("height", Integer.toString(needleAndRegionMarkerHeight));

        String template = "pos ${x} ${y} ${x2} n, h ${height}::";
        StrSubstitutor sub = new StrSubstitutor(constraints);

        layeredPane.setLayer(regionView, MixerConstants.REGION_ZORDER);
        layeredPane.add(regionView, sub.replace(template), MixerConstants.REGION_ZORDER);
    }

    // Set up the timing needle's layout
    {
        JComponent needleView = needleController.getView();

        Map<String, String> constraints = Maps.newHashMap();

        int x = (int) (TrackConstants.HEADER_WIDTH - NeedleConstants.NEEDLE_HEAD_WIDTH
                + NeedleConstants.NEEDLE_WIDTH);
        constraints.put("x", Integer.toString(x));
        constraints.put("y", "0");

        // Padding from the right
        int rightPad = MixerConstants.R_EDGE_PAD + MixerConstants.VSCROLL_WIDTH - 1;

        constraints.put("x2", "(filler.w-" + rightPad + ")");
        constraints.put("height",
                Integer.toString(needleAndRegionMarkerHeight
                        + timescaleController.getTimescaleModel().getZoomWindowToTrackTransitionHeight()
                        + timescaleController.getTimescaleModel().getZoomWindowIndicatorHeight() - 1));

        String template = "pos ${x} ${y} ${x2} n, h ${height}::";
        StrSubstitutor sub = new StrSubstitutor(constraints);

        layeredPane.setLayer(needleView, MixerConstants.NEEDLE_ZORDER);
        layeredPane.add(needleView, sub.replace(template), MixerConstants.NEEDLE_ZORDER);
    }

    // Set up the snap marker's layout
    {
        JComponent markerView = tracksEditorController.getMarkerView();

        Map<String, String> constraints = Maps.newHashMap();
        constraints.put("x", Integer.toString(TimescaleConstants.XPOS_ABS));
        constraints.put("y", Integer.toString(needleHeadHeight + 1));

        // Padding from the right
        int rightPad = MixerConstants.R_EDGE_PAD + MixerConstants.VSCROLL_WIDTH - 1;

        constraints.put("x2", "(filler.w-" + rightPad + ")");
        constraints.put("height", Integer.toString(needleAndRegionMarkerHeight - needleHeadHeight - 1));

        String template = "pos ${x} ${y} ${x2} n, h ${height}::";
        StrSubstitutor sub = new StrSubstitutor(constraints);

        layeredPane.setLayer(markerView, MixerConstants.MARKER_ZORDER);
        layeredPane.add(markerView, sub.replace(template), MixerConstants.MARKER_ZORDER);
    }

    // Set up the tracks horizontal scroll bar
    {
        tracksScrollBar = new JScrollBar(Adjustable.HORIZONTAL);
        tracksScrollBar.setValues(0, TRACKS_SCROLL_BAR_RANGE, 0, TRACKS_SCROLL_BAR_RANGE);
        tracksScrollBar.setUnitIncrement(TRACKS_SCROLL_BAR_RANGE / 20);
        tracksScrollBar.setBlockIncrement(TRACKS_SCROLL_BAR_RANGE / 2);
        tracksScrollBar.addAdjustmentListener(this);
        tracksScrollBar.setValueIsAdjusting(false);
        tracksScrollBar.setVisible(false);
        tracksScrollBar.setName("horizontalScrollBar");

        Map<String, String> constraints = Maps.newHashMap();
        constraints.put("x", Integer.toString(TimescaleConstants.XPOS_ABS));
        constraints.put("y", Integer.toString(tracksScrollBarY));

        int rightPad = (int) (RegionConstants.RMARKER_WIDTH + MixerConstants.VSCROLL_WIDTH
                + MixerConstants.R_EDGE_PAD);
        constraints.put("x2", "(filler.w-" + rightPad + ")");
        constraints.put("height", Integer.toString(MixerConstants.HSCROLL_HEIGHT));

        String template = "pos ${x} ${y} ${x2} n, h ${height}::";
        StrSubstitutor sub = new StrSubstitutor(constraints);

        layeredPane.setLayer(tracksScrollBar, MixerConstants.TRACKS_SB_ZORDER);
        layeredPane.add(tracksScrollBar, sub.replace(template), MixerConstants.TRACKS_SB_ZORDER);
    }

    {
        Map<String, String> constraints = Maps.newHashMap();
        constraints.put("span", "6");
        constraints.put("width", Integer.toString(MixerConstants.MIXER_MIN_WIDTH));
        constraints.put("height", Integer.toString(layeredPaneHeight));

        String template = "growx, span ${span}, w ${width}::, h ${height}::, wrap";
        StrSubstitutor sub = new StrSubstitutor(constraints);

        tracksPanel.add(layeredPane, sub.replace(template));
    }

    tracksPanel.validate();
}

From source file:org.photovault.swingui.PhotoViewController.java

/** Creates a new instance of PhotoViewController */
public PhotoViewController(Container view, AbstractController parentController) {
    super(view, parentController);
    photoDAO = getDAOFactory().getPhotoInfoDAO();
    folderDAO = getDAOFactory().getPhotoFolderDAO();
    ImageIcon rotateCWIcon = getIcon("rotate_cw.png");
    ImageIcon rotateCCWIcon = getIcon("rotate_ccw.png");
    ImageIcon rotate180DegIcon = getIcon("rotate_180.png");

    registerAction("rotate_cw", new RotateSelectedPhotoAction(this, 90, "Rotate CW", rotateCWIcon,
            "Rotates the selected photo 90 degrees clockwise", KeyEvent.VK_R));
    registerAction("rotate_ccw", new RotateSelectedPhotoAction(this, 270, "Rotate CCW", rotateCCWIcon,
            "Rotates the selected photo 90 degrees counterclockwise", KeyEvent.VK_L));
    registerAction("rotate_180", new RotateSelectedPhotoAction(this, 180, "Rotate 180 degrees",
            rotate180DegIcon, "Rotates the selected photo 180 degrees counterclockwise", KeyEvent.VK_T));
    registerAction("rotate_180", new RotateSelectedPhotoAction(this, 180, "Rotate 180 degrees",
            rotate180DegIcon, "Rotates the selected photo 180 degrees counterclockwise", KeyEvent.VK_T));
    String qualityStrings[] = { "Unevaluated", "Top", "Good", "OK", "Poor", "Unusable" };
    String qualityIconnames[] = { "quality_unevaluated.png", "quality_top.png", "quality_good.png",
            "quality_ok.png", "quality_poor.png", "quality_unusable.png" };
    KeyStroke qualityAccelerators[] = { null,
            KeyStroke.getKeyStroke(KeyEvent.VK_5, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()),
            KeyStroke.getKeyStroke(KeyEvent.VK_4, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()),
            KeyStroke.getKeyStroke(KeyEvent.VK_3, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()),
            KeyStroke.getKeyStroke(KeyEvent.VK_2, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()),
            KeyStroke.getKeyStroke(KeyEvent.VK_1, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), };
    ImageIcon[] qualityIcons = new ImageIcon[qualityStrings.length];
    for (int n = 0; n < qualityStrings.length; n++) {
        qualityIcons[n] = getIcon(qualityIconnames[n]);
        DataAccessAction qualityAction = new SetPhotoQualityAction(this, n, qualityStrings[n], qualityIcons[n],
                "Set quality of selected phots to \"" + qualityStrings[n] + "\"", null);
        qualityAction.putValue(AbstractAction.ACCELERATOR_KEY, qualityAccelerators[n]);
        registerAction("quality_" + n, qualityAction);

        registerEventListener(TaskFinishedEvent.class, new DefaultEventListener<BackgroundTask>() {

            public void handleEvent(DefaultEvent<BackgroundTask> event) {
                BackgroundTask task = event.getPayload();
                if (task instanceof IndexFileTask) {
                    IndexFileTask ifTask = (IndexFileTask) task;
                    if (ifTask.getResult() == IndexingResult.ERROR
                            || ifTask.getResult() == IndexingResult.NOT_IMAGE) {
                        return;
                    }//from w w  w . ja v a 2 s  . c o  m
                    UUID volId = ifTask.getVolume().getId();
                    FileLocation loc = ifTask.getFileLocation();
                    Set<PhotoInfo> photos = ifTask.getPhotosFound();
                    log.debug("Found file " + loc.getFile() + " in volume " + volId);
                    for (PhotoInfo p : photos) {
                        log.debug("   linked to photo " + p.getUuid());
                    }
                    if (collection instanceof ExtDirPhotos) {
                        ExtDirPhotos dir = (ExtDirPhotos) collection;
                        if (loc.getVolume().getId().equals(dir.getVolId())
                                && loc.getDirName().equals(dir.getDirPath())) {
                            addPhotos(photos);
                            updateThumbView();
                        }
                    }
                }
            }
        });
    }

    // Create the UI controls
    thumbPane = new PhotoCollectionThumbView(this, null);
    thumbPane.addSelectionChangeListener(new SelectionChangeListener() {

        public void selectionChanged(SelectionChangeEvent e) {
            thumbSelectionChanged(e);
        }
    });
    previewPane = new JAIPhotoViewer(this);
    previewPane.getActionMap().put("hide_fullwindow_preview", new HidePhotoPreviewAction(this));
    previewPane.getActionMap().put("move_next", thumbPane.getSelectNextAction());
    previewPane.getActionMap().put("move_prev", thumbPane.getSelectPreviousAction());

    // Create the split pane to display both of these components

    thumbScroll = new JScrollPane(thumbPane);
    thumbPane.setBackground(Color.WHITE);
    thumbScroll.getViewport().setBackground(Color.WHITE);
    thumbScroll.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            handleThumbAreaResize();
        }
    });

    scrollLayer = new JXLayer<JScrollPane>(thumbScroll);
    progressLayer = new ProgressIndicatorLayer();
    scrollLayer.setUI(progressLayer);

    collectionPane = new JPanel();
    splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    layeredPane = new JLayeredPane();
    layeredPane.setLayout(new StackLayout());
    collectionPane.add(splitPane);
    collectionPane.add(layeredPane);
    GridBagLayout layout = new GridBagLayout();
    collectionPane.setLayout(layout);

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.weighty = 1.0;
    c.weightx = 1.0;
    c.gridy = 0;
    // collectionPane.add( scrollLayer );
    layout.setConstraints(splitPane, c);
    layout.setConstraints(layeredPane, c);
    //        collectionPane.add( previewPane );
    thumbPane.setRowHeight(200);
    setLayout(Layout.ONLY_THUMBS);

    /*
    Register action so that we are notified of changes to currently
    displayed folder
     */
    registerEventListener(CommandExecutedEvent.class, new DefaultEventListener<DataAccessCommand>() {

        public void handleEvent(DefaultEvent<DataAccessCommand> event) {
            DataAccessCommand cmd = event.getPayload();
            if (cmd instanceof ChangePhotoInfoCommand) {
                photoChangeCommandExecuted((ChangePhotoInfoCommand) cmd);
            } else if (cmd instanceof CreateCopyImageCommand) {
                imageCreated((CreateCopyImageCommand) cmd);
            } else if (cmd instanceof ApplyChangeCommand) {
                changeApplied((ApplyChangeCommand) cmd);
            }
        }
    });
}

From source file:org.tinymediamanager.ui.MainWindow.java

/**
 * Initialize the contents of the frame.
 *//*from  w  w w.j a v  a 2  s .  c  om*/
private void initialize() {
    // set the logo
    setIconImages(LOGOS);
    setBounds(5, 5, 1100, 727);
    // do nothing, we have our own windowClosing() listener
    // setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    getContentPane().setLayout(new BorderLayout(0, 0));

    JLayeredPane content = new JLayeredPane();
    content.setLayout(new FormLayout(
            new ColumnSpec[] { ColumnSpec.decode("default:grow"), FormFactory.RELATED_GAP_COLSPEC,
                    ColumnSpec.decode("right:270px"), },
            new RowSpec[] { RowSpec.decode("fill:max(500px;default):grow"), }));
    getContentPane().add(content, BorderLayout.CENTER);

    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("default:grow") },
            new RowSpec[] { RowSpec.decode("fill:max(500px;default):grow") }));
    content.add(mainPanel, "1, 1, 3, 1, fill, fill");
    content.setLayer(mainPanel, 1);

    JTabbedPane tabbedPane = VerticalTextIcon.createTabbedPane(JTabbedPane.LEFT);
    tabbedPane.setTabPlacement(JTabbedPane.LEFT);
    mainPanel.add(tabbedPane, "1, 1, fill, fill");
    // getContentPane().add(tabbedPane, "1, 2, fill, fill");

    panelStatusBar = new StatusBar();
    getContentPane().add(panelStatusBar, BorderLayout.SOUTH);

    panelMovies = new MoviePanel();
    VerticalTextIcon.addTab(tabbedPane, BUNDLE.getString("tmm.movies"), panelMovies); //$NON-NLS-1$

    panelMovieSets = new MovieSetPanel();
    VerticalTextIcon.addTab(tabbedPane, BUNDLE.getString("tmm.moviesets"), panelMovieSets); //$NON-NLS-1$

    panelTvShows = new TvShowPanel();
    VerticalTextIcon.addTab(tabbedPane, BUNDLE.getString("tmm.tvshows"), panelTvShows); //$NON-NLS-1$

    // shutdown listener - to clean database connections safely
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            closeTmm();
        }
    });

    MessageManager.instance.addListener(TmmUIMessageCollector.instance);

    // mouse event listener for context menu
    Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
        @Override
        public void eventDispatched(AWTEvent arg0) {
            if (arg0 instanceof MouseEvent && MouseEvent.MOUSE_RELEASED == arg0.getID()
                    && arg0.getSource() instanceof JTextComponent) {
                MouseEvent me = (MouseEvent) arg0;
                JTextComponent tc = (JTextComponent) arg0.getSource();
                if (me.isPopupTrigger() && tc.getComponentPopupMenu() == null) {
                    TextFieldPopupMenu.buildCutCopyPaste().show(tc, me.getX(), me.getY());
                }
            }
        }
    }, AWTEvent.MOUSE_EVENT_MASK);

    // temp info for users using Java 6
    if (SystemUtils.IS_JAVA_1_6) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                JOptionPane.showMessageDialog(MainWindow.this, BUNDLE.getString("tmm.java6")); //$NON-NLS-1$
            }
        });
    }

    // inform user is MI could not be loaded
    if (Platform.isLinux() && StringUtils.isBlank(MediaInfo.version())) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                JOptionPane.showMessageDialog(MainWindow.this, BUNDLE.getString("mediainfo.failed.linux")); //$NON-NLS-1$
            }
        });
    }
}

From source file:org.tinymediamanager.ui.movies.MoviePanel.java

/**
 * Create the panel./* w w  w.  j av a  2 s  .co  m*/
 */
public MoviePanel() {
    super();
    // load movielist
    LOGGER.debug("loading MovieList");
    movieList = MovieList.getInstance();
    sortedMovies = new SortedList<>(GlazedListsSwing.swingThreadProxyList(movieList.getMovies()),
            new MovieComparator());
    sortedMovies.setMode(SortedList.AVOID_MOVING_ELEMENTS);

    // build menu
    menu = new JMenu(BUNDLE.getString("tmm.movies")); //$NON-NLS-1$
    JFrame mainFrame = MainWindow.getFrame();
    JMenuBar menuBar = mainFrame.getJMenuBar();
    menuBar.add(menu);

    setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("850px:grow"),
                    FormFactory.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("500px:grow"), }));

    splitPaneHorizontal = new JSplitPane();
    splitPaneHorizontal.setContinuousLayout(true);
    add(splitPaneHorizontal, "2, 2, fill, fill");

    JPanel panelMovieList = new JPanel();
    splitPaneHorizontal.setLeftComponent(panelMovieList);
    panelMovieList.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                    ColumnSpec.decode("default:grow"), FormFactory.RELATED_GAP_COLSPEC,
                    FormFactory.DEFAULT_COLSPEC, },
            new RowSpec[] { RowSpec.decode("26px"), FormFactory.RELATED_GAP_ROWSPEC,
                    RowSpec.decode("fill:max(200px;default):grow"), FormFactory.RELATED_GAP_ROWSPEC,
                    FormFactory.DEFAULT_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, }));

    JToolBar toolBar = new JToolBar();
    toolBar.setRollover(true);
    toolBar.setFloatable(false);
    toolBar.setOpaque(false);
    panelMovieList.add(toolBar, "2, 1, left, fill");

    // udpate datasource
    // toolBar.add(actionUpdateDataSources);
    final JSplitButton buttonUpdateDatasource = new JSplitButton(IconManager.REFRESH);
    // temp fix for size of the button
    buttonUpdateDatasource.setText("   ");
    buttonUpdateDatasource.setHorizontalAlignment(JButton.LEFT);
    // buttonScrape.setMargin(new Insets(2, 2, 2, 24));
    buttonUpdateDatasource.setSplitWidth(18);
    buttonUpdateDatasource.setToolTipText(BUNDLE.getString("update.datasource")); //$NON-NLS-1$
    buttonUpdateDatasource.addSplitButtonActionListener(new SplitButtonActionListener() {
        public void buttonClicked(ActionEvent e) {
            actionUpdateDataSources.actionPerformed(e);
        }

        public void splitButtonClicked(ActionEvent e) {
            // build the popupmenu on the fly
            buttonUpdateDatasource.getPopupMenu().removeAll();
            JMenuItem item = new JMenuItem(actionUpdateDataSources2);
            buttonUpdateDatasource.getPopupMenu().add(item);
            buttonUpdateDatasource.getPopupMenu().addSeparator();
            for (String ds : MovieModuleManager.MOVIE_SETTINGS.getMovieDataSource()) {
                buttonUpdateDatasource.getPopupMenu()
                        .add(new JMenuItem(new MovieUpdateSingleDatasourceAction(ds)));
            }

            buttonUpdateDatasource.getPopupMenu().pack();
        }
    });

    JPopupMenu popup = new JPopupMenu("popup");
    buttonUpdateDatasource.setPopupMenu(popup);
    toolBar.add(buttonUpdateDatasource);

    JSplitButton buttonScrape = new JSplitButton(IconManager.SEARCH);
    // temp fix for size of the button
    buttonScrape.setText("   ");
    buttonScrape.setHorizontalAlignment(JButton.LEFT);
    // buttonScrape.setMargin(new Insets(2, 2, 2, 24));
    buttonScrape.setSplitWidth(18);
    buttonScrape.setToolTipText(BUNDLE.getString("movie.scrape.selected")); //$NON-NLS-1$

    // register for listener
    buttonScrape.addSplitButtonActionListener(new SplitButtonActionListener() {
        public void buttonClicked(ActionEvent e) {
            actionScrape.actionPerformed(e);
        }

        public void splitButtonClicked(ActionEvent e) {
        }
    });

    popup = new JPopupMenu("popup");
    JMenuItem item = new JMenuItem(actionScrape2);
    popup.add(item);
    item = new JMenuItem(actionScrapeUnscraped);
    popup.add(item);
    item = new JMenuItem(actionScrapeSelected);
    popup.add(item);
    buttonScrape.setPopupMenu(popup);
    toolBar.add(buttonScrape);

    toolBar.add(actionEditMovie);

    btnRen = new JButton("REN");
    btnRen.setAction(actionRename);
    toolBar.add(btnRen);

    btnMediaInformation = new JButton("MI");
    btnMediaInformation.setAction(actionMediaInformation);
    toolBar.add(btnMediaInformation);

    JButton btnCreateOflline = new JButton();
    btnCreateOflline.setAction(new MovieCreateOfflineAction(false));
    toolBar.add(btnCreateOflline);

    textField = EnhancedTextField.createSearchTextField();
    panelMovieList.add(textField, "3, 1, right, bottom");
    textField.setColumns(13);

    // table = new JTable();
    // build JTable

    MatcherEditor<Movie> textMatcherEditor = new TextComponentMatcherEditor<>(textField, new MovieFilterator());
    MovieMatcherEditor movieMatcherEditor = new MovieMatcherEditor();
    FilterList<Movie> extendedFilteredMovies = new FilterList<>(sortedMovies, movieMatcherEditor);
    textFilteredMovies = new FilterList<>(extendedFilteredMovies, textMatcherEditor);
    movieSelectionModel = new MovieSelectionModel(sortedMovies, textFilteredMovies, movieMatcherEditor);
    movieTableModel = new DefaultEventTableModel<>(GlazedListsSwing.swingThreadProxyList(textFilteredMovies),
            new MovieTableFormat());
    table = new ZebraJTable(movieTableModel);

    movieTableModel.addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent arg0) {
            lblMovieCountFiltered.setText(String.valueOf(movieTableModel.getRowCount()));
            // select first movie if nothing is selected
            ListSelectionModel selectionModel = table.getSelectionModel();
            if (selectionModel.isSelectionEmpty() && movieTableModel.getRowCount() > 0) {
                selectionModel.setSelectionInterval(0, 0);
            }
            if (selectionModel.isSelectionEmpty() && movieTableModel.getRowCount() == 0) {
                movieSelectionModel.setSelectedMovie(null);
            }
        }
    });

    // install and save the comparator on the Table
    movieSelectionModel.setTableComparatorChooser(
            TableComparatorChooser.install(table, sortedMovies, TableComparatorChooser.SINGLE_COLUMN));

    // table = new MyTable();
    table.setNewFontSize((float) ((int) Math.round(getFont().getSize() * 0.916)));
    // scrollPane.setViewportView(table);

    // JScrollPane scrollPane = new JScrollPane(table);
    JScrollPane scrollPane = ZebraJTable.createStripedJScrollPane(table);
    panelMovieList.add(scrollPane, "2, 3, 4, 1, fill, fill");

    {
        final JToggleButton filterButton = new JToggleButton(IconManager.FILTER);
        filterButton.setToolTipText(BUNDLE.getString("movieextendedsearch.options")); //$NON-NLS-1$
        panelMovieList.add(filterButton, "5, 1, right, bottom");

        // add a propertychangelistener which reacts on setting a filter
        movieSelectionModel.addPropertyChangeListener(new PropertyChangeListener() {
            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                if ("filterChanged".equals(evt.getPropertyName())) {
                    if (Boolean.TRUE.equals(evt.getNewValue())) {
                        filterButton.setIcon(IconManager.FILTER_ACTIVE);
                        filterButton.setToolTipText(BUNDLE.getString("movieextendedsearch.options.active")); //$NON-NLS-1$
                    } else {
                        filterButton.setIcon(IconManager.FILTER);
                        filterButton.setToolTipText(BUNDLE.getString("movieextendedsearch.options")); //$NON-NLS-1$
                    }
                }
            }
        });

        panelExtendedSearch = new MovieExtendedSearchPanel(movieSelectionModel);
        panelExtendedSearch.setVisible(false);
        // panelMovieList.add(panelExtendedSearch, "2, 5, 2, 1, fill, fill");
        filterButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                if (panelExtendedSearch.isVisible() == true) {
                    panelExtendedSearch.setVisible(false);
                } else {
                    panelExtendedSearch.setVisible(true);
                }
            }
        });
    }

    JPanel panelStatus = new JPanel();
    panelMovieList.add(panelStatus, "2, 6, 2, 1");
    panelStatus.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("1px"),
                    ColumnSpec.decode("146px:grow"), FormFactory.RELATED_GAP_COLSPEC,
                    ColumnSpec.decode("default:grow"), },
            new RowSpec[] { RowSpec.decode("fill:default:grow"), }));

    panelMovieCount = new JPanel();
    panelStatus.add(panelMovieCount, "3, 1, left, fill");

    lblMovieCount = new JLabel(BUNDLE.getString("tmm.movies") + ":"); //$NON-NLS-1$
    panelMovieCount.add(lblMovieCount);

    lblMovieCountFiltered = new JLabel("");
    panelMovieCount.add(lblMovieCountFiltered);

    lblMovieCountOf = new JLabel(BUNDLE.getString("tmm.of")); //$NON-NLS-1$
    panelMovieCount.add(lblMovieCountOf);

    lblMovieCountTotal = new JLabel("");
    panelMovieCount.add(lblMovieCountTotal);

    JLayeredPane layeredPaneRight = new JLayeredPane();
    layeredPaneRight.setLayout(
            new FormLayout(new ColumnSpec[] { ColumnSpec.decode("default"), ColumnSpec.decode("default:grow") },
                    new RowSpec[] { RowSpec.decode("default"), RowSpec.decode("default:grow") }));
    panelRight = new MovieInformationPanel(movieSelectionModel);
    layeredPaneRight.add(panelRight, "1, 1, 2, 2, fill, fill");
    layeredPaneRight.setLayer(panelRight, 0);

    // glass pane
    layeredPaneRight.add(panelExtendedSearch, "1, 1, fill, fill");
    layeredPaneRight.setLayer(panelExtendedSearch, 1);

    splitPaneHorizontal.setRightComponent(layeredPaneRight);
    splitPaneHorizontal.setContinuousLayout(true);

    // beansbinding init
    initDataBindings();

    addComponentListener(new ComponentAdapter() {
        @Override
        public void componentHidden(ComponentEvent e) {
            menu.setVisible(false);
            super.componentHidden(e);
        }

        @Override
        public void componentShown(ComponentEvent e) {
            menu.setVisible(true);
            super.componentHidden(e);
        }
    });

    // further initializations
    init();

    // filter
    if (MovieModuleManager.MOVIE_SETTINGS.isStoreUiFilters()) {
        movieList.searchDuplicates();
        movieSelectionModel.filterMovies(MovieModuleManager.MOVIE_SETTINGS.getUiFilters());
    }
}

From source file:org.tinymediamanager.ui.moviesets.MovieSetInformationPanel.java

/**
 * Instantiates a new movie set information panel.
 * /*from  w ww . j  a v  a2 s.  co m*/
 * @param model
 *          the model
 */
public MovieSetInformationPanel(MovieSetSelectionModel model) {
    this.selectionModel = model;
    movieEventList = new ObservableElementList<>(
            GlazedListsSwing.swingThreadProxyList(new BasicEventList<Movie>()),
            GlazedLists.beanConnector(Movie.class));

    setLayout(new BorderLayout(0, 0));

    panel = new JPanel();
    add(panel, BorderLayout.CENTER);
    panel.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("180px:grow"),
                    ColumnSpec.decode("1px"), },
            new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC,
                    RowSpec.decode("pref:grow"), RowSpec.decode("bottom:default"), }));

    lblMovieSetName = new JLabel("");
    TmmFontHelper.changeFont(lblMovieSetName, 1.5, Font.BOLD);
    panel.add(lblMovieSetName, "2,1, fill, fill");

    layeredPane = new JLayeredPane();
    panel.add(layeredPane, "1, 3, 2, 1, fill, fill");
    layeredPane.setLayout(new FormLayout(
            new ColumnSpec[] { ColumnSpec.decode("10px"), ColumnSpec.decode("120px"),
                    ColumnSpec.decode("200px:grow"), },
            new RowSpec[] { RowSpec.decode("10px"), RowSpec.decode("180px"),
                    RowSpec.decode("default:grow"), }));

    lblMovieSetPoster = new ImageLabel();
    lblMovieSetPoster.setAlternativeText(BUNDLE.getString("image.notfound.poster")); //$NON-NLS-1$
    lblMovieSetPoster.enableLightbox();
    layeredPane.setLayer(lblMovieSetPoster, 1);
    layeredPane.add(lblMovieSetPoster, "2, 2, fill, fill");

    lblMovieSetFanart = new ImageLabel(false, true);
    lblMovieSetFanart.setAlternativeText(BUNDLE.getString("image.notfound.fanart")); //$NON-NLS-1$
    lblMovieSetFanart.enableLightbox();
    layeredPane.add(lblMovieSetFanart, "1, 1, 3, 3, fill, fill");

    panelSouth = new JSplitPane();
    panelSouth.setContinuousLayout(true);
    panelSouth.setResizeWeight(0.5);
    add(panelSouth, BorderLayout.SOUTH);

    panelOverview = new JPanel();
    panelSouth.setLeftComponent(panelOverview);
    panelOverview.setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("100px:grow"), },
            new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("24px:grow"), }));

    lblOverview = new JLabel(BUNDLE.getString("metatag.plot")); //$NON-NLS-1$
    panelOverview.add(lblOverview, "1, 2");

    scrollPaneOverview = new JScrollPane();
    panelOverview.add(scrollPaneOverview, "1, 4, fill, fill");

    tpOverview = new JTextPane();
    tpOverview.setEditable(false);
    scrollPaneOverview.setViewportView(tpOverview);

    JPanel panelMovies = new JPanel();
    panelSouth.setRightComponent(panelMovies);
    panelMovies.setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("200px:grow(3)"), },
            new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, RowSpec.decode("203px:grow"), }));

    movieTableModel = new DefaultEventTableModel<>(GlazedListsSwing.swingThreadProxyList(movieEventList),
            new MovieInMovieSetTableFormat());
    // tableAssignedMovies = new JTable(movieTableModel);
    tableAssignedMovies = new ZebraJTable(movieTableModel);
    // JScrollPane scrollPaneMovies = new JScrollPane();
    JScrollPane scrollPaneMovies = ZebraJTable.createStripedJScrollPane(tableAssignedMovies);
    panelMovies.add(scrollPaneMovies, "1, 2, fill, fill");

    tableAssignedMovies.setPreferredScrollableViewportSize(new Dimension(450, 200));
    scrollPaneMovies.setViewportView(tableAssignedMovies);

    initDataBindings();

    // adjust table columns
    // year column
    int width = tableAssignedMovies.getFontMetrics(tableAssignedMovies.getFont()).stringWidth(" 2000");
    int titleWidth = tableAssignedMovies.getFontMetrics(tableAssignedMovies.getFont())
            .stringWidth(BUNDLE.getString("metatag.year")); //$NON-NLS-1$
    if (titleWidth > width) {
        width = titleWidth;
    }
    tableAssignedMovies.getTableHeader().getColumnModel().getColumn(1).setPreferredWidth(width);
    tableAssignedMovies.getTableHeader().getColumnModel().getColumn(1).setMinWidth(width);
    tableAssignedMovies.getTableHeader().getColumnModel().getColumn(1).setMaxWidth((int) (width * 1.5));

    // watched column
    tableAssignedMovies.getTableHeader().getColumnModel().getColumn(2).setPreferredWidth(70);
    tableAssignedMovies.getTableHeader().getColumnModel().getColumn(2).setMinWidth(70);
    tableAssignedMovies.getTableHeader().getColumnModel().getColumn(2).setMaxWidth(85);

    // install the propertychangelistener
    PropertyChangeListener propertyChangeListener = new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
            String property = propertyChangeEvent.getPropertyName();
            Object source = propertyChangeEvent.getSource();
            // react on selection of a movie and change of media files
            if ((source.getClass() == MovieSetSelectionModel.class && "selectedMovieSet".equals(property))
                    || (source.getClass() == MovieSet.class && "movies".equals(property))) {
                movieEventList.clear();
                movieEventList.addAll(selectionModel.getSelectedMovieSet().getMovies());
                if (StringUtils.isNotBlank(
                        selectionModel.getSelectedMovieSet().getArtworkFilename(MediaFileType.POSTER))) {
                    lblMovieSetPoster.setImagePath(
                            selectionModel.getSelectedMovieSet().getArtworkFilename(MediaFileType.POSTER));
                } else {
                    lblMovieSetPoster.setImagePath("");
                    lblMovieSetPoster.setImageUrl(
                            selectionModel.getSelectedMovieSet().getArtworkUrl(MediaFileType.POSTER));
                }
                if (StringUtils.isNotBlank(
                        selectionModel.getSelectedMovieSet().getArtworkFilename(MediaFileType.FANART))) {
                    lblMovieSetFanart.setImagePath(
                            selectionModel.getSelectedMovieSet().getArtworkFilename(MediaFileType.FANART));
                } else {
                    lblMovieSetFanart.setImagePath("");
                    lblMovieSetFanart.setImageUrl(
                            selectionModel.getSelectedMovieSet().getArtworkUrl(MediaFileType.FANART));
                }
            }

            // react on changes of the images
            if ((source.getClass() == MovieSet.class && FANART.equals(property))) {
                MovieSet movieSet = (MovieSet) source;
                lblMovieSetFanart.clearImage();
                lblMovieSetFanart.setImagePath(movieSet.getArtworkFilename(MediaFileType.FANART));
            }
            if ((source.getClass() == MovieSet.class && POSTER.equals(property))) {
                MovieSet movieSet = (MovieSet) source;
                lblMovieSetPoster.clearImage();
                lblMovieSetPoster.setImagePath(movieSet.getArtworkFilename(MediaFileType.POSTER));
            }
        }
    };

    selectionModel.addPropertyChangeListener(propertyChangeListener);
}

From source file:org.tinymediamanager.ui.tvshows.TvShowPanel.java

/**
 * Instantiates a new tv show panel.//ww w  . j a v a 2 s . c  o  m
 */
public TvShowPanel() {
    super();

    treeModel = new TvShowTreeModel(tvShowList.getTvShows());
    tvShowSeasonSelectionModel = new TvShowSeasonSelectionModel();
    tvShowEpisodeSelectionModel = new TvShowEpisodeSelectionModel();

    // build menu
    menu = new JMenu(BUNDLE.getString("tmm.tvshows")); //$NON-NLS-1$
    JFrame mainFrame = MainWindow.getFrame();
    JMenuBar menuBar = mainFrame.getJMenuBar();
    menuBar.add(menu);

    setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("850px:grow"),
                    FormFactory.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), }));

    JSplitPane splitPane = new JSplitPane();
    splitPane.setContinuousLayout(true);
    add(splitPane, "2, 2, fill, fill");

    JPanel panelTvShowTree = new JPanel();
    splitPane.setLeftComponent(panelTvShowTree);
    panelTvShowTree.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                    FormFactory.UNRELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                    FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, },
            new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC,
                    RowSpec.decode("3px:grow"), FormFactory.RELATED_GAP_ROWSPEC,
                    FormFactory.DEFAULT_ROWSPEC, }));

    textField = EnhancedTextField.createSearchTextField();
    panelTvShowTree.add(textField, "4, 1, right, bottom");
    textField.setColumns(12);
    textField.getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void insertUpdate(final DocumentEvent e) {
            applyFilter();
        }

        @Override
        public void removeUpdate(final DocumentEvent e) {
            applyFilter();
        }

        @Override
        public void changedUpdate(final DocumentEvent e) {
            applyFilter();
        }

        public void applyFilter() {
            TvShowTreeModel filteredModel = (TvShowTreeModel) tree.getModel();
            if (StringUtils.isNotBlank(textField.getText())) {
                filteredModel.setFilter(SearchOptions.TEXT, textField.getText());
            } else {
                filteredModel.removeFilter(SearchOptions.TEXT);
            }

            filteredModel.filter(tree);
        }
    });

    final JToggleButton btnFilter = new JToggleButton(IconManager.FILTER);
    btnFilter.setToolTipText(BUNDLE.getString("movieextendedsearch.options")); //$NON-NLS-1$
    panelTvShowTree.add(btnFilter, "6, 1, default, bottom");

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    panelTvShowTree.add(scrollPane, "2, 3, 5, 1, fill, fill");

    JToolBar toolBar = new JToolBar();
    toolBar.setRollover(true);
    toolBar.setFloatable(false);
    toolBar.setOpaque(false);
    panelTvShowTree.add(toolBar, "2, 1");

    // toolBar.add(actionUpdateDatasources);
    final JSplitButton buttonUpdateDatasource = new JSplitButton(IconManager.REFRESH);
    // temp fix for size of the button
    buttonUpdateDatasource.setText("   ");
    buttonUpdateDatasource.setHorizontalAlignment(JButton.LEFT);
    // buttonScrape.setMargin(new Insets(2, 2, 2, 24));
    buttonUpdateDatasource.setSplitWidth(18);
    buttonUpdateDatasource.setToolTipText(BUNDLE.getString("update.datasource")); //$NON-NLS-1$
    buttonUpdateDatasource.addSplitButtonActionListener(new SplitButtonActionListener() {
        public void buttonClicked(ActionEvent e) {
            actionUpdateDatasources.actionPerformed(e);
        }

        public void splitButtonClicked(ActionEvent e) {
            // build the popupmenu on the fly
            buttonUpdateDatasource.getPopupMenu().removeAll();
            buttonUpdateDatasource.getPopupMenu().add(new JMenuItem(actionUpdateDatasources2));
            buttonUpdateDatasource.getPopupMenu().addSeparator();
            for (String ds : TvShowModuleManager.SETTINGS.getTvShowDataSource()) {
                buttonUpdateDatasource.getPopupMenu()
                        .add(new JMenuItem(new TvShowUpdateSingleDatasourceAction(ds)));
            }
            buttonUpdateDatasource.getPopupMenu().addSeparator();
            buttonUpdateDatasource.getPopupMenu().add(new JMenuItem(actionUpdateTvShow));
            buttonUpdateDatasource.getPopupMenu().pack();
        }
    });

    JPopupMenu popup = new JPopupMenu("popup");
    buttonUpdateDatasource.setPopupMenu(popup);
    toolBar.add(buttonUpdateDatasource);

    JSplitButton buttonScrape = new JSplitButton(IconManager.SEARCH);
    // temp fix for size of the button
    buttonScrape.setText("   ");
    buttonScrape.setHorizontalAlignment(JButton.LEFT);
    buttonScrape.setSplitWidth(18);
    buttonScrape.setToolTipText(BUNDLE.getString("tvshow.scrape.selected")); //$NON-NLS-1$

    // register for listener
    buttonScrape.addSplitButtonActionListener(new SplitButtonActionListener() {
        @Override
        public void buttonClicked(ActionEvent e) {
            actionScrape.actionPerformed(e);
        }

        @Override
        public void splitButtonClicked(ActionEvent e) {
        }
    });

    popup = new JPopupMenu("popup");
    JMenuItem item = new JMenuItem(actionScrape2);
    popup.add(item);
    // item = new JMenuItem(actionScrapeUnscraped);
    // popup.add(item);
    item = new JMenuItem(actionScrapeSelected);
    popup.add(item);
    item = new JMenuItem(actionScrapeNewItems);
    popup.add(item);
    buttonScrape.setPopupMenu(popup);
    toolBar.add(buttonScrape);
    toolBar.add(actionEdit);

    JButton btnMediaInformation = new JButton();
    btnMediaInformation.setAction(actionMediaInformation);
    toolBar.add(btnMediaInformation);

    // install drawing of full with
    tree = new ZebraJTree(treeModel) {
        private static final long serialVersionUID = 2422163883324014637L;

        @Override
        public void paintComponent(Graphics g) {
            width = this.getWidth();
            super.paintComponent(g);
        }
    };
    tvShowSelectionModel = new TvShowSelectionModel(tree);

    TreeUI ui = new TreeUI() {
        @Override
        protected void paintRow(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds,
                TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf) {
            bounds.width = width - bounds.x;
            super.paintRow(g, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf);
        }
    };
    tree.setUI(ui);

    tree.setRootVisible(false);
    tree.setShowsRootHandles(true);
    tree.setCellRenderer(new TvShowTreeCellRenderer());
    tree.setRowHeight(0);
    scrollPane.setViewportView(tree);

    JPanel panelHeader = new JPanel() {
        private static final long serialVersionUID = -6914183798172482157L;

        @Override
        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            JTattooUtilities.fillHorGradient(g, AbstractLookAndFeel.getTheme().getColHeaderColors(), 0, 0,
                    getWidth(), getHeight());
        }
    };
    scrollPane.setColumnHeaderView(panelHeader);
    panelHeader.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                    FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("center:20px"),
                    ColumnSpec.decode("center:20px"), ColumnSpec.decode("center:20px") },
            new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, }));

    JLabel lblTvShowsColumn = new JLabel(BUNDLE.getString("metatag.tvshow")); //$NON-NLS-1$
    lblTvShowsColumn.setHorizontalAlignment(JLabel.CENTER);
    panelHeader.add(lblTvShowsColumn, "2, 1");

    JLabel lblNfoColumn = new JLabel("");
    lblNfoColumn.setHorizontalAlignment(JLabel.CENTER);
    lblNfoColumn.setIcon(IconManager.INFO);
    lblNfoColumn.setToolTipText(BUNDLE.getString("metatag.nfo"));//$NON-NLS-1$
    panelHeader.add(lblNfoColumn, "4, 1");

    JLabel lblImageColumn = new JLabel("");
    lblImageColumn.setHorizontalAlignment(JLabel.CENTER);
    lblImageColumn.setIcon(IconManager.IMAGE);
    lblImageColumn.setToolTipText(BUNDLE.getString("metatag.images"));//$NON-NLS-1$
    panelHeader.add(lblImageColumn, "5, 1");

    JLabel lblSubtitleColumn = new JLabel("");
    lblSubtitleColumn.setHorizontalAlignment(JLabel.CENTER);
    lblSubtitleColumn.setIcon(IconManager.SUBTITLE);
    lblSubtitleColumn.setToolTipText(BUNDLE.getString("metatag.subtitles"));//$NON-NLS-1$
    panelHeader.add(lblSubtitleColumn, "6, 1");

    JPanel panel = new JPanel();
    panelTvShowTree.add(panel, "2, 5, 3, 1, fill, fill");
    panel.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC,
                    FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                    FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                    FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, },
            new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, }));

    JLabel lblTvShowsT = new JLabel(BUNDLE.getString("metatag.tvshows") + ":"); //$NON-NLS-1$
    panel.add(lblTvShowsT, "1, 2, fill, fill");

    lblTvShows = new JLabel("");
    panel.add(lblTvShows, "3, 2");

    JLabel labelSlash = new JLabel("/");
    panel.add(labelSlash, "5, 2");

    JLabel lblEpisodesT = new JLabel(BUNDLE.getString("metatag.episodes") + ":"); //$NON-NLS-1$
    panel.add(lblEpisodesT, "7, 2");

    lblEpisodes = new JLabel("");
    panel.add(lblEpisodes, "9, 2");

    JLayeredPane layeredPaneRight = new JLayeredPane();
    layeredPaneRight.setLayout(
            new FormLayout(new ColumnSpec[] { ColumnSpec.decode("default"), ColumnSpec.decode("default:grow") },
                    new RowSpec[] { RowSpec.decode("default"), RowSpec.decode("default:grow") }));
    panelRight = new JPanel();
    layeredPaneRight.add(panelRight, "1, 1, 2, 2, fill, fill");
    layeredPaneRight.setLayer(panelRight, 0);

    // glass pane
    final TvShowExtendedSearchPanel panelExtendedSearch = new TvShowExtendedSearchPanel(treeModel, tree);
    panelExtendedSearch.setVisible(false);
    // panelMovieList.add(panelExtendedSearch, "2, 5, 2, 1, fill, fill");
    btnFilter.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            if (panelExtendedSearch.isVisible() == true) {
                panelExtendedSearch.setVisible(false);
            } else {
                panelExtendedSearch.setVisible(true);
            }
        }
    });
    // add a propertychangelistener which reacts on setting a filter
    tree.addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if ("filterChanged".equals(evt.getPropertyName())) {
                if (Boolean.TRUE.equals(evt.getNewValue())) {
                    btnFilter.setIcon(IconManager.FILTER_ACTIVE);
                    btnFilter.setToolTipText(BUNDLE.getString("movieextendedsearch.options.active")); //$NON-NLS-1$
                } else {
                    btnFilter.setIcon(IconManager.FILTER);
                    btnFilter.setToolTipText(BUNDLE.getString("movieextendedsearch.options")); //$NON-NLS-1$
                }
            }
        }
    });
    layeredPaneRight.add(panelExtendedSearch, "1, 1, fill, fill");
    layeredPaneRight.setLayer(panelExtendedSearch, 1);

    splitPane.setRightComponent(layeredPaneRight);
    panelRight.setLayout(new CardLayout(0, 0));

    JPanel panelTvShow = new TvShowInformationPanel(tvShowSelectionModel);
    panelRight.add(panelTvShow, "tvShow");

    JPanel panelTvShowSeason = new TvShowSeasonInformationPanel(tvShowSeasonSelectionModel);
    panelRight.add(panelTvShowSeason, "tvShowSeason");

    JPanel panelTvShowEpisode = new TvShowEpisodeInformationPanel(tvShowEpisodeSelectionModel);
    panelRight.add(panelTvShowEpisode, "tvShowEpisode");

    tree.addTreeSelectionListener(new TreeSelectionListener() {
        @Override
        public void valueChanged(TreeSelectionEvent e) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
            if (node != null) {
                // click on a tv show
                if (node.getUserObject() instanceof TvShow) {
                    TvShow tvShow = (TvShow) node.getUserObject();
                    tvShowSelectionModel.setSelectedTvShow(tvShow);
                    CardLayout cl = (CardLayout) (panelRight.getLayout());
                    cl.show(panelRight, "tvShow");
                }

                // click on a season
                if (node.getUserObject() instanceof TvShowSeason) {
                    TvShowSeason tvShowSeason = (TvShowSeason) node.getUserObject();
                    tvShowSeasonSelectionModel.setSelectedTvShowSeason(tvShowSeason);
                    CardLayout cl = (CardLayout) (panelRight.getLayout());
                    cl.show(panelRight, "tvShowSeason");
                }

                // click on an episode
                if (node.getUserObject() instanceof TvShowEpisode) {
                    TvShowEpisode tvShowEpisode = (TvShowEpisode) node.getUserObject();
                    tvShowEpisodeSelectionModel.setSelectedTvShowEpisode(tvShowEpisode);
                    CardLayout cl = (CardLayout) (panelRight.getLayout());
                    cl.show(panelRight, "tvShowEpisode");
                }
            } else {
                // check if there is at least one tv show in the model
                TvShowRootTreeNode root = (TvShowRootTreeNode) tree.getModel().getRoot();
                if (root.getChildCount() == 0) {
                    // sets an inital show
                    tvShowSelectionModel.setSelectedTvShow(null);
                }
            }
        }
    });

    addComponentListener(new ComponentAdapter() {
        @Override
        public void componentHidden(ComponentEvent e) {
            menu.setVisible(false);
            super.componentHidden(e);
        }

        @Override
        public void componentShown(ComponentEvent e) {
            menu.setVisible(true);
            super.componentHidden(e);
        }
    });

    // further initializations
    init();
    initDataBindings();

    // selecting first TV show at startup
    if (tvShowList.getTvShows() != null && tvShowList.getTvShows().size() > 0) {
        DefaultMutableTreeNode firstLeaf = (DefaultMutableTreeNode) ((DefaultMutableTreeNode) tree.getModel()
                .getRoot()).getFirstChild();
        tree.setSelectionPath(new TreePath(((DefaultMutableTreeNode) firstLeaf.getParent()).getPath()));
        tree.setSelectionPath(new TreePath(firstLeaf.getPath()));
    }
}

From source file:org.zaproxy.zap.extension.cmss.CMSSFrame.java

/** Create the frame. */
public CMSSFrame() {
    setTitle("Fingerprinting tools");
    setResizable(false);// www .  j a  v  a  2 s .  c  o  m
    setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
    setBounds(100, 100, 756, 372);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    contentPane.setLayout(new BorderLayout(0, 0));
    setContentPane(contentPane);

    JLayeredPane layeredPane = new JLayeredPane();
    contentPane.add(layeredPane, BorderLayout.CENTER);

    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    tabbedPane.setBounds(0, 0, 725, 323);
    layeredPane.add(tabbedPane);

    JLayeredPane layeredPane_1 = new JLayeredPane();
    tabbedPane.addTab("Fingerprint", null, layeredPane_1, null);

    JLabel label = new JLabel("App name:");
    label.setBounds(35, 188, 76, 14);
    layeredPane_1.add(label);

    JLabel label_1 = new JLabel("Version:");
    label_1.setBounds(35, 230, 76, 14);
    layeredPane_1.add(label_1);

    textField = new JTextField();
    textField.setColumns(10);
    textField.setBounds(121, 188, 109, 29);
    layeredPane_1.add(textField);

    textField_1 = new JTextField();
    textField_1.setColumns(10);
    textField_1.setBounds(121, 223, 109, 29);
    layeredPane_1.add(textField_1);

    JSeparator separator = new JSeparator();
    separator.setBounds(35, 72, 665, 2);
    layeredPane_1.add(separator);

    JSeparator separator_1 = new JSeparator();
    separator_1.setBounds(196, 11, 1, 201);
    layeredPane_1.add(separator_1);

    JSeparator separator_2 = new JSeparator();
    separator_2.setOrientation(SwingConstants.VERTICAL);
    separator_2.setBounds(260, 81, 1, 201);
    layeredPane_1.add(separator_2);

    final JCheckBox chckbxGetVersion = new JCheckBox("Get version");
    chckbxGetVersion.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            if (textField_1.isEnabled() && !chckbxGetVersion.isSelected())
                textField_1.setEnabled(false);
            if (!textField_1.isEnabled() && chckbxGetVersion.isSelected())
                textField_1.setEnabled(true);
        }
    });
    chckbxGetVersion.setBounds(35, 81, 195, 23);
    layeredPane_1.add(chckbxGetVersion);

    final JCheckBox chckbxPassiveFingerprinting = new JCheckBox("Passive");
    chckbxPassiveFingerprinting.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
        }
    });
    chckbxPassiveFingerprinting.setBounds(35, 107, 195, 23);
    chckbxPassiveFingerprinting.setSelected(true); //
    layeredPane_1.add(chckbxPassiveFingerprinting);

    final JCheckBox chckbxAgressive = new JCheckBox("Agressive");
    chckbxAgressive.setBounds(35, 133, 195, 23);
    layeredPane_1.add(chckbxAgressive);

    JLabel lblWhatToFingerprint = new JLabel("What to fingerprint ?");
    lblWhatToFingerprint.setBounds(287, 81, 109, 14);
    layeredPane_1.add(lblWhatToFingerprint);

    JCheckBox chckbxCms = new JCheckBox("cms");
    chckbxCms.setBounds(280, 102, 134, 23);
    layeredPane_1.add(chckbxCms);

    JCheckBox chckbxMessageboards = new JCheckBox("message-boards");
    chckbxMessageboards.setBounds(280, 128, 134, 23);
    layeredPane_1.add(chckbxMessageboards);

    JCheckBox chckbxJavascriptframeworks = new JCheckBox("javascript-frameworks");
    chckbxJavascriptframeworks.setBounds(281, 154, 133, 23);
    layeredPane_1.add(chckbxJavascriptframeworks);

    JCheckBox chckbxWebframeworks = new JCheckBox("web-frameworks");
    chckbxWebframeworks.setBounds(281, 178, 133, 23);
    layeredPane_1.add(chckbxWebframeworks);

    JCheckBox chckbxWebservers = new JCheckBox("web-servers");
    chckbxWebservers.setBounds(281, 204, 133, 23);
    layeredPane_1.add(chckbxWebservers);

    JSeparator separator_4 = new JSeparator();
    separator_4.setOrientation(SwingConstants.VERTICAL);
    separator_4.setBounds(435, 81, 1, 201);
    layeredPane_1.add(separator_4);

    JCheckBox chckbxDatabases = new JCheckBox("databases");
    chckbxDatabases.setBounds(281, 228, 133, 23);
    layeredPane_1.add(chckbxDatabases);

    JButton btnMore = new JButton("More");
    btnMore.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            wtfpFrame = new WhatToFingerPrintFrame();
            wtfpFrame.setLocationRelativeTo(null);
            wtfpFrame.setVisible(true);
        }
    });
    btnMore.setBounds(291, 261, 123, 23);
    layeredPane_1.add(btnMore);

    JLabel lblFingerprintingTimeAnd = new JLabel("Fingerprinting time and occuracy settings:");
    lblFingerprintingTimeAnd.setBounds(490, 81, 210, 14);
    layeredPane_1.add(lblFingerprintingTimeAnd);

    JButton btnFingerprint = new JButton("Fingerprint");
    btnFingerprint.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (!chckbxPassiveFingerprinting.isSelected() && !chckbxAgressive.isSelected())
                chckbxPassiveFingerprinting.setSelected(true);
            if (chckbxPassiveFingerprinting.isSelected() && !chckbxAgressive.isSelected())
                POrAOption = 1;
            else if (!chckbxPassiveFingerprinting.isSelected() && chckbxAgressive.isSelected())
                POrAOption = 2;
            else if (chckbxPassiveFingerprinting.isSelected() && chckbxAgressive.isSelected())
                POrAOption = 3;

            try {
                targetUrl = new URL(txtHttp.getText());
            } catch (MalformedURLException e2) {
                // TODO Auto-generated catch block
                e2.printStackTrace();
            }

            System.out.println("POrAOption : " + POrAOption);

            // we concatenate the two ArrayLists
            ArrayList<String> wtfpList = getWhatToFingerprint();
            for (String wtfp : wtfpFrame.getWhatToFingerprint()) {
                wtfpList.add(wtfp);
            }
            // we call FastFingerprinter.filterResults on the global whatToFingerPrint
            // List

            fpThread = new FingerPrintingThread(targetUrl, wtfpList, POrAOption);
            fpThread.start();
            while (fpThread.isAlive()) {
                // waiting;

            }
            ArrayList<String> resultList = fpThread.getFingerPrintingResult();
            for (String app : resultList) {
                textField.setText(textField.getText() + app + " , ");
            }

            if (chckbxGetVersion.isSelected()) {
                System.out.println("wiw");
                ArrayList<String> versions = new ArrayList<String>();

                if (resultList.contains("wordpress")) {
                    textField_1.setText(textField_1.getText() + "wordpress :");
                    for (String version : FastFingerprinter.WordpressFastFingerprint(targetUrl)) {
                        textField_1.setText(textField_1.getText() + version + " ; ");
                    }
                }

                if (resultList.contains("joomla")) {
                    textField_1.setText(textField_1.getText() + "joomla :");
                    for (String version : FastFingerprinter.JoomlaFastFingerprint(targetUrl)) {
                        textField_1.setText(textField_1.getText() + version + " ; ");
                    }
                }

                // blindelephant
                for (String app : resultList) {
                    System.out.println("---->" + app);
                    try {
                        versions = WebAppGuesser.fingerPrintFile(app);
                        textField_1.setText(textField_1.getText() + app + " : ");
                        for (String version : versions) {
                            textField_1.setText(textField_1.getText() + version + " ; ");
                        }
                    } catch (NoSuchAlgorithmException | IOException | DecoderException e1) {
                        e1.printStackTrace();
                    }
                }
            }
        }
    });

    btnFingerprint.setBounds(35, 154, 195, 23);
    layeredPane_1.add(btnFingerprint);

    JButton btnDetailedView = new JButton("Detailed view ");
    btnDetailedView.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
        }
    });
    btnDetailedView.setBounds(35, 259, 195, 23);
    layeredPane_1.add(btnDetailedView);
    this.checkBoxesList.add(chckbxCms);
    this.checkBoxesList.add(chckbxJavascriptframeworks);
    this.checkBoxesList.add(chckbxWebframeworks);
    this.checkBoxesList.add(chckbxWebservers);
    this.checkBoxesList.add(chckbxDatabases);
    this.checkBoxesList.add(chckbxMessageboards);

    txtHttp = new JTextField();
    txtHttp.setText("http://");
    txtHttp.setBounds(128, 22, 568, 29);
    layeredPane_1.add(txtHttp);
    txtHttp.setColumns(10);

    JLabel lblTarget = new JLabel("Target : ");
    lblTarget.setBounds(51, 29, 46, 14);
    layeredPane_1.add(lblTarget);

    JLayeredPane layeredPane_2 = new JLayeredPane();
    tabbedPane.addTab("Details", null, layeredPane_2, null);

    JTabbedPane tabbedPane_1 = new JTabbedPane(JTabbedPane.TOP);
    tabbedPane_1.setBounds(0, 0, 720, 223);
    layeredPane_2.add(tabbedPane_1);

    JLayeredPane layeredPane_4 = new JLayeredPane();
    tabbedPane_1.addTab("Detailed result", null, layeredPane_4, null);

    JLayeredPane layeredPane_3 = new JLayeredPane();
    tabbedPane_1.addTab("Passive fingerprint", null, layeredPane_3, null);

    JTabbedPane tabbedPane_2 = new JTabbedPane(JTabbedPane.TOP);
    tabbedPane_1.addTab("Agressive fingerprint", null, tabbedPane_2, null);
}

From source file:savant.view.swing.Frame.java

/**
 * Construct a new Frame for holding a track.
 *
 * @param df the DataFormat, so the frame can do any format-specific
 * initialisation (e.g. smaller height for sequence tracks)
 *//*from  ww w  . jav a2 s  .com*/
public Frame(DataFormat df) {
    super(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.TRACK));
    sequence = df == DataFormat.SEQUENCE;

    // Component which displays the legend component.
    legend = new JComponent() {
        @Override
        public Dimension getPreferredSize() {
            for (Track t : tracks) {
                Dimension d = t.getRenderer().getLegendSize(t.getDrawingMode());
                if (d != null) {
                    return d;
                }
            }
            return new Dimension(0, 0);
        }

        @Override
        public Dimension getMinimumSize() {
            return getPreferredSize();
        }

        @Override
        public void paintComponent(Graphics g) {
            for (Track t : tracks) {
                Dimension d = t.getRenderer().getLegendSize(t.getDrawingMode());
                if (d != null) {
                    Graphics2D g2 = (Graphics2D) g;
                    GradientPaint gp = new GradientPaint(0, 0, Color.WHITE, 0, 60, new Color(230, 230, 230));
                    g2.setPaint(gp);
                    g2.fillRect(0, 0, d.width, d.height);

                    g2.setColor(Color.BLACK);
                    g2.draw(new Rectangle2D.Double(0, 0, d.width - 1, d.height - 1));
                    t.getRenderer().drawLegend(g2, t.getDrawingMode());
                    return;
                }
            }
        }
    };
    legend.setVisible(false);

    frameLandscape = new JLayeredPane();

    //add graphPane -> jlp -> scrollPane
    jlp = new JLayeredPane();
    jlp.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    gbc.gridx = 0;
    gbc.gridy = 0;

    //scrollpane
    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setWheelScrollingEnabled(false);
    scrollPane.setBorder(null);

    graphPane = new GraphPane(this);
    jlp.add(graphPane, gbc, 0);

    scrollPane.getViewport().add(jlp);

    //GRID FRAMEWORK AND COMPONENT ADDING...
    frameLandscape.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;

    //add sidepanel
    sidePanel = new JPanel() {
        @Override
        public Dimension getMinimumSize() {
            return new Dimension(0, 0);
        }
    };
    sidePanel.setLayout(new GridBagLayout());
    sidePanel.setOpaque(false);
    sidePanel.setVisible(false);
    c.weightx = 1.0;
    c.weighty = 1.0;
    c.fill = GridBagConstraints.BOTH;
    c.gridx = 1;
    c.gridy = 0;
    c.insets = new Insets(0, 0, 0, 16); // Leave 16 pixels so that we don't sit on top of the scroll-bar.
    frameLandscape.setLayer(sidePanel, JLayeredPane.PALETTE_LAYER);
    frameLandscape.add(sidePanel, c);

    addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            Dimension dim = getSize();
            if (dim != null) {
                // TODO: The following shouldn't be necessary, but it seems to be.
                int expectedWidth = frameLandscape.getWidth();
                if (expectedWidth != graphPane.getWidth()) {
                    Dimension goodSize = new Dimension(expectedWidth, graphPane.getHeight());
                    graphPane.setPreferredSize(goodSize);
                    graphPane.setSize(goodSize);
                }

                setLegendVisible(true);
            }
        }
    });

    //add graphPane to all cells
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1.0;
    c.weighty = 1.0;
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.insets = new Insets(0, 0, 0, 0);

    frameLandscape.setLayer(scrollPane, JLayeredPane.DEFAULT_LAYER);
    frameLandscape.add(scrollPane, c);

    // Add our progress-panel.  If setTracks is called promptly, it will be cleared
    // away before it ever has a chance to draw.
    getContentPane().add(new ProgressPanel(null), BorderLayout.CENTER);
}