Example usage for javax.swing JScrollPane setVerticalScrollBarPolicy

List of usage examples for javax.swing JScrollPane setVerticalScrollBarPolicy

Introduction

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

Prototype

@BeanProperty(preferred = true, enumerationValues = { "ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED",
        "ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER",
        "ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS" }, description = "The scrollpane vertical scrollbar policy")
public void setVerticalScrollBarPolicy(int policy) 

Source Link

Document

Determines when the vertical scrollbar appears in the scrollpane.

Usage

From source file:com.emental.mindraider.ui.outline.OutlineArchiveJPanel.java

public OutlineArchiveJPanel() {
    setLayout(new BorderLayout());

    // table with archived concepts (title)
    // let table model to load discarded concepts itself
    tableModel = new ArchiveTableModel(this);
    table = new JTable(tableModel);
    table.setAutoCreateRowSorter(true);/*from  ww w  .  j  a v  a 2  s.  co m*/
    JScrollPane scroll = new JScrollPane(table);
    table.setFillsViewportHeight(true);
    table.setShowHorizontalLines(false);
    table.setShowVerticalLines(false);
    table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    JToolBar toolbar = new JToolBar();

    undoButton = new JButton("", IconsRegistry.getImageIcon("trashUndo.png"));
    undoButton.setEnabled(false);
    undoButton.setToolTipText("Restore Note");
    undoButton.addActionListener(new UndiscardConceptActionListener(tableModel, table));
    toolbar.add(undoButton);

    deleteButton = new JButton("", IconsRegistry.getImageIcon("explorerDeleteSmall.png"));
    deleteButton.setEnabled(true);
    deleteButton.setToolTipText("Delete Note");
    deleteButton.addActionListener(new DeleteConceptActionListener(tableModel, table));
    toolbar.add(deleteButton);

    purgeButton = new JButton("", IconsRegistry.getImageIcon("trashFull.png"));
    purgeButton.setEnabled(true);
    purgeButton.setToolTipText("Empty Notes Archive");
    purgeButton.addActionListener(new EmptyArchiveActionListener());
    toolbar.add(purgeButton);

    add(toolbar, BorderLayout.NORTH);

    add(scroll, BorderLayout.CENTER);
}

From source file:jmap2gml.ScriptGui.java

/**
 * Formats the window, initializes the JMap2Script object, and sets up all
 * the necessary events.//from w  w w .  java  2 s .  c  om
 */
