Example usage for javax.swing JScrollPane setBorder

List of usage examples for javax.swing JScrollPane setBorder

Introduction

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

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The component's border.")
public void setBorder(Border border) 

Source Link

Document

Sets the border of this component.

Usage

From source file:mazewar.Mazewar.java

/**
 * The place where all the pieces are put together.
 *//*from  w  w w  .  j  av a 2  s  .c  o  m*/
public Mazewar(String zkServer, int zkPort, int port, String name, String game, boolean robot) {
    super("ECE419 Mazewar");
    consolePrintLn("ECE419 Mazewar started!");

    /* Set up parent */
    ZK_PARENT += game;

    // Throw up a dialog to get the GUIClient name.
    if (name != null) {
        clientId = name;
    } else {
        clientId = JOptionPane.showInputDialog("Enter your name");
    }
    if ((clientId == null) || (clientId.length() == 0)) {
        Mazewar.quit();
    }

    /* Connect to ZooKeeper and get sequencer details */
    List<ClientNode> nodeList = null;
    try {
        zkWatcher = new ZkWatcher();
        zkConnected = new CountDownLatch(1);
        zooKeeper = new ZooKeeper(zkServer + ":" + zkPort, ZK_TIMEOUT, new Watcher() {
            @Override
            public void process(WatchedEvent event) {
                /* Release Lock if ZooKeeper is connected */
                if (event.getState() == SyncConnected) {
                    zkConnected.countDown();
                } else {
                    System.err.println("Could not connect to ZooKeeper!");
                    System.exit(0);
                }
            }
        });
        zkConnected.await();

        /* Successfully connected, now create our node on ZooKeeper */
        zooKeeper.create(Joiner.on('/').join(ZK_PARENT, clientId),
                Joiner.on(':').join(InetAddress.getLocalHost().getHostAddress(), port).getBytes(),
                ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL_SEQUENTIAL);

        /* Get Seed from Parent */
        mazeSeed = Long.parseLong(new String(zooKeeper.getData(ZK_PARENT, false, null)));

        /* Initialize Sequence Number */
        sequenceNumber = new AtomicInteger(zooKeeper.exists(ZK_PARENT, false).getVersion());

        /* Get list of nodes */
        nodeList = ClientNode.sortList(zooKeeper.getChildren(ZK_PARENT, false));
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }

    // Create the maze
    maze = new MazeImpl(new Point(mazeWidth, mazeHeight), mazeSeed);
    assert (maze != null);

    // Have the ScoreTableModel listen to the maze to find
    // out how to adjust scores.
    ScoreTableModel scoreModel = new ScoreTableModel();
    assert (scoreModel != null);
    maze.addMazeListener(scoreModel);

    /* Initialize packet queue */
    packetQueue = new ArrayBlockingQueue<MazePacket>(QUEUE_SIZE);
    sequencedQueue = new PriorityBlockingQueue<MazePacket>(QUEUE_SIZE, new Comparator<MazePacket>() {
        @Override
        public int compare(MazePacket o1, MazePacket o2) {
            return o1.sequenceNumber.compareTo(o2.sequenceNumber);
        }
    });

    /* Inject Event Bus into Client */
    Client.setEventBus(eventBus);

    /* Initialize ZMQ Context */
    context = ZMQ.context(2);

    /* Set up publisher */
    publisher = context.socket(ZMQ.PUB);
    publisher.bind("tcp://*:" + port);
    System.out.println("ZeroMQ Publisher Bound On: " + port);

    try {
        Thread.sleep(100);
    } catch (Exception e) {
        e.printStackTrace();
    }

    /* Set up subscriber */
    subscriber = context.socket(ZMQ.SUB);
    subscriber.subscribe(ArrayUtils.EMPTY_BYTE_ARRAY);

    clients = new ConcurrentHashMap<String, Client>();
    try {
        for (ClientNode client : nodeList) {
            if (client.getName().equals(clientId)) {
                clientPath = ZK_PARENT + "/" + client.getPath();
                guiClient = robot ? new RobotClient(clientId) : new GUIClient(clientId);
                clients.put(clientId, guiClient);
                maze.addClient(guiClient);
                eventBus.register(guiClient);
                subscriber.connect("tcp://" + new String(zooKeeper.getData(clientPath, false, null)));
            } else {
                addRemoteClient(client);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    checkNotNull(guiClient, "Should have received our clientId in CLIENTS list!");

    // Create the GUIClient and connect it to the KeyListener queue
    this.addKeyListener(guiClient);
    this.isRobot = robot;

    // Use braces to force constructors not to be called at the beginning of the
    // constructor.
    /*{
    maze.addClient(new RobotClient("Norby"));
    maze.addClient(new RobotClient("Robbie"));
    maze.addClient(new RobotClient("Clango"));
    maze.addClient(new RobotClient("Marvin"));
    }*/

    // Create the panel that will display the maze.
    overheadPanel = new OverheadMazePanel(maze, guiClient);
    assert (overheadPanel != null);
    maze.addMazeListener(overheadPanel);

    // Don't allow editing the console from the GUI
    console.setEditable(false);
    console.setFocusable(false);
    console.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder()));

    // Allow the console to scroll by putting it in a scrollpane
    JScrollPane consoleScrollPane = new JScrollPane(console);
    assert (consoleScrollPane != null);
    consoleScrollPane
            .setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Console"));

    // Create the score table
    scoreTable = new JTable(scoreModel);
    assert (scoreTable != null);
    scoreTable.setFocusable(false);
    scoreTable.setRowSelectionAllowed(false);

    // Allow the score table to scroll too.
    JScrollPane scoreScrollPane = new JScrollPane(scoreTable);
    assert (scoreScrollPane != null);
    scoreScrollPane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Scores"));

    // Create the layout manager
    GridBagLayout layout = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    getContentPane().setLayout(layout);

    // Define the constraints on the components.
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1.0;
    c.weighty = 3.0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    layout.setConstraints(overheadPanel, c);
    c.gridwidth = GridBagConstraints.RELATIVE;
    c.weightx = 2.0;
    c.weighty = 1.0;
    layout.setConstraints(consoleScrollPane, c);
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 1.0;
    layout.setConstraints(scoreScrollPane, c);

    // Add the components
    getContentPane().add(overheadPanel);
    getContentPane().add(consoleScrollPane);
    getContentPane().add(scoreScrollPane);

    // Pack everything neatly.
    pack();

    // Let the magic begin.
    setVisible(true);
    overheadPanel.repaint();
    this.requestFocusInWindow();
}

From source file:com.projity.pm.graphic.chart.TimeChartPanel.java

public void configureScrollPaneHeaders(JScrollPane scrollPane, JComponent rowHeader) {
    viewport = scrollPane.getViewport();
    if (viewport == null || viewport.getView() != this)
        return;//  www.j a  va2  s  .  c  o  m

    JViewport vp = new JViewport();
    vp.setView(rowHeader);
    vp.setPreferredSize(rowHeader.getPreferredSize());
    scrollPane.setRowHeader(vp);

    scrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER, new ChartCorner(this));

    Border border = scrollPane.getBorder();
    if (border == null || border instanceof UIResource) {
        scrollPane.setBorder(UIManager.getBorder("Table.scrollPaneBorder"));
    }

    // left scale synchro
    viewport.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            updateTimeScaleComponentSize();
        }
    });

}

