Search in sources :

Example 6 with JEditorPane

use of javax.swing.JEditorPane in project adempiere by adempiere.

the class CAbstractBOMTree method preInit.

private void preInit() {
    northPanel = new CPanel();
    southPanel = new CPanel();
    contentPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    nodeDescription = new JEditorPane("text/html", "");
    nodeDescription.setOpaque(false);
    nodeDescription.setEditable(false);
    String columnName = null;
    int columnId = -1;
    if (BOMWrapper.BOM_TYPE_PRODUCT.equals(type())) {
        columnName = MProduct.Table_Name + "_ID";
        columnId = MColumn.getColumn_ID(MProduct.Table_Name, columnName);
    } else if (BOMWrapper.BOM_TYPE_ORDER.equals(type())) {
        columnName = MPPOrder.Table_Name + "_ID";
        columnId = MColumn.getColumn_ID(MPPOrder.Table_Name, columnName);
    }
    MLookup lm = MLookupFactory.get(Env.getCtx(), getWindowNo(), 0, columnId, DisplayType.Search);
    lookup = new VLookup(columnName, false, false, true, lm) {

        public void setValue(Object obj) {
            super.setValue(obj);
            dispatchPropertyChange();
        }

        ;
    };
}
Also used : MLookup(org.compiere.model.MLookup) CPanel(org.compiere.swing.CPanel) JEditorPane(javax.swing.JEditorPane) VLookup(org.compiere.grid.ed.VLookup) JSplitPane(javax.swing.JSplitPane)

Example 7 with JEditorPane

use of javax.swing.JEditorPane in project adempiere by adempiere.

the class HelpInfo method createAndShowGui.

// METHODS
// =======
/**
	 * Create the GUI and show it
	 * @param component the calling component
	 */
public void createAndShowGui(Component component) {
    // title
    setTitle(s_logger.localizeMessage("guiHelpTitle"));
    // load icons
    ArrayList<Image> images = new ArrayList<Image>();
    images.add(getImage("AD16.png"));
    images.add(getImage("AD32.png"));
    setIconImages(images);
    // content pane
    Container pane = getContentPane();
    Locale locale = Locale.getDefault();
    pane.setComponentOrientation(ComponentOrientation.getOrientation(locale));
    pane.setLayout(new GridBagLayout());
    // help text
    JEditorPane info = new JEditorPane();
    info.setEditable(false);
    info.setContentType("text/html");
    HTMLDocument htmlDoc = (HTMLDocument) info.getEditorKit().createDefaultDocument();
    info.setDocument(htmlDoc);
    info.setText(getHelpText());
    info.setCaretPosition(0);
    // scrollable pane for help text
    JScrollPane infoPane = new JScrollPane();
    infoPane.setBorder(BorderFactory.createLoweredBevelBorder());
    infoPane.setPreferredSize(new Dimension(500, 400));
    infoPane.getViewport().add(info, null);
    pane.add(infoPane, getInfoPaneConstraints());
    // close button
    m_buttonClose = new JButton(s_logger.localizeMessage("guiButtonClose"));
    m_buttonClose.setMnemonic(new Integer(s_logger.localizeMessage("guiButtonCloseMnemonic")));
    m_buttonClose.setIcon(new ImageIcon(getImage("Cancel16.png")));
    m_buttonClose.addActionListener(this);
    pane.add(m_buttonClose, getCloseConstraints());
    // show dialog
    pack();
    validate();
    m_buttonClose.requestFocusInWindow();
    setLocationRelativeTo(component);
    setVisible(true);
}
Also used : Locale(java.util.Locale) JScrollPane(javax.swing.JScrollPane) ImageIcon(javax.swing.ImageIcon) GridBagLayout(java.awt.GridBagLayout) HTMLDocument(javax.swing.text.html.HTMLDocument) ArrayList(java.util.ArrayList) JButton(javax.swing.JButton) Dimension(java.awt.Dimension) Image(java.awt.Image) Container(java.awt.Container) JEditorPane(javax.swing.JEditorPane)

Example 8 with JEditorPane

use of javax.swing.JEditorPane in project jmeter by apache.

the class TextBoxDialoger method createDialogBox.

