Example usage for javax.swing ScrollPaneConstants HORIZONTAL_SCROLLBAR_NEVER

List of usage examples for javax.swing ScrollPaneConstants HORIZONTAL_SCROLLBAR_NEVER

Introduction

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

Prototype

int HORIZONTAL_SCROLLBAR_NEVER

To view the source code for javax.swing ScrollPaneConstants HORIZONTAL_SCROLLBAR_NEVER.

Click Source Link

Document

Used to set the horizontal scroll bar policy so that horizontal scrollbars are never displayed.

Usage

From source file:edu.ku.brc.specify.tasks.subpane.qb.QueryBldrPane.java

/**
 * @param report//from  ww w  .  j  a va 2 s  . c o  m
 * 
 * Loads and runs the query that acts as data source for report. Then runs report.
 */
public static void runReport(final SpReport report, final String title, final RecordSetIFace rs) {
    //XXX This is now also used to run Workbench reports. Really should extract the general stuff out
    //to a higher level...
    boolean isQueryBuilderRep = report.getReportObject() instanceof SpQuery;
    if (isQueryBuilderRep) {
        UsageTracker.incrUsageCount("QB.RunReport." + report.getQuery().getContextName());
    } else {
        UsageTracker.incrUsageCount("WB.RunReport");
    }
    TableTree tblTree = null;
    Hashtable<String, TableTree> ttHash = null;
    QueryParameterPanel qpp = null;
    if (isQueryBuilderRep) {
        UsageTracker.incrUsageCount("QB.RunReport." + report.getQuery().getContextName());
        QueryTask qt = (QueryTask) ContextMgr.getTaskByClass(QueryTask.class);
        if (qt != null) {
            Pair<TableTree, Hashtable<String, TableTree>> trees = qt.getTableTrees();
            tblTree = trees.getFirst();
            ttHash = trees.getSecond();
        } else {
            log.error("Could not find the Query task when running report " + report.getName());
            //blow up
            throw new RuntimeException("Could not find the Query task when running report " + report.getName());
        }
        qpp = new QueryParameterPanel();
        qpp.setQuery(report.getQuery(), tblTree, ttHash);
    }
    boolean go = true;
    try {
        JasperCompilerRunnable jcr = new JasperCompilerRunnable(null, report.getName(), null);
        jcr.findFiles();
        if (jcr.isCompileRequired()) {
            jcr.get();
        }
        //if isCompileRequired() is still true, then an error probably occurred compiling the report.
        JasperReport jr = !jcr.isCompileRequired() ? (JasperReport) JRLoader.loadObject(jcr.getCompiledFile())
                : null;
        ReportParametersPanel rpp = jr != null ? new ReportParametersPanel(jr, true) : null;
        JRDataSource src = null;
        if (rs == null && ((qpp != null && qpp.getHasPrompts()) || (rpp != null && rpp.getParamCount() > 0))) {
            Component pane = null;
            if (qpp != null && qpp.getHasPrompts() && rpp != null && rpp.getParamCount() > 0) {
                pane = new JTabbedPane();
                ((JTabbedPane) pane).addTab(UIRegistry.getResourceString("QB_REP_RUN_CRITERIA_TAB_TITLE"),
                        new JScrollPane(qpp, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                                ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));

                ((JTabbedPane) pane).addTab(UIRegistry.getResourceString("QB_REP_RUN_PARAM_TAB_TITLE"),
                        new JScrollPane(rpp, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                                ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
            } else if (qpp != null && qpp.getHasPrompts()) {
                pane = new JScrollPane(qpp, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                        ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
            } else {
                pane = new JScrollPane(rpp, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                        ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
            }
            CustomDialog cd = new CustomDialog((Frame) UIRegistry.getTopWindow(),
                    UIRegistry.getResourceString("QB_GET_REPORT_CONTENTS_TITLE"), true,
                    CustomDialog.OKCANCELHELP, pane);
            cd.setHelpContext("RepRunSettings");
            cd.createUI();
            Dimension ps = cd.getPreferredSize();
            ps.setSize(ps.getWidth() * 1.3, ps.getHeight());
            cd.setSize(ps);
            UIHelper.centerAndShow(cd);
            go = !cd.isCancelled();
            cd.dispose();
        }
        if (go) {
            if (isQueryBuilderRep) {
                TableQRI rootQRI = null;
                int cId = report.getQuery().getContextTableId();
                for (TableTree tt : ttHash.values()) {
                    if (cId == tt.getTableInfo().getTableId()) {
                        rootQRI = tt.getTableQRI();
                        break;
                    }
                }
                Vector<QueryFieldPanel> qfps = new Vector<QueryFieldPanel>(qpp.getFields());
                for (int f = 0; f < qpp.getFields(); f++) {
                    qfps.add(qpp.getField(f));
                }

                HQLSpecs sql = null;

                // XXX need to allow modification of SelectDistinct(etc) ???
                //boolean includeRecordIds = true;
                boolean includeRecordIds = !report.getQuery().isSelectDistinct();

                try {
                    //XXX Is it safe to assume that query is not an export query? 
                    sql = QueryBldrPane.buildHQL(rootQRI, !includeRecordIds, qfps, tblTree, rs,
                            report.getQuery().getSearchSynonymy() == null ? false
                                    : report.getQuery().getSearchSynonymy(),
                            false, null);
                } catch (Exception ex) {
                    String msg = StringUtils.isBlank(ex.getLocalizedMessage())
                            ? getResourceString("QB_RUN_ERROR")
                            : ex.getLocalizedMessage();
                    UIRegistry.getStatusBar().setErrorMessage(msg, ex);
                    UIRegistry.writeTimedSimpleGlassPaneMsg(msg, Color.RED);
                    return;
                }
                int smushedCol = (report.getQuery().getSmushed() != null && report.getQuery().getSmushed())
                        ? getSmushedCol(qfps) + 1
                        : -1;
                src = new QBDataSource(sql.getHql(), sql.getArgs(), sql.getSortElements(),
                        getColumnInfo(qfps, true, rootQRI.getTableInfo(), false), includeRecordIds,
                        report.getRepeats(), smushedCol, /*getRecordIdCol(qfps)*/0);
                ((QBDataSource) src).startDataAcquisition();
            } else {
                DataProviderSessionIFace session = DataProviderFactory.getInstance().createSession();
                try {
                    boolean loadedWB = false;
                    if (rs != null && rs.getOnlyItem() != null) {
                        Workbench wb = session.get(Workbench.class, rs.getOnlyItem().getRecordId());
                        if (wb != null) {
                            wb.forceLoad();
                            src = new WorkbenchJRDataSource(wb, true, report.getRepeats());
                            loadedWB = true;
                        }
                    }
                    if (!loadedWB) {
                        UIRegistry.displayErrorDlgLocalized("QueryBldrPane.WB_LOAD_ERROR_FOR_REPORT",
                                rs != null ? rs.getName() : "[" + UIRegistry.getResourceString("NONE") + "]");
                        return;
                    }
                } finally {
                    session.close();
                }
            }

            final CommandAction cmd = new CommandAction(ReportsBaseTask.REPORTS, ReportsBaseTask.PRINT_REPORT,
                    src);
            cmd.setProperty("title", title);
            cmd.setProperty("file", report.getName());
            if (rs == null) {
                cmd.setProperty("skip-parameter-prompt", "true");
            }
            //if isCompileRequired is true then an error probably occurred while compiling,
            //and, if so, it will be caught again and reported in the report results pane.
            if (!jcr.isCompileRequired()) {
                cmd.setProperty("compiled-file", jcr.getCompiledFile());
            }
            if (rpp != null && rpp.getParamCount() > 0) {
                StringBuilder params = new StringBuilder();
                for (int p = 0; p < rpp.getParamCount(); p++) {
                    Pair<String, String> param = rpp.getParam(p);
                    if (StringUtils.isNotBlank(param.getSecond())) {
                        params.append(param.getFirst());
                        params.append("=");
                        params.append(param.getSecond());
                        params.append(";");
                    }
                    cmd.setProperty("params", params.toString());
                }
            }
            CommandDispatcher.dispatch(cmd);
        }
    } catch (JRException ex) {
        UsageTracker.incrHandledUsageCount();
        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(QueryBldrPane.class, ex);
        log.error(ex);
        ex.printStackTrace();
    }
}

From source file:edu.ku.brc.specify.tasks.subpane.qb.QueryBldrPane.java

/**
 * @param parentList//from   ww  w  . j a  va 2 s  .c o m
 */
protected void fillNextList(final JList parentList) {
    if (processingLists) {
        return;
    }

    processingLists = true;

    final int curInx = listBoxList.indexOf(parentList);
    if (curInx > -1) {
        int startSize = listBoxPanel.getComponentCount();
        for (int i = curInx + 1; i < listBoxList.size(); i++) {
            listBoxPanel.remove(spList.get(i));
        }
        int removed = startSize - listBoxPanel.getComponentCount();
        for (int i = 0; i < removed; i++) {
            tableTreeList.remove(tableTreeList.size() - 1);
        }

    } else {
        listBoxPanel.removeAll();
        tableTreeList.clear();
    }

    QryListRendererIFace item = (QryListRendererIFace) parentList.getSelectedValue();
    if (item instanceof ExpandableQRI) {
        JList newList;
        DefaultListModel model;
        JScrollPane sp;

        if (curInx == listBoxList.size() - 1) {
            newList = new JList(model = new DefaultListModel());
            newList.addMouseListener(new MouseAdapter() {

                /* (non-Javadoc)
                 * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
                 */
                @Override
                public void mouseClicked(MouseEvent e) {
                    if (e.getClickCount() == 2) {
                        if (currentInx != -1) {
                            JList list = (JList) e.getSource();
                            QryListRendererIFace qriFace = (QryListRendererIFace) list.getSelectedValue();
                            if (BaseQRI.class.isAssignableFrom(qriFace.getClass())) {
                                BaseQRI qri = (BaseQRI) qriFace;
                                if (qri.isInUse()) {
                                    //remove the field
                                    for (QueryFieldPanel qfp : QueryBldrPane.this.queryFieldItems) {
                                        FieldQRI fqri = qfp.getFieldQRI();
                                        if (fqri == qri || (fqri instanceof RelQRI && fqri.getTable() == qri)) {
                                            boolean clearIt = qfp.getSchemaItem() != null;
                                            QueryBldrPane.this.removeQueryFieldItem(qfp);
                                            if (clearIt) {
                                                qfp.setField(null, null);
                                            }
                                            break;
                                        }
                                    }
                                } else {
                                    // add the field
                                    try {
                                        FieldQRI fieldQRI = buildFieldQRI(qri);
                                        if (fieldQRI == null) {
                                            throw new Exception("null FieldQRI");
                                        }
                                        SpQueryField qf = new SpQueryField();
                                        qf.initialize();
                                        qf.setFieldName(fieldQRI.getFieldName());
                                        qf.setStringId(fieldQRI.getStringId());
                                        query.addReference(qf, "fields");
                                        if (!isExportMapping) {
                                            addQueryFieldItem(fieldQRI, qf, false);
                                        } else {
                                            addNewMapping(fieldQRI, qf, null, false);
                                        }
                                    } catch (Exception ex) {
                                        log.error(ex);
                                        UsageTracker.incrHandledUsageCount();
                                        edu.ku.brc.exceptions.ExceptionTracker.getInstance()
                                                .capture(QueryBldrPane.class, ex);
                                        return;
                                    }
                                }
                            }
                        }
                    }
                }
            });
            newList.setCellRenderer(qryRenderer);
            listBoxList.add(newList);
            sp = new JScrollPane(newList, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
                    ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
            JLabel colHeader = UIHelper.createLabel(item.getTitle());
            colHeader.setHorizontalAlignment(SwingConstants.CENTER);
            colHeader.setBackground(listBoxPanel.getBackground());
            colHeader.setOpaque(true);

            sp.setColumnHeaderView(colHeader);

            spList.add(sp);

            newList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
                public void valueChanged(ListSelectionEvent e) {
                    if (!e.getValueIsAdjusting()) {
                        fillNextList(listBoxList.get(curInx + 1));
                    }
                }
            });

        } else {
            newList = listBoxList.get(curInx + 1);
            model = (DefaultListModel) newList.getModel();
            sp = spList.get(curInx + 1);
            JLabel colHeaderLbl = (JLabel) sp.getColumnHeader().getComponent(0);
            if (item instanceof TableQRI) {
                colHeaderLbl.setText(((TableQRI) item).getTitle());
            } else {
                colHeaderLbl.setText(getResourceString("QueryBldrPane.QueryFields"));
            }
        }

        createNewList((TableQRI) item, model);

        listBoxPanel.remove(addBtn);
        listBoxPanel.add(sp);
        tableTreeList.add(((ExpandableQRI) item).getTableTree());
        listBoxPanel.add(addBtn);
        currentInx = -1;

    } else {
        listBoxPanel.add(addBtn);
    }

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            updateAddBtnState();

            // Is all this really necessary
            listBoxPanel.validate();
            listBoxPanel.repaint();
            scrollPane.validate();
            scrollPane.invalidate();
            scrollPane.doLayout();
            scrollPane.repaint();
            validate();
            invalidate();
            doLayout();
            repaint();
            UIRegistry.forceTopFrameRepaint();
        }
    });

    processingLists = false;
    currentInx = curInx;

}

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