From source file:edu.ku.brc.specify.config.FixAttachments.java

/**
 * @param tableList/*  ww  w  . j av a 2  s  .  c o  m*/
 * @param tableIdList
 * @param resultsHashMap
 * @param tblTypeHash
 * @param tableHash
 * @param totalFiles
 */
private void displayBadAttachments(final ArrayList<JTable> tableList, final ArrayList<Integer> tableIdList,
        final HashMap<Integer, Vector<Object[]>> resultsHashMap, final HashMap<Integer, String> tblTypeHash,
        final HashMap<Integer, AttchTableModel> tableHash, final int totalFiles) {
    CellConstraints cc = new CellConstraints();

    int maxWidth = 200;
    int y = 1;
    String rowDef = tableList.size() == 1 ? "f:p:g"
            : UIHelper.createDuplicateJGoodiesDef("p", "10px", tableList.size());
    PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g", rowDef));
    if (tableList.size() > 1) {
        int i = 0;
        for (JTable table : tableList) {
            Integer tblId = tableIdList.get(i++);
            int numRows = table.getModel().getRowCount();

            PanelBuilder pb2 = new PanelBuilder(new FormLayout("f:p:g", "p,2px,f:p:g"));
            if (resultsHashMap.size() > 1) {
                UIHelper.calcColumnWidths(table, numRows < 15 ? numRows + 1 : 15, maxWidth);
            } else {
                UIHelper.calcColumnWidths(table, 15, maxWidth);
            }
            pb2.addSeparator(tblTypeHash.get(tblId), cc.xy(1, 1));
            pb2.add(UIHelper.createScrollPane(table), cc.xy(1, 3));
            pb.add(pb2.getPanel(), cc.xy(1, y));
            y += 2;
        }
    } else {
        UIHelper.calcColumnWidths(tableList.get(0), 15, maxWidth);
        pb.add(UIHelper.createScrollPane(tableList.get(0)), cc.xy(1, 1));
    }
    tableList.clear();

    pb.setDefaultDialogBorder();

    JScrollPane panelSB = UIHelper.createScrollPane(pb.getPanel());
    panelSB.setBorder(BorderFactory.createEmptyBorder());
    Dimension dim = panelSB.getPreferredSize();
    panelSB.setPreferredSize(new Dimension(dim.width + 10, 600));

    final int totFiles = totalFiles;
    String title = String.format("Attachment Information - %d files to recover.", totalFiles);
    CustomDialog dlg = new CustomDialog((Dialog) null, title, true, CustomDialog.OKCANCELAPPLYHELP, panelSB) {
        @Override
        protected void helpButtonPressed() {
            File file = produceSummaryReport(resultsHashMap, tableHash, totFiles);
            try {
                AttachmentUtils.openURI(file.toURI());
            } catch (Exception e) {
            }
        }

        @Override
        protected void applyButtonPressed() {
            boolean isOK = UIRegistry.displayConfirm("Clean up",
                    "Are you sure you want to remove all references to the missing attachments?", "Remove",
                    "Cancel", JOptionPane.WARNING_MESSAGE);
            if (isOK) {
                super.applyButtonPressed();
            }
        }
    };

    dlg.setCloseOnApplyClk(true);
    dlg.setCancelLabel("Skip");
    dlg.setOkLabel("Recover Files");
    dlg.setHelpLabel("Show Summary");
    dlg.setApplyLabel("Delete References");
    dlg.createUI();
    dlg.pack();

    dlg.setVisible(true);

    if (dlg.getBtnPressed() == CustomDialog.OK_BTN) {
        reattachFiles(resultsHashMap, tableHash, totalFiles);

    } else if (dlg.getBtnPressed() == CustomDialog.APPLY_BTN) {
        doAttachmentRefCleanup(resultsHashMap, tableHash, totFiles);
    }

}

