Search in sources :

Example 21 with JTextPane

use of javax.swing.JTextPane in project jdk8u_jdk by JetBrains.

the class InsetsEncapsulation method run.

@Override
public void run() {
    runTest(new JLabel("hi"));
    runTest(new JMenu());
    runTest(new JTree());
    runTest(new JTable());
    runTest(new JMenuItem());
    runTest(new JCheckBoxMenuItem());
    runTest(new JToggleButton());
    runTest(new JSpinner());
    runTest(new JSlider());
    runTest(Box.createVerticalBox());
    runTest(Box.createHorizontalBox());
    runTest(new JTextField());
    runTest(new JTextArea());
    runTest(new JTextPane());
    runTest(new JPasswordField());
    runTest(new JFormattedTextField());
    runTest(new JEditorPane());
    runTest(new JButton());
    runTest(new JColorChooser());
    runTest(new JFileChooser());
    runTest(new JCheckBox());
    runTest(new JInternalFrame());
    runTest(new JDesktopPane());
    runTest(new JTableHeader());
    runTest(new JLayeredPane());
    runTest(new JRootPane());
    runTest(new JMenuBar());
    runTest(new JOptionPane());
    runTest(new JRadioButton());
    runTest(new JRadioButtonMenuItem());
    runTest(new JPopupMenu());
    runTest(new JScrollBar());
    runTest(new JScrollPane());
    runTest(new JViewport());
    runTest(new JSplitPane());
    runTest(new JTabbedPane());
    runTest(new JToolBar());
    runTest(new JSeparator());
    runTest(new JProgressBar());
    if (!failures.isEmpty()) {
        System.out.println("These classes failed");
        for (final Component failure : failures) {
            System.out.println(failure.getClass());
        }
        throw new RuntimeException("Test failed");
    }
}
Also used : JDesktopPane(javax.swing.JDesktopPane) JTextArea(javax.swing.JTextArea) JRadioButton(javax.swing.JRadioButton) JLayeredPane(javax.swing.JLayeredPane) JTabbedPane(javax.swing.JTabbedPane) JButton(javax.swing.JButton) JProgressBar(javax.swing.JProgressBar) JTableHeader(javax.swing.table.JTableHeader) JTextField(javax.swing.JTextField) JSeparator(javax.swing.JSeparator) JScrollBar(javax.swing.JScrollBar) JTextPane(javax.swing.JTextPane) JToggleButton(javax.swing.JToggleButton) JSlider(javax.swing.JSlider) JMenuItem(javax.swing.JMenuItem) JComponent(javax.swing.JComponent) Component(java.awt.Component) JScrollPane(javax.swing.JScrollPane) JViewport(javax.swing.JViewport) JFormattedTextField(javax.swing.JFormattedTextField) JLabel(javax.swing.JLabel) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) JToolBar(javax.swing.JToolBar) JOptionPane(javax.swing.JOptionPane) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) JPopupMenu(javax.swing.JPopupMenu) JCheckBox(javax.swing.JCheckBox) JTree(javax.swing.JTree) JFileChooser(javax.swing.JFileChooser) JPasswordField(javax.swing.JPasswordField) JTable(javax.swing.JTable) JEditorPane(javax.swing.JEditorPane) JSpinner(javax.swing.JSpinner) JRootPane(javax.swing.JRootPane) JSplitPane(javax.swing.JSplitPane) JColorChooser(javax.swing.JColorChooser) JInternalFrame(javax.swing.JInternalFrame) JMenu(javax.swing.JMenu) JMenuBar(javax.swing.JMenuBar)

Example 22 with JTextPane

use of javax.swing.JTextPane in project JMRI by JMRI.

the class BeanEditAction method addToPanel.

/**
     * Set out the panel based upon the items passed in via the ArrayList.
     *
     * @param panel JPanel to add stuff to
     * @param items a {@link BeanEditItem} list of key-value pairs for the items
     *              to add
     */