private void createDialogBox() {
    JFrame mainFrame = GuiPackage.getInstance().getMainFrame();
    String title = //$NON-NLS-1$
    editable ? //$NON-NLS-1$
    JMeterUtils.getResString("textbox_title_edit") : //$NON-NLS-1$
    JMeterUtils.getResString("textbox_title_view");
    // modal dialog box
    dialog = new JDialog(mainFrame, title, true);
    // Close action dialog box when tapping Escape key
    JPanel content = (JPanel) dialog.getContentPane();
    content.registerKeyboardAction(this, KeyStrokes.ESC, JComponent.WHEN_IN_FOCUSED_WINDOW);
    textBox = new JEditorPane();
    textBox.setEditable(editable);
    JScrollPane textBoxScrollPane = GuiUtils.makeScrollPane(textBox);
    JPanel btnBar = new JPanel();
    btnBar.setLayout(new FlowLayout(FlowLayout.RIGHT));
    if (editable) {
        //$NON-NLS-1$
        JButton cancelBtn = new JButton(JMeterUtils.getResString("textbox_cancel"));
        cancelBtn.setActionCommand(CANCEL_COMMAND);
        cancelBtn.addActionListener(this);
        //$NON-NLS-1$
        JButton saveBtn = new JButton(JMeterUtils.getResString("textbox_save_close"));
        saveBtn.setActionCommand(SAVE_CLOSE_COMMAND);
        saveBtn.addActionListener(this);
        btnBar.add(cancelBtn);
        btnBar.add(saveBtn);
    } else {
        //$NON-NLS-1$
        JButton closeBtn = new JButton(JMeterUtils.getResString("textbox_close"));
        closeBtn.setActionCommand(CLOSE_COMMAND);
        closeBtn.addActionListener(this);
        btnBar.add(closeBtn);
    }
    // Prepare dialog box
    Container panel = dialog.getContentPane();
    dialog.setMinimumSize(new Dimension(400, 250));
    panel.add(textBoxScrollPane, BorderLayout.CENTER);
    panel.add(btnBar, BorderLayout.SOUTH);
    // determine location on screen
    Point p = mainFrame.getLocationOnScreen();
    Dimension d1 = mainFrame.getSize();
    Dimension d2 = dialog.getSize();
    dialog.setLocation(p.x + (d1.width - d2.width) / 2, p.y + (d1.height - d2.height) / 2);
    dialog.pack();
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) Container(java.awt.Container) FlowLayout(java.awt.FlowLayout) JFrame(javax.swing.JFrame) JEditorPane(javax.swing.JEditorPane) JButton(javax.swing.JButton) Dimension(java.awt.Dimension) Point(java.awt.Point) JDialog(javax.swing.JDialog)

Example 9 with JEditorPane

use of javax.swing.JEditorPane in project ChatGameFontificator by GlitchCog.

the class ControlWindow method constructAboutPopup.

/**
     * Construct the popup dialog containing the About message
     */
private void constructAboutPopup() {
    aboutPane = new JEditorPane("text/html", ABOUT_CONTENTS);
    aboutPane.addHyperlinkListener(new HyperlinkListener() {

        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (EventType.ACTIVATED.equals(e.getEventType())) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        Desktop.getDesktop().browse(URI.create("https://" + e.getDescription()));
                    } catch (IOException e1) {
                        e1.printStackTrace();
                    }
                }
            }
        }
    });
    aboutPane.setEditable(false);
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) HyperlinkListener(javax.swing.event.HyperlinkListener) JEditorPane(javax.swing.JEditorPane) IOException(java.io.IOException)

Example 10 with JEditorPane

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

the class EntryEditorTabRelatedArticles method setHtmlText.

/**
     * Takes a List of HTML snippets stored in the field "html_representation" of a list of bibentries and sets it in the JEditorPane
     *
     * @param list of bib entries having a field html_representation
     */
public void setHtmlText(List<BibEntry> list) {
    StringBuilder htmlContent = new StringBuilder();
    URL url = IconTheme.getIconUrl("mdlListIcon");
    htmlContent.append("<html><head><title></title></head><body bgcolor='#ffffff'>");
    htmlContent.append("<ul style='list-style-image:(");
    htmlContent.append(url);
    htmlContent.append(")'>");
    list.stream().map(bibEntry -> bibEntry.getField("html_representation")).filter(Optional::isPresent).map(o -> "<li style='margin: 5px'>" + o.get() + "</li>").forEach(html -> htmlContent.append(html));
    htmlContent.append("</ul>");
    htmlContent.append("<br><div style='margin-left: 5px'>");
    htmlContent.append("<a href='http://mr-dlib.org/information-for-users/information-about-mr-dlib-for-jabref-users/#'>");
    htmlContent.append(Localization.lang("What_is_Mr._DLib?"));
    htmlContent.append("</a></div>");
    htmlContent.append("</body></html>");
    this.setText(htmlContent.toString());
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) FieldName(org.jabref.model.entry.FieldName) URL(java.net.URL) BibEntry(org.jabref.model.entry.BibEntry) JabRefDesktop(org.jabref.gui.desktop.JabRefDesktop) MrDLibFetcher(org.jabref.logic.importer.fetcher.MrDLibFetcher) IconTheme(org.jabref.gui.IconTheme) IOException(java.io.IOException) JabRefPreferences(org.jabref.preferences.JabRefPreferences) Globals(org.jabref.Globals) ExecutionException(java.util.concurrent.ExecutionException) List(java.util.List) JEditorPane(javax.swing.JEditorPane) Optional(java.util.Optional) SwingWorker(javax.swing.SwingWorker) Localization(org.jabref.logic.l10n.Localization) Log(org.apache.commons.logging.Log) LogFactory(org.apache.commons.logging.LogFactory) Optional(java.util.Optional) URL(java.net.URL)

Aggregations

JEditorPane (javax.swing.JEditorPane)38 JScrollPane (javax.swing.JScrollPane)16 Dimension (java.awt.Dimension)10 IOException (java.io.IOException)10 JButton (javax.swing.JButton)9 JLabel (javax.swing.JLabel)9 JDialog (javax.swing.JDialog)7 JFrame (javax.swing.JFrame)6 JPanel (javax.swing.JPanel)5 StyledEditorKit (javax.swing.text.StyledEditorKit)5 BorderLayout (java.awt.BorderLayout)4 GridBagLayout (java.awt.GridBagLayout)4 URL (java.net.URL)4 JCheckBox (javax.swing.JCheckBox)4 JSplitPane (javax.swing.JSplitPane)4 JTree (javax.swing.JTree)4 Component (java.awt.Component)3 GridBagConstraints (java.awt.GridBagConstraints)3 Point (java.awt.Point)3 ArrayList (java.util.ArrayList)3