From source file:net.sf.taverna.t2.workbench.cagrid.CaGridComponent.java

private void addResultPanel() {
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;/*from ww w  .  ja  va  2  s . co m*/
    c.gridy = ++row;
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 0.01;
    c.weighty = 0.01;
    c.anchor = GridBagConstraints.SOUTHEAST;
    c.gridwidth = GridBagConstraints.REMAINDER;
    resultPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    resultPanel.setDividerLocation(200);
    resultPanel.setBorder(null);
    runListModel = new DefaultListModel();
    runList = new JList(runListModel);
    runList.setBorder(new EmptyBorder(5, 5, 5, 5));
    runList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    runListPanel = new JPanel(new BorderLayout());
    runListPanel.setBorder(LineBorder.createGrayLineBorder());

    JLabel worklflowRunsLabel = new JLabel("Workflow Runs");
    worklflowRunsLabel.setBorder(new EmptyBorder(5, 5, 5, 5));
    removeCaGridRunsButton = new JButton("Remove"); // button to remove previous workflow runs
    removeCaGridRunsButton.setAlignmentX(JComponent.RIGHT_ALIGNMENT);
    removeCaGridRunsButton.setEnabled(false);
    removeCaGridRunsButton.setToolTipText("Remove caGrid run(s)");
    removeCaGridRunsButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int[] selected = runList.getSelectedIndices();
            for (int i = selected.length - 1; i >= 0; i--) {
                CaGridRun cr = (CaGridRun) runListModel.get(selected[i]);

                //delete the EPR file
                File file = new File(new File(System.getProperty("user.home")), cr.workflowid + ".epr");
                file.delete();
                System.out.println(cr.workflowid + ".epr deleted");
                runListModel.remove(selected[i]);
            }
            // Set the first item as selected - if there is one
            if (runListModel.size() > 0) {
                runList.setSelectedIndex(0);
            } else {
                resultText.setText("");
                resultText.revalidate();

            }
        }
    });
    runListPanel.add(worklflowRunsLabel, BorderLayout.NORTH);
    runListPanel.add(removeCaGridRunsButton, BorderLayout.BEFORE_FIRST_LINE);

    JScrollPane scrollPane = new JScrollPane(runList);
    scrollPane.setBorder(null);
    runListPanel.add(scrollPane, BorderLayout.CENTER);
    // loadWorkflowRunsFromStoredEPRFiles(): add CaGridRun to runList for each EPR
    // add two buttons: remove and refresh status
    runList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                Object selection = runList.getSelectedValue();
                if (selection instanceof CaGridRun) {
                    removeCaGridRunsButton.setEnabled(true);
                    CaGridRun dataflowRun = (CaGridRun) selection;
                    // update status and refresh outputPanel
                    String resultDisplayString = updateResultDisplayString(dataflowRun);
                    resultText.setText(resultDisplayString);
                    resultText.setLineWrap(true);
                    resultText.setEditable(false);
                    outputPanel.revalidate();
                    revalidate();
                } else {
                    removeCaGridRunsButton.setEnabled(false);
                    revalidate();

                }
            }
        }
    });

    resultPanel.setTopComponent(runListPanel);

    //each output should be a (xml) string
    outputPanel = new JScrollPane();

    resultText = new JTextArea();
    outputPanel = new JScrollPane(resultText, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    //outputPanel = new JPanel(new BorderLayout());
    outputPanel.setBorder(LineBorder.createGrayLineBorder());
    outputPanel.setBackground(Color.WHITE);
    //outputPanel.add(new JLabel("Workflow Execution Outputs shows here.", JLabel.CENTER), null);
    resultPanel.setBottomComponent(outputPanel);
    add(resultPanel, c);

    //add runComponent to the GUI
    ArrayList<CaGridRun> loadedRunList = loadWorkflowRunsFromStoredEPRFiles(null,
            (String) services.getSelectedItem());
    if (loadedRunList != null) {
        for (int m = 0; m < loadedRunList.size(); m++) {
            CaGridRun cr = (CaGridRun) loadedRunList.get(m);
            runListModel.add(0, cr);
        }
        System.out.println(loadedRunList.size() + " EPR loaded.");
        runList.setSelectedIndex(0);
    }

}

From source file:com.apatar.ui.JPublishToApatarDialog.java