protected void addToPanel(JPanel panel, List<BeanEditItem> items) {
    GridBagLayout gbLayout = new GridBagLayout();
    GridBagConstraints cL = new GridBagConstraints();
    GridBagConstraints cD = new GridBagConstraints();
    GridBagConstraints cR = new GridBagConstraints();
    cL.fill = GridBagConstraints.HORIZONTAL;
    cL.insets = new Insets(2, 0, 0, 15);
    cR.insets = new Insets(0, 10, 15, 15);
    cD.insets = new Insets(2, 0, 0, 0);
    cD.anchor = GridBagConstraints.NORTHWEST;
    cL.anchor = GridBagConstraints.NORTHWEST;
    int y = 0;
    JPanel p = new JPanel();
    for (BeanEditItem it : items) {
        if (it.getDescription() != null && it.getComponent() != null) {
            JLabel decript = new JLabel(it.getDescription() + ":", JLabel.LEFT);
            if (it.getDescription().equals("")) {
                decript.setText("");
            }
            cL.gridx = 0;
            cL.gridy = y;
            cL.ipadx = 3;
            gbLayout.setConstraints(decript, cL);
            p.setLayout(gbLayout);
            p.add(decript, cL);
            cD.gridx = 1;
            cD.gridy = y;
            gbLayout.setConstraints(it.getComponent(), cD);
            p.add(it.getComponent(), cD);
            cR.gridx = 2;
            cR.gridwidth = 1;
            cR.anchor = GridBagConstraints.WEST;
        } else {
            cR.anchor = GridBagConstraints.CENTER;
            cR.gridx = 0;
            cR.gridwidth = 3;
        }
        cR.gridy = y;
        if (it.getHelp() != null) {
            JTextPane help = new JTextPane();
            help.setText(it.getHelp());
            gbLayout.setConstraints(help, cR);
            formatTextAreaAsLabel(help);
            p.add(help, cR);
        }
        y++;
    }
    panel.add(p);
}
Also used : JPanel(javax.swing.JPanel) JTextPane(javax.swing.JTextPane) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) JLabel(javax.swing.JLabel)

Example 23 with JTextPane

use of javax.swing.JTextPane in project JMRI by JMRI.

the class LicenseAction method makePanel.

@Override
public jmri.util.swing.JmriPanel makePanel() {
    jmri.util.swing.JmriPanel p = new JmriPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
    JScrollPane jScrollPane = new JScrollPane();
    JTextPane textPane = new JTextPane();
    // get the file
    // NOI18N
    InputStream is = FileUtil.findInputStream("resources/COPYING", FileUtil.Location.INSTALLED);
    String t;
    try (// file stored as ASCII // NOI18N
    InputStreamReader isr = new InputStreamReader(is, "US-ASCII");
        BufferedReader r = new BufferedReader(isr)) {
        StringBuilder buf = new StringBuilder();
        while (r.ready()) {
            buf.append(r.readLine());
            buf.append("\n");
        }
        t = buf.toString();
    } catch (IOException ex) {
        t = "JMRI is distributed under a license. For license information, see the JMRI website http://jmri.org";
    }
    textPane.setText(t);
    // set up display
    textPane.setEditable(false);
    jScrollPane.getViewport().add(textPane);
    p.add(jScrollPane);
    // start scrolled to top
    JScrollBar b = jScrollPane.getVerticalScrollBar();
    b.setValue(b.getMaximum());
    return p;
}
Also used : JScrollPane(javax.swing.JScrollPane) InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) BoxLayout(javax.swing.BoxLayout) IOException(java.io.IOException) JScrollBar(javax.swing.JScrollBar) JTextPane(javax.swing.JTextPane) BufferedReader(java.io.BufferedReader) JmriPanel(jmri.util.swing.JmriPanel) JmriPanel(jmri.util.swing.JmriPanel)

Example 24 with JTextPane

use of javax.swing.JTextPane in project jabref by JabRef.

the class MergeEntries method setupEntryTypeRow.