private void initView() {

    // Set default scale values
    minStart = 0;/*  w ww  .j  av  a2  s  .co  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.dishevelled.brainstorm.BrainStorm.java

/**
 * Layout components./*from   w w w  . j a v  a 2s . co m*/
 */
private void layoutComponents() {
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    JScrollPane scrollPane = new JScrollPane(textArea);
    scrollPane.setBorder(null);
    scrollPane.setOpaque(true);
    scrollPane.setBackground(backgroundColor);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
    add(placeholder);

    JPanel flow = new JPanel();
    flow.setLayout(new FlowLayout());
    flow.setOpaque(false);
    flow.add(scrollPane);

    add(flow);
    add(Box.createVerticalGlue());
    add(Box.createVerticalGlue());
}

From source file:org.geworkbench.components.lincs.LincsInterface.java

private JScrollPane buildJListPanel(List<String> dataList, JList aJlist) {

    aJlist.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    aJlist.setSelectionModel(new LincsListSelectionModel());
    aJlist.setModel(new LincsListModel(dataList));
    JScrollPane jScrollPane1 = new javax.swing.JScrollPane(aJlist,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

    jScrollPane1.setPreferredSize(new java.awt.Dimension(200, 70));

    return jScrollPane1;

}

From source file:org.geworkbench.components.lincs.LincsInterface.java

private JScrollPane buildFilterJListPanel(List<String> dataList, FilteredJList filteredJList) {

    filteredJList.setSelectionModel(new LincsListSelectionModel());
    filteredJList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

    for (int i = 0; i < dataList.size(); i++)
        filteredJList.addItem(dataList.get(i));
    JScrollPane jScrollPane1 = new javax.swing.JScrollPane(filteredJList,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

    jScrollPane1.setPreferredSize(new java.awt.Dimension(200, 70));

    return jScrollPane1;

}

From source file:org.jajuk.ui.views.ArtistView.java

@Override
public void shortCall(Object in) {
    removeAll();/*from  w  w  w .jav a 2  s.c  o  m*/
    jspAlbums = getLastFMSuggestionsPanel(SuggestionType.OTHERS_ALBUMS, true);
    // Artist unknown from last.fm, leave
    if (artistInfo == null
            // If image url is void, last.fm doesn't provide enough data about this
            // artist, we reset the view
            || StringUtils.isBlank(artistInfo.getImageUrl())) {
        reset();
        return;
    }
    artistThumb = new LastFmArtistThumbnail(artistInfo);
    // No known icon next to artist thumb
    artistThumb.setArtistView(true);
    artistThumb.populate();
    jtaArtistDesc = new JTextArea(bio) {
        private static final long serialVersionUID = 9217998016482118852L;

        // We set the margin this way, setMargin() doesn't work due to
        // existing border
        @Override
        public Insets getInsets() {
            return new Insets(2, 4, 0, 4);
        }
    };
    jtaArtistDesc.setBorder(null);
    jtaArtistDesc.setEditable(false);
    jtaArtistDesc.setLineWrap(true);
    jtaArtistDesc.setWrapStyleWord(true);
    jtaArtistDesc.setOpaque(false);
    JScrollPane jspWiki = new JScrollPane(jtaArtistDesc);
    jspWiki.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    jspWiki.setBorder(null);
    jspWiki.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    // Add items, layout is different according wiki text availability
    if (StringUtils.isNotBlank(jtaArtistDesc.getText())) {
        setLayout(new MigLayout("ins 5,gapy 5", "[grow]", "[grow][20%!][grow]"));
        add(artistThumb, "center,wrap");
        // don't add the textarea if no wiki text available
        add(jspWiki, "growx,wrap");
        add(jspAlbums, "grow,wrap");
    } else {
        setLayout(new MigLayout("ins 5,gapy 5", "[grow]"));
        add(artistThumb, "center,wrap");
        // don't add the textarea if no wiki text available
        add(jspAlbums, "grow,wrap");
    }
    revalidate();
    repaint();
}

From source file:org.jajuk.ui.views.SuggestionView.java

/**
 * Return the result panel for local albums.
 *
 * @param type //from w w w  .j a  v  a  2 s  . c o m
 *
 * @return the local suggestions panel
 */
JScrollPane getLocalSuggestionsPanel(SuggestionType type) {
    FlowScrollPanel out = new FlowScrollPanel();
    out.setLayout(new FlowLayout(FlowLayout.LEFT));
    JScrollPane jsp = new JScrollPane(out, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    jsp.setBorder(null);
    out.setScroller(jsp);
    List<Album> albums = null;
    if (type == SuggestionType.BEST_OF) {
        albums = albumsPrefered;
    } else if (type == SuggestionType.NEWEST) {
        albums = albumsNewest;
    } else if (type == SuggestionType.RARE) {
        albums = albumsRare;
    }
    if (albums != null && albums.size() > 0) {
        for (Album album : albums) {
            LocalAlbumThumbnail thumb = new LocalAlbumThumbnail(album, 100, false);
            thumb.populate();
            thumb.getIcon().addMouseListener(new ThumbMouseListener());
            out.add(thumb);
        }
    } else {
        out.add(UtilGUI.getCentredPanel(new JLabel(Messages.getString("WikipediaView.3"))));
    }
    return jsp;
}

From source file:org.jajuk.ui.views.SuggestionView.java

/**
 * Return the result panel for lastFM information.
 *
 * @param type //from ww  w .  j a v a2s . c  o  m
 * @param artistView 
 *
 * @return the last fm suggestions panel
 */
JScrollPane getLastFMSuggestionsPanel(SuggestionType type, boolean artistView) {
    FlowScrollPanel flowPanel = new FlowScrollPanel();
    JScrollPane jsp = new JScrollPane(flowPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    jsp.setBorder(null);
    flowPanel.setScroller(jsp);
    flowPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
    if (type == SuggestionType.OTHERS_ALBUMS) {
        if (albums != null && albums.getAlbums().size() > 0) {
            for (AlbumInfo album : albums.getAlbums()) {
                AbstractThumbnail thumb = new LastFmAlbumThumbnail(album);
                thumb.setArtistView(artistView);
                thumb.populate();
                if (thumb.getIcon() != null) {
                    thumb.getIcon().addMouseListener(new ThumbMouseListener());
                    flowPanel.add(thumb);
                }
            }
        }
        // No result found
        else {
            return new JScrollPane(getNothingFoundPanel());
        }
    } else if (type == SuggestionType.SIMILAR_ARTISTS) {
        if (similar != null) {
            List<ArtistInfo> artists = similar.getArtists();
            for (ArtistInfo similarArtist : artists) {
                AbstractThumbnail thumb = new LastFmArtistThumbnail(similarArtist);
                thumb.setArtistView(artistView);
                thumb.populate();
                if (thumb.getIcon() != null) {
                    thumb.getIcon().addMouseListener(new ThumbMouseListener());
                    flowPanel.add(thumb);
                }
            }
        }
        // No result found
        else {
            return new JScrollPane(getNothingFoundPanel());
        }
    }
    return jsp;
}

From source file:org.kepler.gui.PlotsEditorPanel.java

public PlotsEditorPanel(TableauFrame parent, String title) {
    super();//from   ww w.  ja va 2s. c  o m
    _title = title;
    _frame = parent;
    setBackground(TabManager.BGCOLOR);
    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    plotsPanel = new JPanel();
    plotsPanel.setLayout(new BoxLayout(plotsPanel, BoxLayout.PAGE_AXIS));

    fixGraphics();

    JScrollPane scrollPane = new JScrollPane(plotsPanel);

    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    this.add(scrollPane, BorderLayout.CENTER);
    JButton addPlotButton = createAddPlotButton();
    this.add(addPlotButton, BorderLayout.PAGE_END);

    // This thread will try to wait until the PlotsPanel is available
    // before adding a plot to it. If a plot is added before the
    // applicable tab pane is available, an NPE will be triggered.
    // The thread will poll for tab pane setup completion every 100 ms,
    // up to a maximum of 10 seconds (100 iterations). If after 10 seconds
    // the tab pane is not available, something has probably gone wrong,
    // and further attempts would do no good.
    new Thread(new Runnable() {
        private void pause(long l) {
            try {
                Thread.sleep(l);
            } catch (InterruptedException ignored) {
            }
        }

        public void run() {
            int maxIterations = 100;
            for (int i = 0; i < maxIterations; i++) {
                log.debug("PlotsEditorPanel thread waiting " + "for TabPane to become available...");
                pause(100);
                if (canAddPlot()) {
                    log.debug("PlotsEditorPanel thread got TabPane, adding Plot.");
                    addPlot();
                    return;
                }
            }
        }
    }).start();
}