private void createDialog() {

    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();

    this.setLayout(gridbag);

    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 1.0;//from   w  w w. j a  va  2  s  . c  o m
    c.weighty = 0.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    //c.insets = new Insets(5, 5, 5, 5);

    JPanel panelLogin = new JPanel();
    panelLogin.setBorder(new EmptyBorder(10, 10, 0, 10));
    panelLogin.setLayout(new BoxLayout(panelLogin, BoxLayout.X_AXIS));
    panelLogin.add(new JLabel("User Name"));
    panelLogin.add(Box.createHorizontalStrut(5));
    panelLogin.add(username);
    username.setComponentPopupMenu(new JDefaultContextMenu(username));
    panelLogin.add(Box.createHorizontalStrut(5));
    panelLogin.add(new JLabel("Password"));
    panelLogin.add(Box.createHorizontalStrut(5));
    panelLogin.add(password);

    JPanel panelForgotPassLink = new JPanel();
    panelForgotPassLink.setBorder(new EmptyBorder(10, 10, 0, 10));
    panelForgotPassLink.setLayout(new BoxLayout(panelForgotPassLink, BoxLayout.X_AXIS));
    panelForgotPassLink.add(new JLabel("Lost your password? "));
    panelForgotPassLink.add(Box.createHorizontalStrut(5));
    panelForgotPassLink.add(forgotPassLinkLabel);

    forgotPassLinkLabel.setFont(UiUtils.NORMAL_SIZE_12_FONT);
    forgotPassLinkLabel.addMouseListener(new MouseHyperLinkEvent());
    forgotPassLinkLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    forgotPassLinkLabel.setText(
            "<html><a href='http://www.apatarforge.org/profile/lostpassword.html'>Click here to retrieve it</a></html>");

    JPanel panelFile = new JPanel();
    panelFile.setBorder(new EmptyBorder(10, 10, 0, 10));
    panelFile.setLayout(new BoxLayout(panelFile, BoxLayout.X_AXIS));
    panelFile.add(selectFromFile);
    panelFile.add(Box.createHorizontalStrut(5));
    panelFile.add(new JLabel("New File "));
    panelFile.add(Box.createHorizontalStrut(5));
    panelFile.add(nameFile);
    panelFile.add(Box.createHorizontalStrut(5));
    panelFile.add(browse);
    nameFile.setEnabled(false);
    nameFile.setComponentPopupMenu(new JDefaultContextMenu(nameFile));
    browse.setEnabled(false);

    JPanel panelLocation = new JPanel();
    panelLocation.setBorder(new EmptyBorder(10, 10, 0, 10));
    panelLocation.setLayout(new BoxLayout(panelLocation, BoxLayout.X_AXIS));
    panelLocation.add(new JLabel("Suggest Location:"));
    panelLocation.add(Box.createHorizontalStrut(5));
    panelLocation.add(location);

    JPanel panelDMName = new JPanel();
    panelDMName.setBorder(new EmptyBorder(10, 10, 0, 10));
    panelDMName.setLayout(new BoxLayout(panelDMName, BoxLayout.X_AXIS));
    JLabel datamapNameLabel = new JLabel("DataMap Name:");
    datamapNameLabel.setBorder(new EmptyBorder(0, 0, 0, 10));
    panelDMName.add(datamapNameLabel);
    panelDMName.add(Box.createHorizontalStrut(5));
    panelDMName.add(dataMapName);
    dataMapName.setComponentPopupMenu(new JDefaultContextMenu(dataMapName));

    JPanel panelDMDescription = new JPanel();
    panelDMDescription.setBorder(new EmptyBorder(10, 10, 0, 10));
    panelDMDescription.setLayout(new BoxLayout(panelDMDescription, BoxLayout.X_AXIS));
    panelDMDescription.add(new JLabel("DataMap Description (16000 Chars)"));
    panelDMDescription.add(Box.createHorizontalStrut(5));
    //JScrollPane scroll = new JScrollPane(dataMapDescription);
    //scroll.setSize(300, 50);
    dataMapDescription.setLineWrap(true);
    dataMapDescription.setWrapStyleWord(true);
    panelDMDescription.add(new JScrollPane(dataMapDescription));

    JPanel panelDMShortDescription = new JPanel();
    panelDMShortDescription.setBorder(new EmptyBorder(10, 10, 0, 10));
    panelDMShortDescription.setLayout(new BoxLayout(panelDMShortDescription, BoxLayout.X_AXIS));
    JLabel labelShort = new JLabel("Short Description:");
    labelShort.setBorder(new EmptyBorder(0, 0, 0, 85));
    panelDMShortDescription.add(labelShort);
    panelDMShortDescription.add(Box.createHorizontalStrut(5));
    shortDescription.setLineWrap(true);
    shortDescription.setWrapStyleWord(true);
    panelDMShortDescription.add(new JScrollPane(shortDescription));
    setEnableShortDescription(false);

    // -------------

    JPanel panelTitleForTags = new JPanel();
    panelTitleForTags.setBorder(new EmptyBorder(10, 10, 0, 10));
    panelTitleForTags.setLayout(new BoxLayout(panelTitleForTags, BoxLayout.X_AXIS));
    panelTitleForTags.add(new JLabel("Add tags associated with your DataMap:"));

    // -------------

    JPanel panelListAddedTags = new JPanel();
    panelListAddedTags.setBorder(new EmptyBorder(0, 10, 10, 10));
    panelListAddedTags.setLayout(new BoxLayout(panelListAddedTags, BoxLayout.X_AXIS));

    // --
    JPanel panelFrom = new JPanel();
    panelFrom.setLayout(new BoxLayout(panelFrom, BoxLayout.Y_AXIS));
    JPanel panelMiddle = new JPanel();
    panelMiddle.setLayout(new BoxLayout(panelMiddle, BoxLayout.X_AXIS));
    JPanel panelTo = new JPanel();
    panelTo.setLayout(new BoxLayout(panelTo, BoxLayout.Y_AXIS));

    // --
    JPanel panelAddNewTag = new JPanel();
    panelAddNewTag.setLayout(new BoxLayout(panelAddNewTag, BoxLayout.X_AXIS));
    panelAddNewTag.add(new JLabel("Add new tag:"));
    panelAddNewTag.add(Box.createHorizontalStrut(5));
    textfieldAddNewTag = new JTextField();
    textfieldAddNewTag.setComponentPopupMenu(new JDefaultContextMenu(textfieldAddNewTag));
    panelAddNewTag.add(textfieldAddNewTag);
    panelAddNewTag.add(Box.createHorizontalStrut(5));
    JButton buttonAddTag = new JButton("Add");
    buttonAddTag.addActionListener(addNewTagMouseListener);
    panelAddNewTag.add(buttonAddTag);

    // --
    JPanel panelDeleteTags = new JPanel();
    panelDeleteTags.setLayout(new BoxLayout(panelDeleteTags, BoxLayout.X_AXIS));

    panelDeleteTags.add(new JLabel("Delete selected tag(s):"));
    panelDeleteTags.add(Box.createHorizontalStrut(5));
    JButton buttonDeleteTag = new JButton("Delete");
    buttonDeleteTag.addActionListener(deleteTagMouseListener);
    panelDeleteTags.add(buttonDeleteTag);
    panelDeleteTags.add(new JPanel());

    // --

    JButton moveTag = new JButton(UiUtils.ARROW_ICON);
    moveTag.addActionListener(addTagsMouseListener);
    panelMiddle.add(moveTag);

    tblModelFrom = new DefaultTableModel();
    tblModelTo = new DefaultTableModel();
    tblModelFrom.addColumn("Tag Name");
    tblModelTo.addColumn("Tag Name");

    tagsTableFrom = new JTable(tblModelFrom);
    tagsTableTo = new JTable(tblModelTo);

    tagsTableFrom.setOpaque(false);
    tagsTableFrom.setBackground(null);
    tagsTableFrom.setBorder(null);
    tagsTableFrom.setShowGrid(false);

    tagsTableTo.setOpaque(false);
    tagsTableTo.setBackground(null);
    tagsTableTo.setBorder(null);
    tagsTableTo.setShowGrid(false);

    tagsTableFrom.getColumn("Tag Name").setCellEditor(new CellEditor(new JTextField()));
    tagsTableTo.getColumn("Tag Name").setCellEditor(new CellEditor(new JTextField()));

    fillTableTags();

    tagsTableFrom.setComponentPopupMenu(new JDefaultContextMenu(tagsTableFrom));
    tagsTableTo.setComponentPopupMenu(new JDefaultContextMenu(tagsTableTo));

    JScrollPane srollPane = new JScrollPane(tagsTableFrom);
    srollPane.setBorder(null);

    JScrollPane srollPane2 = new JScrollPane(tagsTableTo);
    srollPane.setBorder(null);

    panelFrom.add(srollPane);
    panelFrom.add(Box.createVerticalStrut(5));
    panelFrom.add(panelAddNewTag);

    panelTo.add(srollPane2);
    panelTo.add(Box.createVerticalStrut(5));
    panelTo.add(panelDeleteTags);

    panelListAddedTags.add(panelFrom);
    panelListAddedTags.add(Box.createHorizontalStrut(5));
    panelListAddedTags.add(panelMiddle);
    panelListAddedTags.add(Box.createHorizontalStrut(5));
    panelListAddedTags.add(panelTo);

    // -------

    JPanel panelButton = new JPanel();
    panelButton.setLayout(new BoxLayout(panelButton, BoxLayout.X_AXIS));
    panelButton.add(Box.createHorizontalGlue());
    panelButton.add(bOk);
    panelButton.add(Box.createHorizontalStrut(5));
    panelButton.add(bCancel);
    panelButton.add(Box.createHorizontalStrut(5));

    ComponentBuilder.makeComponent(new JCommentPanel(), gridbag, c, getContentPane());

    ComponentBuilder.makeComponent(panelLogin, gridbag, c, getContentPane());
    ComponentBuilder.makeComponent(panelForgotPassLink, gridbag, c, getContentPane());
    ComponentBuilder.makeComponent(panelFile, gridbag, c, getContentPane());
    ComponentBuilder.makeComponent(panelLocation, gridbag, c, getContentPane());
    ComponentBuilder.makeComponent(panelDMName, gridbag, c, getContentPane());

    c.fill = GridBagConstraints.BOTH;

    c.weighty = 2.0;
    ComponentBuilder.makeComponent(panelDMDescription, gridbag, c, getContentPane());

    c.weighty = 0.0;
    ComponentBuilder.makeComponent(autoGenerateShortDescription, gridbag, c, getContentPane());

    c.weighty = 1.0;
    ComponentBuilder.makeComponent(panelDMShortDescription, gridbag, c, getContentPane());

    c.weighty = 1.0;
    ComponentBuilder.makeComponent(panelTitleForTags, gridbag, c, getContentPane());

    c.weighty = 3.0;
    ComponentBuilder.makeComponent(panelListAddedTags, gridbag, c, getContentPane());

    c.weighty = 0.0;
    ComponentBuilder.makeComponent(new JSeparator(), gridbag, c, getContentPane());

    c.weighty = 1.0;
    ComponentBuilder.makeComponent(panelButton, gridbag, c, getContentPane());
}