private void setupEntryTypeRow(JPanel mergePanel) {
    // Start with entry type
    mergePanel.add(boldFontLabel(Localization.lang("Entry type")), CELL_CONSTRAINTS.xy(1, 1));
    JTextPane leftTypeDisplay = new DiffHighlightingTextPane();
    leftTypeDisplay.setText(DiffHighlighting.HTML_START + leftEntry.getType() + DiffHighlighting.HTML_END);
    mergePanel.add(leftTypeDisplay, CELL_CONSTRAINTS.xy(3, 1));
    if (leftEntry.getType().equals(rightEntry.getType())) {
        identicalTypes = true;
    } else {
        identicalTypes = false;
        ButtonGroup group = new ButtonGroup();
        typeRadioButtons = new ArrayList<>(2);
        for (int k = 0; k < 3; k += 2) {
            JRadioButton button = new JRadioButton();
            typeRadioButtons.add(button);
            group.add(button);
            mergePanel.add(button, CELL_CONSTRAINTS.xy(5 + (k * 2), 1));
            button.addChangeListener(e -> updateAll());
        }
        typeRadioButtons.get(0).setSelected(true);
    }
    JTextPane rightTypeDisplay = new DiffHighlightingTextPane();
    rightTypeDisplay.setText(DiffHighlighting.HTML_START + rightEntry.getType() + DiffHighlighting.HTML_END);
    mergePanel.add(rightTypeDisplay, CELL_CONSTRAINTS.xy(11, 1));
}
Also used : JTextPane(javax.swing.JTextPane) JRadioButton(javax.swing.JRadioButton) ButtonGroup(javax.swing.ButtonGroup) DiffHighlightingTextPane(org.jabref.gui.util.component.DiffHighlightingTextPane)

Example 25 with JTextPane

use of javax.swing.JTextPane in project Info-Evaluation by TechnionYP5777.

the class MainFrame method initialize.

/**
	 * Initialize the contents of the frame.
	 */