public ScriptGui() {
    setTitle("jmap to gml script converter");
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    getContentPane().setLayout(new GridBagLayout());

    this.addWindowListener(new WindowListener() {
        @Override
        public void windowOpened(WindowEvent we) {
        }

        @Override
        public void windowClosing(WindowEvent we) {
            saveConfig();
        }

        @Override
        public void windowClosed(WindowEvent we) {
        }

        @Override
        public void windowIconified(WindowEvent we) {
        }

        @Override
        public void windowDeiconified(WindowEvent we) {
        }

        @Override
        public void windowActivated(WindowEvent we) {
        }

        @Override
        public void windowDeactivated(WindowEvent we) {
        }
    });

    GridBagConstraints c = new GridBagConstraints();

    setResizable(true);
    setIconImage((new ImageIcon("spikeup.png")).getImage());

    jta = new JTextArea(38, 30);

    loadConfig();

    JScrollPane jsp = new JScrollPane(jta);
    jsp.setRowHeaderView(new TextLineNumber(jta));
    jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    jsp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    jsp.setSize(jsp.getWidth(), 608);

    // menu bar
    JMenuBar menubar = new JMenuBar();

    // file menu
    JMenu file = new JMenu("File");

    // load button
    JMenuItem load = new JMenuItem("Load jmap");
    load.addActionListener(ae -> {
        JFileChooser fileChooser = new JFileChooser(prevDirectory);
        fileChooser.setFileFilter(new FileNameExtensionFilter("jmap file", "jmap", "jmap"));

        int returnValue = fileChooser.showOpenDialog(null);

        if (returnValue == JFileChooser.APPROVE_OPTION) {
            File selectedFile = fileChooser.getSelectedFile();

            prevDirectory = selectedFile.getAbsolutePath();

            jm2s = new ScriptFromJmap(selectedFile.getPath(), false);

            jta.setText("");
            jta.append(jm2s.toString());
            jta.setCaretPosition(0);

            writeFile.setEnabled(true);

            drawPanel.setItems(jta.getText().split("\n"));
        }
    });

    // add load to file menu
    file.add(load);

    // button to save script to file
    writeFile = new JMenuItem("Write file");
    writeFile.addActionListener(ae -> {
        if (jm2s != null) {
            PrintWriter out;
            try {
                File f = new File(
                        jm2s.getFileName().substring(0, jm2s.getFileName().lastIndexOf(".jmap")) + ".gml");
                out = new PrintWriter(f);
                out.append(jm2s.toString());
                out.close();
            } catch (FileNotFoundException ex) {
                Logger.getLogger(ScriptGui.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    });
    writeFile.setEnabled(false);

    JMenuItem gmx = new JMenuItem("Export as gmx");
    gmx.addActionListener(ae -> {
        String fn = String.format("%s.room.gmx", prevDirectory);

        JFileChooser fc = new JFileChooser(prevDirectory);
        fc.setSelectedFile(new File(fn));
        fc.setFileFilter(new FileNameExtensionFilter("Game Maker XML", "gmx", "gmx"));
        fc.showDialog(null, "Save");
        File f = fc.getSelectedFile();

        if (f != null) {
            try {
                GMX.itemsToGMX(drawPanel.items, new FileOutputStream(f));
            } catch (FileNotFoundException ex) {
                Logger.getLogger(ScriptGui.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    });

    // add to file menu
    file.add(writeFile);
    file.add(gmx);

    // add file menu to the menubar
    menubar.add(file);

    // Edit menu

    // display menu
    JMenu display = new JMenu("Display");

    JMenuItem update = new JMenuItem("Update");

    update.addActionListener(ae -> {
        drawPanel.setItems(jta.getText().split("\n"));
    });

    display.add(update);

    JMenuItem gridToggle = new JMenuItem("Toggle Grid");
    gridToggle.addActionListener(ae -> {
        drawPanel.toggleGrid();
    });
    display.add(gridToggle);

    JMenuItem gridOptions = new JMenuItem("Modify Grid");
    gridOptions.addActionListener(ae -> {
        drawPanel.modifyGrid();
    });
    display.add(gridOptions);

    menubar.add(display);

    // sets the menubar
    setJMenuBar(menubar);

    // add the text area to the window
    c.gridx = 0;
    c.gridy = 0;
    add(jsp, c);

    // initialize the preview panel
    drawPanel = new Preview(this);
    JScrollPane scrollPane = new JScrollPane(drawPanel);

    // add preview panel to the window
    c.gridx = 1;
    c.gridwidth = 2;
    add(scrollPane, c);

    pack();
    setMinimumSize(this.getSize());
    setLocationRelativeTo(null);
    setVisible(true);
    drawPanel.setItems(jta.getText().split("\n"));
}

From source file:hspc.submissionsprogram.AppDisplay.java

AppDisplay() {
    this.setTitle("Dominion High School Programming Contest");
    this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    this.setResizable(false);

    WindowListener exitListener = new WindowAdapter() {
        @Override/*from  ww w  .  j a v  a 2  s . c o m*/
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    this.addWindowListener(exitListener);

    JTabbedPane pane = new JTabbedPane();
    this.add(pane);

    JPanel submitPanel = new JPanel(null);
    submitPanel.setPreferredSize(new Dimension(500, 500));

    UIManager.put("FileChooser.readOnly", true);
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.setBounds(0, 0, 500, 350);
    fileChooser.setVisible(true);
    FileNameExtensionFilter javaFilter = new FileNameExtensionFilter("Java files (*.java)", "java");
    fileChooser.setFileFilter(javaFilter);
    fileChooser.setAcceptAllFileFilterUsed(false);
    fileChooser.setControlButtonsAreShown(false);
    submitPanel.add(fileChooser);

    JSeparator separator1 = new JSeparator();
    separator1.setBounds(12, 350, 476, 2);
    separator1.setForeground(new Color(122, 138, 152));
    submitPanel.add(separator1);

    JLabel problemChooserLabel = new JLabel("Problem:");
    problemChooserLabel.setBounds(12, 360, 74, 25);
    submitPanel.add(problemChooserLabel);

    String[] listOfProblems = Main.Configuration.get("problem_names")
            .split(Main.Configuration.get("name_delimiter"));
    JComboBox problems = new JComboBox<>(listOfProblems);
    problems.setBounds(96, 360, 393, 25);
    submitPanel.add(problems);

    JButton submit = new JButton("Submit");
    submit.setBounds(170, 458, 160, 30);
    submit.addActionListener(e -> {
        try {
            File file = fileChooser.getSelectedFile();
            try {
                CloseableHttpClient httpClient = HttpClients.createDefault();
                HttpPost uploadFile = new HttpPost(Main.Configuration.get("submit_url"));

                MultipartEntityBuilder builder = MultipartEntityBuilder.create();
                builder.addTextBody("accountID", Main.accountID, ContentType.TEXT_PLAIN);
                builder.addTextBody("problem", String.valueOf(problems.getSelectedItem()),
                        ContentType.TEXT_PLAIN);
                builder.addBinaryBody("submission", file, ContentType.APPLICATION_OCTET_STREAM, file.getName());
                HttpEntity multipart = builder.build();

                uploadFile.setEntity(multipart);

                CloseableHttpResponse response = httpClient.execute(uploadFile);
                HttpEntity responseEntity = response.getEntity();
                String inputLine;
                BufferedReader br = new BufferedReader(new InputStreamReader(responseEntity.getContent()));
                try {
                    if ((inputLine = br.readLine()) != null) {
                        int rowIndex = Integer.parseInt(inputLine);
                        new ResultWatcher(rowIndex);
                    }
                    br.close();
                } catch (IOException ex) {
                    ex.printStackTrace();
                }
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        } catch (NullPointerException ex) {
            JOptionPane.showMessageDialog(this, "No file selected.\nPlease select a java file.", "Error",
                    JOptionPane.WARNING_MESSAGE);
        }
    });
    submitPanel.add(submit);

    JPanel clarificationsPanel = new JPanel(null);
    clarificationsPanel.setPreferredSize(new Dimension(500, 500));

    cList = new JList<>();
    cList.setBounds(12, 12, 476, 200);
    cList.setBorder(new CompoundBorder(BorderFactory.createLineBorder(new Color(122, 138, 152)),
            BorderFactory.createEmptyBorder(8, 8, 8, 8)));
    cList.setBackground(new Color(254, 254, 255));
    clarificationsPanel.add(cList);

    JButton viewC = new JButton("View");
    viewC.setBounds(12, 224, 232, 25);
    viewC.addActionListener(e -> {
        if (cList.getSelectedIndex() != -1) {
            int id = Integer.parseInt(cList.getSelectedValue().split("\\.")[0]);
            clarificationDatas.stream().filter(data -> data.getId() == id).forEach(
                    data -> new ClarificationDisplay(data.getProblem(), data.getText(), data.getResponse()));
        }
    });
    clarificationsPanel.add(viewC);

    JButton refreshC = new JButton("Refresh");
    refreshC.setBounds(256, 224, 232, 25);
    refreshC.addActionListener(e -> updateCList(true));
    clarificationsPanel.add(refreshC);

    JSeparator separator2 = new JSeparator();
    separator2.setBounds(12, 261, 476, 2);
    separator2.setForeground(new Color(122, 138, 152));
    clarificationsPanel.add(separator2);

    JLabel problemChooserLabelC = new JLabel("Problem:");
    problemChooserLabelC.setBounds(12, 273, 74, 25);
    clarificationsPanel.add(problemChooserLabelC);

    JComboBox problemsC = new JComboBox<>(listOfProblems);
    problemsC.setBounds(96, 273, 393, 25);
    clarificationsPanel.add(problemsC);

    JTextArea textAreaC = new JTextArea();
    textAreaC.setLineWrap(true);
    textAreaC.setWrapStyleWord(true);
    textAreaC.setBorder(new CompoundBorder(BorderFactory.createLineBorder(new Color(122, 138, 152)),
            BorderFactory.createEmptyBorder(8, 8, 8, 8)));
    textAreaC.setBackground(new Color(254, 254, 255));

    JScrollPane areaScrollPane = new JScrollPane(textAreaC);
    areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    areaScrollPane.setBounds(12, 312, 477, 134);
    clarificationsPanel.add(areaScrollPane);

    JButton submitC = new JButton("Submit Clarification");
    submitC.setBounds(170, 458, 160, 30);
    submitC.addActionListener(e -> {
        if (textAreaC.getText().length() > 2048) {
            JOptionPane.showMessageDialog(this,
                    "Clarification body is too long.\nMaximum of 2048 characters allowed.", "Error",
                    JOptionPane.WARNING_MESSAGE);
        } else if (textAreaC.getText().length() < 20) {
            JOptionPane.showMessageDialog(this,
                    "Clarification body is too short.\nClarifications must be at least 20 characters, but no more than 2048.",
                    "Error", JOptionPane.WARNING_MESSAGE);
        } else {
            Connection conn = null;
            PreparedStatement stmt = null;
            try {
                Class.forName(JDBC_DRIVER);

                conn = DriverManager.getConnection(Main.Configuration.get("jdbc_mysql_address"),
                        Main.Configuration.get("mysql_user"), Main.Configuration.get("mysql_pass"));

                String sql = "INSERT INTO clarifications (team, problem, text) VALUES (?, ?, ?)";
                stmt = conn.prepareStatement(sql);

                stmt.setInt(1, Integer.parseInt(String.valueOf(Main.accountID)));
                stmt.setString(2, String.valueOf(problemsC.getSelectedItem()));
                stmt.setString(3, String.valueOf(textAreaC.getText()));

                textAreaC.setText("");

                stmt.executeUpdate();

                stmt.close();
                conn.close();

                updateCList(false);
            } catch (Exception ex) {
                ex.printStackTrace();
            } finally {
                try {
                    if (stmt != null) {
                        stmt.close();
                    }
                } catch (Exception ex2) {
                    ex2.printStackTrace();
                }
                try {
                    if (conn != null) {
                        conn.close();
                    }
                } catch (Exception ex2) {
                    ex2.printStackTrace();
                }
            }
        }
    });
    clarificationsPanel.add(submitC);

    pane.addTab("Submit", submitPanel);
    pane.addTab("Clarifications", clarificationsPanel);

    Timer timer = new Timer();
    TimerTask updateTask = new TimerTask() {
        @Override
        public void run() {
            updateCList(false);
        }
    };
    timer.schedule(updateTask, 10000, 10000);

    updateCList(false);

    this.pack();
    this.setLocationRelativeTo(null);
    this.setVisible(true);
}

From source file:net.sf.mzmine.chartbasics.graphicsexport.GraphicsExportDialog.java

/**
 * Create the dialog.//from   www .  j a v  a  2 s  .  com
 */
public GraphicsExportDialog() {
    final JFrame thisframe = this;
    //
    parameters = new GraphicsExportParameters();
    chartParam = new ChartThemeParameters();
    parametersAndComponents = new HashMap<String, JComponent>();

    String[] formats = parameters.getParameter(GraphicsExportParameters.exportFormat).getChoices();
    chooser.addChoosableFileFilter(new FileTypeFilter(formats, "Export images"));
    chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    //
    setBounds(100, 100, 808, 795);
    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    contentPanel.setLayout(new MigLayout("", "[][][grow]", "[][][][grow]"));
    {
        StringParameter p = parameters.getParameter(GraphicsExportParameters.path);
        StringComponent txtPath = p.createEditingComponent();
        contentPanel.add(txtPath, "flowx,cell 0 0,growx");
        parametersAndComponents.put(p.getName(), txtPath);
    }
    {
        btnPath = new JButton("Path");
        btnPath.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                choosePath();
            }
        });
        contentPanel.add(btnPath, "cell 1 0");
    }
    {
        StringParameter p = parameters.getParameter(GraphicsExportParameters.filename);
        StringComponent txtFileName = p.createEditingComponent();
        contentPanel.add(txtFileName, "cell 0 1,growx");
        parametersAndComponents.put(p.getName(), txtFileName);
    }
    {
        JLabel lblFilename = new JLabel("filename");
        contentPanel.add(lblFilename, "cell 1 1");
    }
    {
        JPanel pnSettingsLeft = new JPanel();
        pnSettingsLeft.setMinimumSize(new Dimension(260, 260));
        contentPanel.add(pnSettingsLeft, "cell 0 3,grow");
        pnSettingsLeft.setLayout(new BorderLayout(0, 0));
        {

            GridBagPanel pn = new GridBagPanel();
            {
                // add unit
                UserParameter p;
                JComponent comp;
                // add unit
                p = (UserParameter) parameters.getParameter(GraphicsExportParameters.unit);
                comp = p.createEditingComponent();
                comp.setToolTipText(p.getDescription());
                comp.setEnabled(true);
                pn.add(comp, 2, 2);
                parametersAndComponents.put(p.getName(), comp);

                int i = 0;
                // add export settings
                Parameter[] param = parameters.getParameters();
                for (int pi = 3; pi < param.length; pi++) {
                    p = (UserParameter) param[pi];
                    comp = p.createEditingComponent();
                    comp.setToolTipText(p.getDescription());
                    comp.setEnabled(true);
                    pn.add(new JLabel(p.getName()), 0, i);
                    pn.add(comp, 1, i, 1, 1, 1, 1);
                    // add to map
                    parametersAndComponents.put(p.getName(), comp);
                    i++;
                }

                // add separator
                pn.add(new JSeparator(), 0, i, 5, 1, 1, 1, GridBagConstraints.BOTH);
                i++;
                // add Apply theme button
                JButton btnApply2 = new JButton("Apply theme");
                btnApply2.addActionListener(e -> applyTheme());
                pn.add(btnApply2, 0, i, 5, 1, 1, 1, GridBagConstraints.BOTH);
                i++;

                // add chart settings
                param = chartParam.getParameters();
                for (int pi = 0; pi < param.length; pi++) {
                    p = (UserParameter) param[pi];
                    comp = p.createEditingComponent();
                    comp.setToolTipText(p.getDescription());
                    comp.setEnabled(true);
                    pn.add(new JLabel(p.getName()), 0, i);
                    pn.add(comp, 1, i, 4, 1);
                    // add to map
                    parametersAndComponents.put(p.getName(), comp);
                    i++;
                }

                // add listener to master font
                JFontSpecs master = (JFontSpecs) parametersAndComponents
                        .get(chartParam.getParameter(ChartThemeParameters.masterFont).getName());
                master.addListener(fspec -> {
                    if (listenersEnabled)
                        handleMasterFontChanged(fspec);
                });
            }

            JScrollPane scrollPane = new JScrollPane(pn);
            scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
            pnSettingsLeft.add(scrollPane, BorderLayout.CENTER);
            scrollPane.getVerticalScrollBar().setUnitIncrement(18);
            scrollPane.revalidate();
            scrollPane.repaint();
        }
    }
    {
        {
            pnChartPreview = new JPanel();
            pnChartPreview.setLayout(null);
            contentPanel.add(pnChartPreview, "cell 1 3 2 1,grow");
        }
    }
    {
        JPanel buttonPane = new JPanel();
        buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
        getContentPane().add(buttonPane, BorderLayout.SOUTH);
        {
            JButton okButton = new JButton("Save");
            okButton.addActionListener(e -> saveGraphicsAs());
            okButton.setActionCommand("OK");
            buttonPane.add(okButton);
            getRootPane().setDefaultButton(okButton);
        }
        {
            btnRenewPreview = new JButton("Renew Preview");
            btnRenewPreview.addActionListener(e -> renewPreview());
            buttonPane.add(btnRenewPreview);
        }
        {
            btnApply = new JButton("Apply theme");
            btnApply.addActionListener(e -> applyTheme());
            buttonPane.add(btnApply);
        }
        {
            JButton cancelButton = new JButton("Cancel");
            cancelButton.addActionListener(e -> setVisible(false));
            cancelButton.setActionCommand("Cancel");
            buttonPane.add(cancelButton);
        }
    }
    // set all to components
    updateComponentsFromParameters();
}

From source file:ca.sqlpower.architect.swingui.ProfileGraphPanel.java

public ProfileGraphPanel(ProfilePanel panel, int rowCount) {
    this.profilePanel = panel;
    this.rowCount = rowCount;

    FormLayout displayLayout = new FormLayout("4dlu, default, 4dlu, 100dlu, 4dlu, fill:default:grow, 4dlu", // columns
            "4dlu, default, 6dlu"); // rows
    CellConstraints cc = new CellConstraints();

    validResultsPanel = ProfileGraphPanel.logger.isDebugEnabled() ? new FormDebugPanel(displayLayout)
            : new JPanel(displayLayout);
    validResultsPanel.setBorder(BorderFactory.createEtchedBorder());

    Font bodyFont = validResultsPanel.getFont();
    Font titleFont = bodyFont.deriveFont(Font.BOLD, bodyFont.getSize() * 1.25F);

    title = new JLabel("Column Name");
    title.setFont(titleFont);/*from   w w  w.  j a v  a 2 s . c  om*/

    PanelBuilder pb = new PanelBuilder(displayLayout, validResultsPanel);
    pb.add(title, cc.xyw(2, 2, 5));

    int row = 4;
    rowCountDisplay = makeInfoRow(pb, "RowCount", row);
    row += 2;
    nullableLabel = makeInfoRow(pb, "Nullable", row);
    row += 2;
    nullCountLabel = makeInfoRow(pb, "Null Count", row);
    row += 2;
    nullPercentLabel = makeInfoRow(pb, "% Null Records", row);
    row += 2;
    minLengthLabel = makeInfoRow(pb, "Minimum Length", row);
    row += 2;
    maxLengthLabel = makeInfoRow(pb, "Maximum Length", row);
    row += 2;
    uniqueCountLabel = makeInfoRow(pb, "Unique Values", row);
    row += 2;
    uniquePercentLabel = makeInfoRow(pb, "% Unique", row);
    row += 2;
    minValue = makeInfoRow(pb, "Minimum Value", row);
    row += 2;
    maxValue = makeInfoRow(pb, "Maximum Value", row);
    row += 2;
    avgValue = makeInfoRow(pb, "Average Value", row);
    row += 2;

    freqValueTable = new FreqValueTable(null);
    freqValueSp = new JScrollPane(freqValueTable);

    pb.appendRow("fill:10dlu:grow");
    pb.appendRow("fill:default:grow");
    pb.add(freqValueSp, cc.xyw(2, row + 1, 3));

    // Now add something to represent the chart
    JFreeChart createPieChart = ChartFactory.createPieChart("", new DefaultPieDataset(new DefaultKeyedValues()),
            false, false, false);
    chartPanel = new ChartPanel(createPieChart);
    chartPanel.setPreferredSize(new Dimension(300, 300));

    if (panel.getProfileManager().getWorkspaceContainer() instanceof ArchitectSession
            && ((ArchitectSession) panel.getProfileManager().getWorkspaceContainer()).isEnterpriseSession()) {
        pb.add(new JLabel("Column Profile Notes"), cc.xy(6, 2));
        notesField = new JTextArea();
        notesField.setLineWrap(true);
        notesField.setWrapStyleWord(true);
        JScrollPane notesScroll = new JScrollPane(notesField);
        notesScroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        notesScroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        pb.add(notesScroll, cc.xywh(6, 4, 1, row - 4));

        pb.appendRow("fill:4dlu:grow");
        pb.appendRow("4dlu");

        pb.add(chartPanel, cc.xy(6, row + 1));
    } else {
        pb.appendRow("fill:4dlu:grow");
        pb.appendRow("4dlu");
        pb.add(chartPanel, cc.xywh(6, 4, 1, row - 2));
    }

    invalidResultsPanel = new JPanel(new BorderLayout());
    invalidResultsLabel = new JLabel("No error message yet");
    invalidResultsPanel.add(invalidResultsLabel);

    displayArea = new JPanel(new GridLayout(1, 1));
    displayArea.setPreferredSize(validResultsPanel.getPreferredSize());
}

From source file:dk.dma.epd.common.prototype.gui.voct.VOCTAdditionalInfoPanel.java

/**
 * Constructor/* ww  w  .  j ava 2 s . c o m*/
 * 
 * @param compactLayout
 *            if false, there will be message type selectors in the panel
 */
public VOCTAdditionalInfoPanel(boolean compactLayout) {
    super(new BorderLayout());

    EPD.getInstance().getVoctHandler().addVoctSarInfoListener(this);

    // Prepare the title header
    titleHeader.setBackground(getBackground().darker());
    titleHeader.setOpaque(true);
    titleHeader.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    titleHeader.setHorizontalAlignment(SwingConstants.CENTER);
    add(titleHeader, BorderLayout.NORTH);

    // Add messages panel
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    messagesPanel.setBackground(UIManager.getColor("List.background"));
    messagesPanel.setOpaque(false);
    messagesPanel.setLayout(new GridBagLayout());
    messagesPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    add(scrollPane, BorderLayout.CENTER);

    JPanel sendPanel = new JPanel(new GridBagLayout());
    add(sendPanel, BorderLayout.SOUTH);
    Insets insets = new Insets(2, 2, 2, 2);

    // Add text area
    // if (false) {
    // messageText = new JTextField();
    // ((JTextField) messageText).addActionListener(this);
    // sendPanel.add(messageText, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, NORTH, BOTH, insets, 0, 0));
    //
    // } else {
    messageText = new JTextArea();
    JScrollPane scrollPane2 = new JScrollPane(messageText);
    scrollPane2.setPreferredSize(new Dimension(100, 50));
    scrollPane2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane2.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    sendPanel.add(scrollPane2, new GridBagConstraints(0, 0, 1, 2, 1.0, 1.0, NORTH, BOTH, insets, 0, 0));
    // }

    // Add buttons
    // ButtonGroup group = new ButtonGroup();

    if (!compactLayout) {
        JToolBar msgTypePanel = new JToolBar();
        msgTypePanel.setBorderPainted(false);
        msgTypePanel.setOpaque(true);
        msgTypePanel.setFloatable(false);
        sendPanel.add(msgTypePanel, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, NORTH, NONE, insets, 0, 0));

    }

    if (compactLayout) {
        addBtn = new JButton("Add to Log");
        sendPanel.add(addBtn, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, NORTH, NONE, insets, 0, 0));
    }
    // addBtn.setEnabled(false);
    // messageText.setEditable(false);
    addBtn.addActionListener(this);
}

From source file:main.MainPanel.java

/**
 * Initialization of all the component/*from  w  w w.ja  v  a  2 s . com*/
 */
public void initComponents() {
    BorderLayout layout = new BorderLayout();
    this.setLayout(layout);

    buttonGroup.add(socketRadioButton);
    socketRadioButton.setSelected(true);

    persistentGroup.add(persistentRadioButton);
    persistentGroup.add(notPersistentRadioButton);
    notPersistentRadioButton.setSelected(true);

    // Initialization of Labels,TextFields and RadioButtons
    JPanel paramsPanel = new JPanel();
    GridLayout paramsLayout = new GridLayout(16, 2);
    paramsPanel.setLayout(paramsLayout);
    paramsPanel.add(new JLabel("username"));
    paramsPanel.add(usernameField);
    paramsPanel.add(new JLabel("password"));
    paramsPanel.add(passwordField);
    paramsPanel.add(new JLabel("endPoint"));
    paramsPanel.add(endPointField);
    // paramsPanel.add(new JLabel("serverHost"));
    // paramsPanel.add(serverHostField);
    // paramsPanel.add(new JLabel("serverPort"));
    // paramsPanel.add(serverPortField);
    paramsPanel.add(new JLabel("Actor"));
    paramsPanel.add(actorField);
    paramsPanel.add(new JLabel("nbLastMessages"));
    paramsPanel.add(nbLastMessagesField);
    paramsPanel.add(new JLabel("Message"));
    paramsPanel.add(messageField);
    paramsPanel.add(new JLabel("convid"));
    paramsPanel.add(convidField);
    paramsPanel.add(new JLabel("status"));
    paramsPanel.add(convstateField);
    paramsPanel.add(new JLabel("relevant"));
    paramsPanel.add(relevantField);
    paramsPanel.add(new JLabel("timeout"));
    paramsPanel.add(timeoutField);
    paramsPanel.add(new JLabel("Filter Name"));
    paramsPanel.add(filterNameField);
    paramsPanel.add(new JLabel("Filter attr"));
    paramsPanel.add(filterAttrField);
    paramsPanel.add(new JLabel("Filter value"));
    paramsPanel.add(filterValueField);
    paramsPanel.add(persistentRadioButton);
    paramsPanel.add(notPersistentRadioButton);
    // paramsPanel.add(xmppRadioButton);
    paramsPanel.add(socketRadioButton);

    statusArea.setEditable(false);
    paramsPanel.add(statusArea);

    // Initialization of Buttons
    JPanel controlsPanel = new JPanel();
    GridLayout controlsLayout = new GridLayout(3, 7);
    controlsPanel.setLayout(controlsLayout);
    controlsPanel.add(connectButton);
    controlsPanel.add(disconnectButton);
    controlsPanel.add(sendButton);
    controlsPanel.add(createChannelButton);
    controlsPanel.add(subscribeButton);
    controlsPanel.add(unsubscribeButton);
    // controlsPanel.add(publishButton);
    controlsPanel.add(getLastMessagesButton);
    controlsPanel.add(getSubscriptionsButton);
    controlsPanel.add(getThreadButton);
    controlsPanel.add(getThreadsButton);
    controlsPanel.add(pubConvStateButton);
    controlsPanel.add(setFilterButton);
    controlsPanel.add(listFiltersButton);
    controlsPanel.add(unsetFilterButton);
    controlsPanel.add(getRelevantMessagesButton);
    controlsPanel.add(cleanButton);

    // Initialization of the TextArea
    JPanel consolePanel = new JPanel();
    logArea.setEditable(false);
    consolePanel.add(logArea);
    JScrollPane txtScrol = new JScrollPane(logArea);
    txtScrol.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    consolePanel.add(txtScrol);

    // Add all in the layout
    this.add(paramsPanel, BorderLayout.NORTH);
    this.add(controlsPanel, BorderLayout.CENTER);
    this.add(consolePanel, BorderLayout.SOUTH);
}

From source file:com.vgi.mafscaling.Rescale.java

private void createMafScalesScrollPane(JPanel dataPanel) {
    JPanel mafPanel = new JPanel();
    GridBagLayout gbl_mafPanelLayout = new GridBagLayout();
    gbl_mafPanelLayout.columnWidths = new int[] { 0 };
    gbl_mafPanelLayout.rowHeights = new int[] { 0, 0 };
    gbl_mafPanelLayout.columnWeights = new double[] { 0.0, 1.0 };
    gbl_mafPanelLayout.rowWeights = new double[] { 0.0, 1.0 };
    mafPanel.setLayout(gbl_mafPanelLayout);

    JScrollPane mafScrollPane = new JScrollPane(mafPanel);
    mafScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
    mafScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    GridBagConstraints gbl_mafScrollPane = new GridBagConstraints();
    gbl_mafScrollPane.anchor = GridBagConstraints.PAGE_START;
    gbl_mafScrollPane.fill = GridBagConstraints.HORIZONTAL;
    gbl_mafScrollPane.insets = insets0;/*  ww w.  j a  va 2s.  co m*/
    gbl_mafScrollPane.weightx = 1.0;
    gbl_mafScrollPane.gridx = 0;
    gbl_mafScrollPane.gridy = 1;
    gbl_mafScrollPane.ipady = 120;
    dataPanel.add(mafScrollPane, gbl_mafScrollPane);

    GridBagConstraints gbc_mafScrollPane = new GridBagConstraints();
    gbc_mafScrollPane.anchor = GridBagConstraints.PAGE_START;
    gbc_mafScrollPane.weightx = 1.0;
    gbc_mafScrollPane.weighty = 1.0;
    gbc_mafScrollPane.insets = insets0;
    gbc_mafScrollPane.fill = GridBagConstraints.HORIZONTAL;
    gbc_mafScrollPane.gridx = 0;
    gbc_mafScrollPane.gridy = 0;

    MafTablePane origMafScrollPane = new MafTablePane(ColumnWidth, OrigMafTableName, false, false);
    origMafScrollPane.setBorder(null);
    origMafScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    origMafTable = origMafScrollPane.getJTable();
    excelAdapter.addTable(origMafTable, false, false, false, false, false, false, false, false, true);
    mafPanel.add(origMafScrollPane, gbc_mafScrollPane);

    MafTablePane newMafScrollPane = new MafTablePane(ColumnWidth, NewMafTableName, false, true);
    newMafScrollPane.setBorder(null);
    newMafScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    newMafTable = newMafScrollPane.getJTable();
    newMafExcelAdapter.addTable(newMafTable, false, false, false, false, false, false, false, false, true);
    gbc_mafScrollPane.gridy++;
    mafPanel.add(newMafScrollPane, gbc_mafScrollPane);

    Action action = new AbstractAction() {
        private static final long serialVersionUID = 1L;

        public void actionPerformed(ActionEvent e) {
            recalculateNewGs();
        }
    };

    setNewMafTableCellListenerListener(new TableCellListener(newMafTable, action));
}

From source file:dk.dma.epd.common.prototype.gui.notification.ChatServicePanel.java

/**
 * Constructor/*from  w w  w  .j  av  a  2s .c  o  m*/
 * 
 * @param compactLayout
 *            if false, there will be message type selectors in the panel
 */
public ChatServicePanel(boolean compactLayout) {
    super(new BorderLayout());

    // Prepare the title header
    titleHeader.setBackground(getBackground().darker());
    titleHeader.setOpaque(true);
    titleHeader.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    titleHeader.setHorizontalAlignment(SwingConstants.CENTER);
    add(titleHeader, BorderLayout.NORTH);

    // Add messages panel
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    messagesPanel.setBackground(UIManager.getColor("List.background"));
    messagesPanel.setOpaque(false);
    messagesPanel.setLayout(new GridBagLayout());
    messagesPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    add(scrollPane, BorderLayout.CENTER);

    JPanel sendPanel = new JPanel(new GridBagLayout());
    add(sendPanel, BorderLayout.SOUTH);
    Insets insets = new Insets(2, 2, 2, 2);

    // Add text area
    if (compactLayout) {
        messageText = new JTextField();
        ((JTextField) messageText).addActionListener(this);
        sendPanel.add(messageText, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, NORTH, BOTH, insets, 0, 0));

    } else {
        messageText = new JTextArea();
        JScrollPane scrollPane2 = new JScrollPane(messageText);
        scrollPane2.setPreferredSize(new Dimension(100, 50));
        scrollPane2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        scrollPane2.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
        sendPanel.add(scrollPane2, new GridBagConstraints(0, 0, 1, 2, 1.0, 1.0, NORTH, BOTH, insets, 0, 0));
    }

    // Add buttons
    ButtonGroup group = new ButtonGroup();
    messageTypeBtn = createMessageTypeButton("Send messages", ICON_MESSAGE, true, group);
    warningTypeBtn = createMessageTypeButton("Send warnings", ICON_WARNING, false, group);
    alertTypeBtn = createMessageTypeButton("Send alerts", ICON_ALERT, false, group);

    if (!compactLayout) {
        JToolBar msgTypePanel = new JToolBar();
        msgTypePanel.setBorderPainted(false);
        msgTypePanel.setOpaque(true);
        msgTypePanel.setFloatable(false);
        sendPanel.add(msgTypePanel, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, NORTH, NONE, insets, 0, 0));
        msgTypePanel.add(messageTypeBtn);
        msgTypePanel.add(warningTypeBtn);
        msgTypePanel.add(alertTypeBtn);
    }

    if (compactLayout) {
        sendBtn = new JButton("Send");
        sendPanel.add(sendBtn, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, NORTH, NONE, insets, 0, 0));
    } else {
        sendBtn = new JButton("Send", ICON_MESSAGE);
        sendBtn.setPreferredSize(new Dimension(100, sendBtn.getPreferredSize().height));
        sendPanel.add(sendBtn, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, NORTH, NONE, insets, 0, 0));
    }
    sendBtn.setEnabled(false);
    messageText.setEditable(false);
    sendBtn.addActionListener(this);
}

From source file:net.sf.jabref.gui.plaintextimport.TextInputDialog.java

private void initSourcePanel() {
    sourcePreview.setEditable(false);/*w  w  w.j  ava  2s .c  om*/
    sourcePreview
            .setFont(new Font("Monospaced", Font.PLAIN, Globals.prefs.getInt(JabRefPreferences.FONT_SIZE)));
    JScrollPane paneScrollPane = new JScrollPane(sourcePreview);
    paneScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    paneScrollPane.setPreferredSize(new Dimension(500, 255));
    paneScrollPane.setMinimumSize(new Dimension(10, 10));

    sourcePanel.setLayout(new BorderLayout());
    sourcePanel.add(paneScrollPane, BorderLayout.CENTER);
}