From source file:com.rapidminer.gui.properties.OperatorPropertyPanel.java

@Override
public Component getComponent() {
    if (dockableComponent == null) {
        JScrollPane scrollPane = new ExtendedJScrollPane(this);
        scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
        scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
        scrollPane.setBorder(null);

        dockableComponent = new JPanel(new BorderLayout());

        JPanel toolBarPanel = new JPanel(new BorderLayout());
        ViewToolBar toolBar = new ViewToolBar();
        JToggleButton toggleExpertModeButton = mainFrame.TOGGLE_EXPERT_MODE_ACTION.createToggleButton();
        toggleExpertModeButton.setText(null);
        toolBar.add(toggleExpertModeButton);

        showHelpAction.setSelected(isShowParameterHelp());
        JToggleButton helpToggleButton = showHelpAction.createToggleButton();
        helpToggleButton.setText(null);// w ww  .  java2 s.com
        toolBar.add(helpToggleButton);

        Action infoOperatorAction = new InfoOperatorAction() {

            private static final long serialVersionUID = 6758272768665592429L;

            @Override
            protected Operator getOperator() {
                return mainFrame.getFirstSelectedOperator();
            }
        };
        toolBar.add(infoOperatorAction);
        JToggleButton enableOperatorButton = new ToggleActivationItem(mainFrame.getActions())
                .createToggleButton();
        enableOperatorButton.setText(null);
        toolBar.add(enableOperatorButton);
        Action renameOperatorAction = new ResourceAction(true, "rename_in_processrenderer") {

            {
                setCondition(OPERATOR_SELECTED, MANDATORY);
            }

            private static final long serialVersionUID = -3104160320178045540L;

            @Override
            public void actionPerformed(ActionEvent e) {
                Operator operator = mainFrame.getFirstSelectedOperator();
                String name = SwingTools.showInputDialog("rename_operator", operator.getName());
                if (name != null && name.length() > 0) {
                    operator.rename(name);
                }
            }
        };
        toolBar.add(renameOperatorAction);
        toolBar.add(new DeleteOperatorAction());
        breakpointButton.addToToolBar(toolBar);

        // toolBar.add(mainFrame.getActions().MAKE_DIRTY_ACTION);
        toolBarPanel.add(toolBar, BorderLayout.NORTH);

        JPanel headerPanel = new JPanel();
        headerPanel.setBackground(SwingTools.LIGHTEST_BLUE);
        headerPanel.add(headerLabel);
        headerPanel.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.LIGHT_GRAY));
        toolBarPanel.add(headerPanel, BorderLayout.SOUTH);

        dockableComponent.add(toolBarPanel, BorderLayout.NORTH);
        dockableComponent.add(scrollPane, BorderLayout.CENTER);

        // compatibility level and warnings
        JPanel southPanel = new JPanel(new BorderLayout());
        southPanel.add(expertModeHintLabel, BorderLayout.CENTER);
        compatibilityLabel.setLabelFor(compatibilityLevelSpinner);
        compatibilityLevelSpinner.setPreferredSize(
                new Dimension(80, (int) compatibilityLevelSpinner.getPreferredSize().getHeight()));
        compatibilityPanel.add(compatibilityLabel);
        compatibilityPanel.add(compatibilityLevelSpinner);
        southPanel.add(compatibilityPanel, BorderLayout.SOUTH);

        dockableComponent.add(southPanel, BorderLayout.SOUTH);
    }
    return dockableComponent;
}