private void initialize() {
    /*
		 * this flag to change the name of search button
		 */
    startFlag = false;
    frame = new JFrame();
    frame.setTitle("Info Evaluation");
    frame.setResizable(false);
    final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setBounds(0, 0, screen.width, screen.height - 1);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    try {
        connector = new MySQLConnector();
    } catch (final Exception e) {
        JOptionPane.showMessageDialog(null, "problem with sql connector", "Error", JOptionPane.INFORMATION_MESSAGE);
    }
    frame.addWindowListener(new java.awt.event.WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent winEvt) {
            try {
                clearDB();
            } catch (final SQLException e) {
                JOptionPane.showMessageDialog(null, "problem with removing events from Database", "Error", JOptionPane.INFORMATION_MESSAGE);
            }
            closeConnection();
            System.exit(0);
        }
    });
    final AnalyzeSources events = new AnalyzeSources();
    events.addSource(src1);
    events.addSource(src2, "2015");
    MySQLConnector.addEvents(events.getData());
    try {
        addAllKeywords(events.getData());
    } catch (SQLException ¢) {
        ¢.printStackTrace();
    }
    final JMenuBar menuBar = new JMenuBar();
    frame.setJMenuBar(menuBar);
    mnHelp = new JMenu("Help");
    menuBar.add(mnHelp);
    mntmAbout = new JMenuItem("About");
    mnHelp.add(mntmAbout);
    popupMenu = new JPopupMenu();
    mnfilter = new JMenuItem("Filter by");
    mnprofile = new JMenuItem("View profile");
    mnprofile.setVisible(false);
    popupMenu.add(mnfilter);
    popupMenu.add(mnprofile);
    /*
		 *
		 * initializing the table
		 *
		 */
    // {
    table = new JTable();
    table.setComponentPopupMenu(popupMenu);
    table.setShowVerticalLines(false);
    table.setCellSelectionEnabled(true);
    table.setColumnSelectionAllowed(true);
    table.setBorder(new LineBorder(null));
    for (int count = 1; count <= 10; ++count) table.setModel(new DefaultTableModel(new Object[][] { { "Name", "Date", "Reason" } }, new String[] { "Name", "Date", "Reason" }));
    table.setBounds(30, 120, screen.width / 2 + 100, screen.height / 2);
    table.setVisible(false);
    js = new JScrollPane(table, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    js.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
    js.setVisible(false);
    js.setBounds(30, 120, screen.width / 2 + 100, screen.height / 2);
    frame.getContentPane().add(js);
    frame.getContentPane().add(js);
    /*
		 * initializing the table
		 *
		 */
    inputList = new RefineTable();
    inputList.addField("Date");
    inputList.addField("Name");
    inputList.addField("Reason");
    inputList.addField("Year");
    btnSearch = new JButton("Load analyze results");
    searchTxt = new JTextField(10);
    searchTxt.setText("Select checkBox to search");
    searchTxt.setColumns(10);
    searchTxt.setEditable(false);
    ArrayList<String> keywords = new ArrayList<String>();
    for (TableTuple t : events.getData()) {
        String year = t.getDate().split("/")[2];
        if (!keywords.contains(year))
            keywords.add(year);
        if (!keywords.contains(t.getName()))
            keywords.add(t.getName());
        for (String s : t.getKeyWords()) for (String key : s.split(" ")) {
            if (keywords.contains(key))
                continue;
            keywords.add(key);
        }
    }
    AutoComplete.setupAutoComplete(searchTxt, keywords);
    chckbxName = new JCheckBox("Name");
    chckbxName.setVisible(false);
    chckbxDate = new JCheckBox("Date");
    chckbxDate.setVisible(false);
    chckbxReason = new JCheckBox("Reason");
    chckbxReason.setVisible(false);
    chckbxSortby = new JCheckBox("Sort by");
    chckbxFilterBy = new JCheckBox("Filter by");
    comboBox = new JComboBox<>();
    comboBox.setVisible(false);
    txtpnChooseOneFrom = new JTextPane();
    txtpnChooseOneFrom.setText("Choose one from:");
    txtpnChooseOneFrom.setBackground(new Color(0, 0, 0, 0));
    txtpnChooseOneFrom.setVisible(false);
    personalInfo = new InfoExtractor();
    btnLoadAnalyzeResults = new JButton("Load analyze results");
    btnLoadAnalyzeResults.setVisible(false);
    /*
		 * add image
		 */
    BufferedImage myPicture;
    try {
        myPicture = ImageIO.read(this.getClass().getResource("images/search.png"));
        lblImage = new JLabel(new ImageIcon(myPicture.getScaledInstance(220, 220, Image.SCALE_DEFAULT)));
    } catch (IOException ¢) {
        ¢.printStackTrace();
    }
    chckbxSearch = new JCheckBox("");
    btnAddEvents = new JButton("Add Events");
    final GroupLayout groupLayout = new GroupLayout(frame.getContentPane());
    groupLayout.setHorizontalGroup(groupLayout.createParallelGroup(Alignment.LEADING).addGroup(groupLayout.createSequentialGroup().addContainerGap(881, Short.MAX_VALUE).addComponent(lblImage, GroupLayout.PREFERRED_SIZE, 232, GroupLayout.PREFERRED_SIZE).addGap(247)).addGroup(groupLayout.createSequentialGroup().addGap(30).addGroup(groupLayout.createParallelGroup(Alignment.LEADING).addGroup(groupLayout.createSequentialGroup().addComponent(btnLoadAnalyzeResults).addGap(92).addComponent(btnAddEvents, GroupLayout.PREFERRED_SIZE, 145, GroupLayout.PREFERRED_SIZE)).addGroup(groupLayout.createSequentialGroup().addComponent(chckbxSearch, GroupLayout.PREFERRED_SIZE, 29, GroupLayout.PREFERRED_SIZE).addPreferredGap(ComponentPlacement.RELATED).addGroup(groupLayout.createParallelGroup(Alignment.LEADING, false).addComponent(searchTxt, GroupLayout.PREFERRED_SIZE, 744, GroupLayout.PREFERRED_SIZE).addGroup(groupLayout.createSequentialGroup().addGroup(groupLayout.createParallelGroup(Alignment.LEADING, false).addGroup(groupLayout.createSequentialGroup().addComponent(chckbxName).addGap(18).addComponent(chckbxDate, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)).addGroup(groupLayout.createSequentialGroup().addComponent(chckbxSortby).addPreferredGap(ComponentPlacement.UNRELATED).addComponent(chckbxFilterBy))).addPreferredGap(ComponentPlacement.RELATED).addComponent(chckbxReason).addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(txtpnChooseOneFrom, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))).addGap(18).addGroup(groupLayout.createParallelGroup(Alignment.LEADING).addComponent(btnSearch, GroupLayout.PREFERRED_SIZE, 224, GroupLayout.PREFERRED_SIZE).addComponent(comboBox, GroupLayout.PREFERRED_SIZE, 219, GroupLayout.PREFERRED_SIZE)))).addContainerGap(313, Short.MAX_VALUE)));
    groupLayout.setVerticalGroup(groupLayout.createParallelGroup(Alignment.TRAILING).addGroup(groupLayout.createSequentialGroup().addContainerGap().addGroup(groupLayout.createParallelGroup(Alignment.LEADING, false).addComponent(chckbxSearch).addGroup(groupLayout.createSequentialGroup().addGroup(groupLayout.createParallelGroup(Alignment.BASELINE).addComponent(searchTxt, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE).addComponent(btnSearch, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE)).addPreferredGap(ComponentPlacement.RELATED).addGroup(groupLayout.createParallelGroup(Alignment.BASELINE).addComponent(chckbxSortby).addComponent(chckbxFilterBy)).addPreferredGap(ComponentPlacement.RELATED).addGroup(groupLayout.createParallelGroup(Alignment.LEADING).addComponent(txtpnChooseOneFrom, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addGroup(groupLayout.createParallelGroup(Alignment.BASELINE).addComponent(chckbxName).addComponent(chckbxDate).addComponent(chckbxReason)).addComponent(comboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))).addPreferredGap(ComponentPlacement.RELATED, 177, Short.MAX_VALUE).addComponent(lblImage, GroupLayout.PREFERRED_SIZE, 193, GroupLayout.PREFERRED_SIZE).addGap(76).addGroup(groupLayout.createParallelGroup(Alignment.BASELINE).addComponent(btnLoadAnalyzeResults, GroupLayout.PREFERRED_SIZE, 35, GroupLayout.PREFERRED_SIZE).addComponent(btnAddEvents, GroupLayout.DEFAULT_SIZE, 35, Short.MAX_VALUE)).addGap(171)));
    frame.getContentPane().setLayout(groupLayout);
}
Also used : ImageIcon(javax.swing.ImageIcon) SQLException(java.sql.SQLException) LineBorder(javax.swing.border.LineBorder) DefaultTableModel(javax.swing.table.DefaultTableModel) JButton(javax.swing.JButton) ArrayList(java.util.ArrayList) JTextField(javax.swing.JTextField) BufferedImage(java.awt.image.BufferedImage) JTextPane(javax.swing.JTextPane) JFrame(javax.swing.JFrame) GroupLayout(javax.swing.GroupLayout) MySQLConnector(main.database.MySQLConnector) JMenuItem(javax.swing.JMenuItem) JScrollPane(javax.swing.JScrollPane) Color(java.awt.Color) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) AnalyzeSources(main.Analyze.AnalyzeSources) IOException(java.io.IOException) SQLException(java.sql.SQLException) IOException(java.io.IOException) JPopupMenu(javax.swing.JPopupMenu) Point(java.awt.Point) JCheckBox(javax.swing.JCheckBox) TableTuple(main.database.TableTuple) WindowEvent(java.awt.event.WindowEvent) JTable(javax.swing.JTable) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Aggregations

JTextPane (javax.swing.JTextPane)32 JScrollPane (javax.swing.JScrollPane)13 JButton (javax.swing.JButton)9 JLabel (javax.swing.JLabel)9 JPanel (javax.swing.JPanel)8 Color (java.awt.Color)6 Dimension (java.awt.Dimension)6 JRadioButton (javax.swing.JRadioButton)6 JTextField (javax.swing.JTextField)6 Insets (java.awt.Insets)4 IOException (java.io.IOException)4 JCheckBox (javax.swing.JCheckBox)4 JPasswordField (javax.swing.JPasswordField)4 JTable (javax.swing.JTable)4 BorderLayout (java.awt.BorderLayout)3 Component (java.awt.Component)3 FlowLayout (java.awt.FlowLayout)3 Font (java.awt.Font)3 GridBagConstraints (java.awt.GridBagConstraints)3 GridBagLayout (java.awt.GridBagLayout)3