From source file:dbseer.gui.panel.DBSeerLiveMonitorPanel.java

private void initialize() {
    JScrollPane tableScrollPane = new JScrollPane(monitorTable);
    tableScrollPane.setPreferredSize(new Dimension(300, 300));
    JScrollPane transactionTypesScrollPane = new JScrollPane();
    leftDockPanel = new JPanel();
    leftDockPanel.setLayout(new MigLayout("fill"));
    transactionTypesPanel = new JPanel();
    transactionTypesPanel.setLayout(new MigLayout("wrap 3"));
    rightPanel = new JPanel();
    rightPanel.setLayout(new MigLayout("fill"));
    rightPanel.setPreferredSize(new Dimension(640, 480));

    transactionTypesScrollPane.setViewportView(transactionTypesPanel);
    transactionTypesScrollPane.setBorder(BorderFactory.createTitledBorder("Transaction types"));
    transactionTypesScrollPane.setPreferredSize(new Dimension(360, 300));

    throughputCollection = new TimeSeriesCollection();
    throughputChartPanel = new ChartPanel(createThroughputChart(throughputCollection));

    latencyCollection = new TimeSeriesCollection();
    latencyChartPanel = new ChartPanel(createAverageLatencyChart(latencyCollection));

    leftDockPanel.add(tableScrollPane, "wrap, grow");
    leftDockPanel.add(transactionTypesScrollPane, "grow");

    rightPanel.add(throughputChartPanel, "grow, wrap");
    rightPanel.add(latencyChartPanel, "grow");

    this.add(leftDockPanel, "dock west, growy");
    this.add(rightPanel, "grow");
}

From source file:ca.phon.app.session.editor.view.segmentation.SegmentationEditorView.java

private void init() {
    segmentWindowField = new JTextField();
    SegmentWindowDocument segDoc = new SegmentWindowDocument();
    segmentWindowField.setDocument(segDoc);
    segmentWindowField.setText(DEFAULT_SEGMENT_WINDOW + "");
    segDoc.addDocumentListener(new SegmentWindowListener());

    segmentLabel = new SegmentLabel();
    segmentLabel.setSegmentWindow(DEFAULT_SEGMENT_WINDOW);
    segmentLabel.setCurrentTime(0L);/*from  w  ww . j  a  v a 2 s.com*/
    segmentLabel.lockSegmentStartTime(-1L);

    modeBox = new JComboBox(SegmentationMode.values());
    modeBox.setSelectedItem(SegmentationMode.INSERT_AFTER_CURRENT);

    JPanel topPanel = new JPanel();
    FormLayout topLayout = new FormLayout("right:pref, 3dlu, fill:default:grow, pref",
            "pref, pref, pref, pref");
    topPanel.setLayout(topLayout);
    CellConstraints cc = new CellConstraints();
    topPanel.add(new JLabel("Segment Window"), cc.xy(1, 1));
    topPanel.add(segmentWindowField, cc.xy(3, 1));
    topPanel.add(new JLabel("ms"), cc.xy(4, 1));

    JLabel infoLabel = new JLabel("Set to 0 for unlimited segment time");
    infoLabel.setFont(infoLabel.getFont().deriveFont(10.0f));

    topPanel.add(infoLabel, cc.xy(3, 2));
    topPanel.add(new JLabel("Current Window"), cc.xy(1, 3));
    topPanel.add(segmentLabel, cc.xy(3, 3));

    topPanel.add(new JLabel("Mode"), cc.xy(1, 4));
    topPanel.add(modeBox, cc.xyw(3, 4, 2));

    setLayout(new BorderLayout());
    add(topPanel, BorderLayout.NORTH);

    participantPanel = new JPanel();

    participantPanel.setBackground(Color.white);
    participantPanel.setOpaque(true);

    JScrollPane participantScroller = new JScrollPane(participantPanel);
    Dimension prefSize = participantScroller.getPreferredSize();
    prefSize.height = 150;
    participantScroller.setPreferredSize(prefSize);
    Dimension maxSize = participantScroller.getMaximumSize();
    maxSize.height = 200;
    participantScroller.setMaximumSize(maxSize);
    Dimension minSize = participantScroller.getMinimumSize();
    minSize.height = 100;
    participantScroller.setMinimumSize(minSize);
    participantScroller.setBorder(BorderFactory.createTitledBorder("Participants"));

    add(participantScroller, BorderLayout.CENTER);

    updateParticipantPanel();
    setupEditorActions();
}

From source file:ca.sqlpower.wabit.swingui.chart.ChartPanel.java

private void buildUI() {

    // First level in the panel has only 2 rows of 1 column
    panel.setLayout(new MigLayout("fill", "[grow, fill]", "[shrink]10[grow, fill]"));

    panel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.GRAY),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    // Now we build the upper part. 
    // The "data" section.
    JPanel topPanel = new JPanel(new MigLayout("fill", "[115]10[fill, grow]", "[]10[]10[400]"));

    JLabel dataCategoryLabel = new JLabel("Data");
    dataCategoryLabel.setFont(dataCategoryLabel.getFont().deriveFont(Font.BOLD));
    topPanel.add(dataCategoryLabel, "span, wrap");

    topPanel.add(new JLabel("Data source"), "gapleft 15");
    topPanel.add(queryComboBox, "wrap");

    JScrollPane tableScrollPane = new JScrollPane(resultTable);
    topPanel.add(headerLegendContainer, "gapleft 15, aligny top");
    topPanel.add(tableScrollPane);/* w  w w. ja va 2  s .  co  m*/

    panel.add(topPanel, "wrap");

    // Now the lower part. It has two parts. The options scrolling pane and the preview.
    JPanel bottomPanel = new JPanel(
            new MigLayout("fill, hidemode 2", "[grow]10[fill, shrinkprio 101]", "[fill]"));

    JLabel optionsCategoryLabel = new JLabel("Options");
    optionsCategoryLabel.setFont(optionsCategoryLabel.getFont().deriveFont(Font.BOLD));
    bottomPanel.add(optionsCategoryLabel);

    JLabel previewCategoryLabel = new JLabel("Preview");
    previewCategoryLabel.setFont(previewCategoryLabel.getFont().deriveFont(Font.BOLD));
    bottomPanel.add(previewCategoryLabel, "wrap");

    JScrollPane optionsScrollPane = new JScrollPane(buildChartPrefsPanel(),
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    optionsScrollPane.setBorder(null);
    bottomPanel.add(optionsScrollPane, "push, gapleft 15");

    JPanel chartAndErrorPanel = new JPanel(new BorderLayout());
    chartAndErrorPanel.add(chartError, BorderLayout.NORTH);
    chartAndErrorPanel.add(chartPanel, BorderLayout.CENTER);
    bottomPanel.add(chartAndErrorPanel, "width 100%, alignx left, gapleft 15");

    panel.add(bottomPanel, "height 100%");

    toolBarBuilder.add(refreshDataAction);
    toolBarBuilder.add(revertToDefaultsAction);

    //Since the first button on the tool bar will be displayed this size will be the
    //same as the font size of a displayed button. If the button wasn't being displayed
    //the font size ends up incorrect
    float fontSize = toolBarBuilder.getToolbar().getComponentAtIndex(0).getFont().getSize();

    toolBarBuilder.addSeparator();
    toolBarBuilder.add(makeChartTypeButton("Bar", ChartType.BAR, BAR_CHART_ICON, fontSize));
    toolBarBuilder.add(makeChartTypeButton("Pie", ChartType.PIE, PIE_CHART_ICON, fontSize));
    toolBarBuilder
            .add(makeChartTypeButton("Category Line", ChartType.CATEGORY_LINE, LINE_CHART_ICON, fontSize));

    toolBarBuilder.addSeparator();
    toolBarBuilder.add(makeChartTypeButton("Line", ChartType.LINE, LINE_CHART_ICON, fontSize));
    toolBarBuilder.add(makeChartTypeButton("Scatter", ChartType.SCATTER, SCATTER_CHART_ICON, fontSize));
}

From source file:com.net2plan.gui.tools.GUINetworkDesign.java

private JPanel configureLeftBottomPanel() {
    this.focusPanel = new FocusPane(this);
    final JPanel focusPanelContainer = new JPanel(new BorderLayout());
    final JToolBar navigationToolbar = new JToolBar(JToolBar.VERTICAL);
    navigationToolbar.setRollover(true);
    navigationToolbar.setFloatable(false);
    navigationToolbar.setOpaque(false);//from  w  ww  . jav a 2s.  co m

    final JButton btn_pickNavigationUndo, btn_pickNavigationRedo;

    btn_pickNavigationUndo = new JButton("");
    btn_pickNavigationUndo
            .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/undoPick.png")));
    btn_pickNavigationUndo.setToolTipText("Navigate back to the previous element picked");
    btn_pickNavigationRedo = new JButton("");
    btn_pickNavigationRedo
            .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/redoPick.png")));
    btn_pickNavigationRedo.setToolTipText("Navigate forward to the next element picked");

    final ActionListener action = e -> {
        Pair<NetworkElement, Pair<Demand, Link>> backOrForward;
        do {
            backOrForward = (e.getSource() == btn_pickNavigationUndo)
                    ? GUINetworkDesign.this.getVisualizationState().getPickNavigationBackElement()
                    : GUINetworkDesign.this.getVisualizationState().getPickNavigationForwardElement();
            if (backOrForward == null)
                break;
            final NetworkElement ne = backOrForward.getFirst(); // For network elements
            final Pair<Demand, Link> fr = backOrForward.getSecond(); // For forwarding rules
            if (ne != null) {
                if (ne.getNetPlan() != GUINetworkDesign.this.getDesign())
                    continue;
                if (ne.getNetPlan() == null)
                    continue;
                break;
            } else if (fr != null) {
                if (fr.getFirst().getNetPlan() != GUINetworkDesign.this.getDesign())
                    continue;
                if (fr.getFirst().getNetPlan() == null)
                    continue;
                if (fr.getSecond().getNetPlan() != GUINetworkDesign.this.getDesign())
                    continue;
                if (fr.getSecond().getNetPlan() == null)
                    continue;
                break;
            } else
                break; // null,null => reset picked state
        } while (true);
        if (backOrForward != null) {
            if (backOrForward.getFirst() != null)
                GUINetworkDesign.this.getVisualizationState().pickElement(backOrForward.getFirst());
            else if (backOrForward.getSecond() != null)
                GUINetworkDesign.this.getVisualizationState().pickForwardingRule(backOrForward.getSecond());
            else
                GUINetworkDesign.this.getVisualizationState().resetPickedState();

            GUINetworkDesign.this.updateVisualizationAfterPick();
        }
    };

    btn_pickNavigationUndo.addActionListener(action);
    btn_pickNavigationRedo.addActionListener(action);

    btn_pickNavigationRedo.setFocusable(false);
    btn_pickNavigationUndo.setFocusable(false);

    navigationToolbar.add(btn_pickNavigationUndo);
    navigationToolbar.add(btn_pickNavigationRedo);

    final JScrollPane scPane = new JScrollPane(focusPanel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scPane.getVerticalScrollBar().setUnitIncrement(20);
    scPane.getHorizontalScrollBar().setUnitIncrement(20);
    scPane.setBorder(BorderFactory.createEmptyBorder());

    // Control the scroll
    scPane.getHorizontalScrollBar().addAdjustmentListener(e -> {
        // Repaints the panel each time the horizontal scroll bar is moves, in order to avoid ghosting.
        focusPanelContainer.revalidate();
        focusPanelContainer.repaint();
    });

    focusPanelContainer.add(navigationToolbar, BorderLayout.WEST);
    focusPanelContainer.add(scPane, BorderLayout.CENTER);

    JPanel pane = new JPanel(new MigLayout("fill, insets 0 0 0 0"));
    pane.setBorder(BorderFactory.createTitledBorder(new LineBorder(Color.BLACK), "Focus panel"));

    pane.add(focusPanelContainer, "grow");
    return pane;
}