javax.swing.JTextPane Java Examples

The following examples show how to use javax.swing.JTextPane. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AttachDebuggerAction.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 7 votes vote down vote up
SelectConfigDialog() {
  super(null, false, false);
  setTitle("Run Configuration");
  myPanel = new JPanel();
  myTextPane = new JTextPane();
  Messages.installHyperlinkSupport(myTextPane);
  String selectConfig = "<html><body>" +
                        "<p>The run configuration for the Flutter module must be selected." +
                        "<p>Please change the run configuration to the one created when the<br>" +
                        "module was created. See <a href=\"" +
                        FlutterConstants.URL_RUN_AND_DEBUG +
                        "\">the Flutter documentation</a> for more information.</body></html>";
  myTextPane.setText(selectConfig);
  myPanel.add(myTextPane);
  init();
  //noinspection ConstantConditions
  getButton(getCancelAction()).setVisible(false);
}
 
Example #2
Source File: AttachDebuggerAction.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
SelectConfigDialog() {
  super(null, false, false);
  setTitle("Run Configuration");
  myPanel = new JPanel();
  myTextPane = new JTextPane();
  Messages.installHyperlinkSupport(myTextPane);
  String selectConfig = "<html><body>" +
                        "<p>The run configuration for the Flutter module must be selected." +
                        "<p>Please change the run configuration to the one created when the<br>" +
                        "module was created. See <a href=\"" +
                        FlutterConstants.URL_RUN_AND_DEBUG +
                        "\">the Flutter documentation</a> for more information.</body></html>";
  myTextPane.setText(selectConfig);
  myPanel.add(myTextPane);
  init();
  //noinspection ConstantConditions
  getButton(getCancelAction()).setVisible(false);
}
 
Example #3
Source File: InformationPanel.java    From stendhal with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a new InformationPanel.
 */
InformationPanel() {
	setLayout(new OverlayLayout(this));
	JComponent container = SBoxLayout.createContainer(SBoxLayout.VERTICAL);
	glassPane = new JComponent(){};
	add(glassPane);
	add(container);

	// ** Zone name **
	nameField = new JTextPane();
	StyleConstants.setAlignment(center, StyleConstants.ALIGN_CENTER);
	nameField.setAlignmentX(CENTER_ALIGNMENT);
	nameField.setOpaque(true);
	nameField.setBackground(getBackground());
	nameField.setForeground(Color.WHITE);
	nameField.setFocusable(false);
	nameField.setEditable(false);
	container.add(nameField, SLayout.EXPAND_X);

	// ** Danger display **
	dangerIndicator = new DangerIndicator(MAX_SKULLS);
	dangerIndicator.setAlignmentX(CENTER_ALIGNMENT);
	container.add(dangerIndicator);
	// Default to safe, so that we always have a tooltip
	describeDanger(0);
}
 
Example #4
Source File: MiniEdit.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Utility method to open a file */
private void openFile(File file) {
    Doc doc = (Doc) openDocs.get(file);
    if (doc == null) {
        doc = new Doc(file);
        JTextPane pane = doc.getTextPane();
        if (pane != null) {
            //otherwise there was an exception
            pane.addFocusListener(this);
            synchronized (getTreeLock()) {
                Component c = documentTabs.add(new JScrollPane(pane));
                openDocs.put(file, doc);
                documentTabs.setTitleAt(documentTabs.getTabCount()-1, doc.getTitle());
                documentTabs.setToolTipTextAt(documentTabs.getTabCount()-1, file.toString());
                pane.requestFocus();
                documentTabs.setSelectedComponent(c);
            }
        }
    } else {
        doc.getTextPane().requestFocus();
    }
}
 
Example #5
Source File: ShowNotifications.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static JTextPane createInfoPanel(String notification) {
    JTextPane balloon = new JTextPane();
    balloon.setContentType("text/html");
    String text = getDetails(notification).replaceAll("(\r\n|\n|\r)", "<br>");
    balloon.setText(text);
    balloon.setOpaque(false);
    balloon.setEditable(false);
    balloon.setBorder(new EmptyBorder(0, 0, 0, 0));


    if (UIManager.getLookAndFeel().getID().equals("Nimbus")) {
        //#134837
        //http://forums.java.net/jive/thread.jspa?messageID=283882
        balloon.setBackground(new Color(0, 0, 0, 0));
    }

    balloon.addHyperlinkListener(new HyperlinkListener() {

        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
                URLDisplayer.getDefault().showURL(e.getURL());
            }
        }
    });
    return balloon;
}
 
Example #6
Source File: AddTextAction.java    From wpcleaner with Apache License 2.0 6 votes vote down vote up
/**
 * Replace text.
 * 
 * @param localNewText New text.
 * @param localElement Element.
 * @param localTextPane Text Pane.
 */
private void replace(
    String localNewText,
    Element localElement,
    JTextPane localTextPane) {
  if ((localElement == null) ||
      (localTextPane == null) ||
      (localNewText == null)) {
    return;
  }

  // Initialize
  int startOffset = MWPaneFormatter.getUUIDStartOffset(localTextPane, localElement);
  int endOffset = MWPaneFormatter.getUUIDEndOffet(localTextPane, localElement);

  // Replace
  try {
    localTextPane.getDocument().remove(startOffset, endOffset - startOffset);
    localTextPane.getDocument().insertString(startOffset, localNewText, localElement.getAttributes());
    localTextPane.setCaretPosition(startOffset);
    localTextPane.moveCaretPosition(startOffset + localNewText.length());
  } catch (BadLocationException e1) {
    // Nothing to be done
  }
}
 
Example #7
Source File: JTextPaneUtils.java    From WorldGrower with GNU General Public License v3.0 6 votes vote down vote up
public static void appendTextUsingLabel(JTextPane textPane, String message) {
	StyledDocument document = (StyledDocument)textPane.getDocument();
	
       try {
		JLabel jl  = JLabelFactory.createJLabel(message);
		jl.setHorizontalAlignment(SwingConstants.LEFT);

		String styleName = "style"+message;
		Style textStyle = document.addStyle(styleName, null);
	    StyleConstants.setComponent(textStyle, jl);

	    document.insertString(document.getLength(), " ", document.getStyle(styleName));
	} catch (BadLocationException e) {
		throw new IllegalStateException(e);
	}
}
 
Example #8
Source File: LineNumber.java    From bigtable-sql with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args)
{
	JFrame frame = new JFrame("LineNumberDemo");
	frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );

	JPanel panel = new JPanel();
	frame.setContentPane( panel );
	panel.setBorder(BorderFactory.createEmptyBorder(20,20,20,20));
	panel.setLayout(new BorderLayout());

	JTextPane textPane = new JTextPane();
	textPane.setFont( new Font("monospaced", Font.PLAIN, 12) );
	textPane.setText("abc");

	JScrollPane scrollPane = new JScrollPane(textPane);
	panel.add(scrollPane);
	scrollPane.setPreferredSize(new Dimension(300, 250));

	LineNumber lineNumber = new LineNumber( textPane );
	scrollPane.setRowHeaderView( lineNumber );

	frame.pack();
	frame.setVisible(true);
}
 
Example #9
Source File: WikiEditPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Creates new form WikiEditPanel
 */
public WikiEditPanel(String wikiLanguage, boolean editing, boolean switchable) {
    this.wikiLanguage = wikiLanguage;
    this.switchable = switchable;
    this.wikiFormatText = "";
    this.htmlFormatText = "";
    initComponents();
    pnlButtons.setVisible(switchable);
    textCode.getDocument().addDocumentListener(new RevalidatingListener());
    textPreview.getDocument().addDocumentListener(new RevalidatingListener());
    textCode.addCaretListener(new CaretListener() {
        @Override
        public void caretUpdate(CaretEvent e) {
            makeCaretVisible(textCode);
        }
    });
    textCode.getDocument().addDocumentListener(new EnablingListener());
    // A11Y - Issues 163597 and 163598
    UIUtils.fixFocusTraversalKeys(textCode);
    UIUtils.issue163946Hack(scrollCode);

    Spellchecker.register(textCode);
    textPreview.putClientProperty(JTextPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);

    setEditing(editing);
}
 
Example #10
Source File: HallKeeper.java    From ETL_Unicorn with Apache License 2.0 6 votes vote down vote up
public static void vpcsRegister(LinkList first, String fileCurrentpath, NodeShow nodeView
		, JTextPane rightBotJTextPane) {
	if(null== hallKeeper) {
		hallKeeper= new ConcurrentHashMap<>();
	}
	if(200> hallKeeper.size()) {
		try {
			BootNeroDoc bootNeroDoc= new BootNeroDoc(first, fileCurrentpath, nodeView, rightBotJTextPane);
			Sets.register(bootNeroDoc.getId());//sets ��sleeper����ʱ��������Է�����������ݡ�
			Pillow.register(bootNeroDoc);//pillow����Щ���ݵķ���洢��
			Vision.registerVision(bootNeroDoc);//vision��sleeper���еľ����ξ���
			hallKeeper.put(bootNeroDoc.getId(), bootNeroDoc);
			bootNeroDoc.start();
		}catch(Exception e) {
			Skivvy.working(hallKeeper, e);//skivvy����vision�� pillow��sets��sleeper ȫ�̹���ͷ�����
		}
	}
}
 
Example #11
Source File: ModelItem.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void printHeaders(JTextPane pane, JSONObject headers,
        StyledDocument doc, Style boldStyle, Style defaultStyle) throws BadLocationException {

    assert headers != null;
    Set keys = new TreeSet(new Comparator<Object>() {
        @Override
        public int compare(Object o1, Object o2) {
            return ((String)o1).compareToIgnoreCase((String)o2);
        }

    });
    keys.addAll(headers.keySet());
    for (Object oo : keys) {
        String key = (String)oo;
        doc.insertString(doc.getLength(), key+": ", boldStyle);
        String value = (String)headers.get(key);
        doc.insertString(doc.getLength(), value+"\n", defaultStyle);
    }
}
 
Example #12
Source File: ROCViewer.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
public ROCViewer(AreaUnderCurve auc) {
	setLayout(new BorderLayout());

	String message = auc.toString();

	criterionName = auc.getName();

	// info string
	JPanel infoPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
	infoPanel.setOpaque(true);
	infoPanel.setBackground(Colors.WHITE);
	JTextPane infoText = new JTextPane();
	infoText.setEditable(false);
	infoText.setBackground(infoPanel.getBackground());
	infoText.setFont(infoText.getFont().deriveFont(Font.BOLD));
	infoText.setText(message);
	infoPanel.add(infoText);
	add(infoPanel, BorderLayout.NORTH);

	// plot panel
	plotter = new ROCChartPlotter();
	plotter.addROCData("ROC", auc.getRocData());
	JPanel innerPanel = new JPanel(new BorderLayout());
	innerPanel.add(plotter, BorderLayout.CENTER);
	innerPanel.setBorder(BorderFactory.createMatteBorder(5, 0, 10, 10, Colors.WHITE));
	add(innerPanel, BorderLayout.CENTER);
}
 
Example #13
Source File: ProblemPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void enhancedInitComponents() {
        initComponents();
        taTitle.setBackground(new Color(0, 0, 0, 0));
        taTitle.setOpaque(false);
        taTitle.putClientProperty(JTextPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
        tpMessage.setBackground(new Color(0, 0, 0, 0));
        tpMessage.setOpaque(false);
        tpMessage.putClientProperty(JTextPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
}
 
Example #14
Source File: TextPaneAppender.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public TextPaneAppender() {
  super();
  setTextPane(new JTextPane());
  createAttributes();
  createIcons();
  this.label="";
  this.sw = new StringWriter();
  this.qw = new QuietWriter(sw, errorHandler);
  this.tp = new TracerPrintWriter(qw);
  this.fancy =true;
}
 
Example #15
Source File: GUISample.java    From ETL_Unicorn with Apache License 2.0 5 votes vote down vote up
public void init(Object[][] tableData_old,JTextPane text){
	try {
		this.text= text;
		this.tableData_old= tableData_old;
		CreatMap();
	} catch (IOException e) {
		e.printStackTrace();
	}
	Registrar();
	this.resize(w,h);	
}
 
Example #16
Source File: Desktop.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
void showInfo()
{
  final JTextPane html = new JTextPane();

  html.setContentType("text/html");

  html.setEditable(false);

  html.setText(Util.getSystemInfo());

  final JScrollPane scroll = new JScrollPane(html);
  scroll.setPreferredSize(new Dimension(420, 300));
  SwingUtilities.invokeLater(new Runnable() {
    @Override
    public void run()
    {
      final JViewport vp = scroll.getViewport();
      if (vp != null) {
        vp.setViewPosition(new Point(0, 0));
        scroll.setViewport(vp);
      }
    }
  });

  JOptionPane.showMessageDialog(frame, scroll, "Framework info",
                                JOptionPane.INFORMATION_MESSAGE, null);
}
 
Example #17
Source File: JTextPaneUtils.java    From WorldGrower with GNU General Public License v3.0 5 votes vote down vote up
public static void insertNewLine(JTextPane textPane) {
	StyledDocument document = (StyledDocument)textPane.getDocument();
	
       try {
		String styleName = "stylenewline";
	    document.insertString(document.getLength(), "\n", document.getStyle(styleName));
	} catch (BadLocationException e) {
		throw new IllegalStateException(e);
	}
}
 
Example #18
Source File: Text.java    From wandora with GNU General Public License v3.0 5 votes vote down vote up
protected JComponent getTextComponent(String locator) throws Exception {
    JTextPane textComponent = new JTextPane();
    textComponent.setText(getContent(locator));
    textComponent.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    textComponent.setEditable(false);
    textComponent.setCaretPosition(0);
    return textComponent;
}
 
Example #19
Source File: FindSupport.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void highlight(Component comp, boolean cancel) {
    if (comp == bar) {
        return;
    }
    if (comp instanceof JTextPane) {
        JTextPane tcomp = (JTextPane)comp;
        if(!tcomp.isVisible()) {
            return;
        }
        String txt = tcomp.getText();
        Matcher matcher = pattern.matcher(txt);
        Highlighter highlighter = tcomp.getHighlighter();
        if (cancel) {
            highlighter.removeAllHighlights();
        } else {
            int idx = 0;
            while (matcher.find(idx)) {
                int start = matcher.start();
                int end = matcher.end();
                if (start == end) {
                    break;
                }
                try {
                    highlighter.addHighlight(start, end, highlighterAll);
                } catch (BadLocationException blex) {
                    BugtrackingManager.LOG.log(Level.INFO, blex.getMessage(), blex);
                }
                idx = matcher.end();
            }
        }
    } else if (comp instanceof Container) {
        Container cont = (Container)comp;
        for (Component subComp : cont.getComponents()) {
            highlight(subComp, cancel);
        }
    }
}
 
Example #20
Source File: ReloadDependencies.java    From BART with MIT License 5 votes vote down vote up
public ReloadDependencies(JTextPane textPanel) {
    this.textPanel = textPanel;
    dto = CentralLookup.getDefLookup().lookup(EGTaskDataObjectDataObject.class);
    if(dto!=null)   {
        egtask = dto.getEgtask();
    }else{
        egtask = null;
    }
    parse = new ParseDependencies();
    vioGenQueriesGenerator = new GenerateVioGenQueries();
}
 
Example #21
Source File: CommentsPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void setupTextPane(final JTextPane textPane, String comment) {
    if( UIUtils.isNimbus() ) {
        textPane.setUI( new BasicTextPaneUI() );
    }
    textPane.setText(comment);
    
    Caret caret = textPane.getCaret();
    if (caret instanceof DefaultCaret) {
        ((DefaultCaret)caret).setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
    }

    // attachments
    if (!attachmentIds.isEmpty()) {
        AttachmentHyperlinkSupport.Attachement a = AttachmentHyperlinkSupport.findAttachment(comment, attachmentIds);
        if (a != null) {
            String attachmentId = a.id;
            if (attachmentId != null) {
                int index = attachmentIds.indexOf(attachmentId);
                if (index != -1) {
                    BugzillaIssue.Attachment attachment = attachments.get(index);
                    AttachmentLink attachmentLink = new AttachmentLink(attachment);
                    HyperlinkSupport.getInstance().registerLink(textPane, new int[] {a.idx1, a.idx2}, attachmentLink);
                } else {
                    Bugzilla.LOG.log(Level.WARNING, "couldn''t find attachment id in: {0}", comment); // NOI18N
                }
            }
        }
    }

    // pop-ups
    textPane.setComponentPopupMenu(commentsPopup);

    textPane.setBackground(blueBackground);

    textPane.setBorder(BorderFactory.createEmptyBorder(3,3,3,3));
    textPane.setEditable(false);
    textPane.getAccessibleContext().setAccessibleName(NbBundle.getMessage(CommentsPanel.class, "CommentsPanel.textPane.AccessibleContext.accessibleName")); // NOI18N
    textPane.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CommentsPanel.class, "CommentsPanel.textPane.AccessibleContext.accessibleDescription")); // NOI18N
}
 
Example #22
Source File: JTextPaneOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps {@code JTextPane.insertIcon(Icon)} through queue
 */
public void insertIcon(final Icon icon) {
    runMapping(new MapVoidAction("insertIcon") {
        @Override
        public void map() {
            ((JTextPane) getSource()).insertIcon(icon);
        }
    });
}
 
Example #23
Source File: NbiTextPane.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public NbiTextPane() {
    super();
    
    setOpaque(false);
    setEditable(false);
    setBorder(new EmptyBorder(0, 0, 0, 0));
    setFocusable(false);
    putClientProperty(JTextPane.HONOR_DISPLAY_PROPERTIES, true);
    
    if (UIManager.getLookAndFeel().getID().equals("Nimbus")) {
        //#134837
        //http://forums.java.net/jive/thread.jspa?messageID=283882
        setBackground(new Color(0, 0, 0, 0));
    }
}
 
Example #24
Source File: RubyConsole.java    From ramus with GNU General Public License v3.0 5 votes vote down vote up
public JComponent createComponent() {
    JPanel panel = new JPanel();
    JPanel console = new JPanel();
    panel.setLayout(new BorderLayout());

    final JEditorPane text = new JTextPane();

    text.setMargin(new Insets(8, 8, 8, 8));
    text.setCaretColor(new Color(0xa4, 0x00, 0x00));
    text.setBackground(new Color(0xf2, 0xf2, 0xf2));
    text.setForeground(new Color(0xa4, 0x00, 0x00));
    Font font = findFont("Monospaced", Font.PLAIN, 14, new String[]{
            "Monaco", "Andale Mono"});

    text.setFont(font);
    JScrollPane pane = new JScrollPane();
    pane.setViewportView(text);
    pane.setBorder(BorderFactory.createLineBorder(Color.darkGray));
    panel.add(pane, BorderLayout.CENTER);
    console.validate();

    final TextAreaReadline tar = new TextAreaReadline(text,
            getString("Wellcom") + " \n\n");

    RubyInstanceConfig config = new RubyInstanceConfig() {
        {
            //setInput(tar.getInputStream());
            //setOutput(new PrintStream(tar.getOutputStream()));
            //setError(new PrintStream(tar.getOutputStream()));
            setObjectSpaceEnabled(false);
        }
    };
    Ruby runtime = Ruby.newInstance(config);
    tar.hookIntoRuntimeWithStreams(runtime);

    run(runtime);
    return panel;
}
 
Example #25
Source File: ApplicationXML.java    From wandora with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected JComponent getTextComponent(String locator) throws Exception {
    JTextPane textComponent = new JTextPane();
    textComponent.setText(getContent(locator));
    textComponent.setFont(new Font("monospaced", Font.PLAIN, 12));
    textComponent.setEditable(false);
    textComponent.setCaretPosition(0);
    textComponent.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    return textComponent;
}
 
Example #26
Source File: ResourcePanel.java    From AML-Project with Apache License 2.0 5 votes vote down vote up
public ResourcePanel(Dimension max, Dimension min)
{
	super("Resource Panel",false,false,false,false);
	this.setMaximumSize(max);
	this.setPreferredSize(min);
	
	desc = new JTextPane();
	desc.setEditable(false);
	
	UIDefaults defaults = new UIDefaults();
	defaults.put("TextPane[Enabled].backgroundPainter", AMLColor.WHITE);
	desc.putClientProperty("Nimbus.Overrides", defaults);
	desc.putClientProperty("Nimbus.Overrides.InheritDefaults", true);
	desc.setBackground(AMLColor.WHITE);
	
	doc = desc.getStyledDocument();
	def = StyleContext.getDefaultStyleContext(). getStyle(StyleContext.DEFAULT_STYLE);
	bold = doc.addStyle("bold", def);
	StyleConstants.setBold(bold, true);
	s = doc.addStyle("source", def);
	StyleConstants.setBold(s, true);
	StyleConstants.setForeground(s, AMLColor.BLUE);
	t = doc.addStyle("target", def);
	StyleConstants.setBold(t, true);
	StyleConstants.setForeground(t, AMLColor.BROWN);
	u = doc.addStyle("uri", def);
	StyleConstants.setUnderline(u, true);
	
	setContentPane(desc);
	pack();
	setVisible(true);

	refresh();
}
 
Example #27
Source File: AnnotationDisplayCustomizationFrame.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the customization panel.
 *
 * @param typeName the type name
 * @return the j panel
 */
private JPanel createCustomizationPanel(String typeName) {
  this.currentTypeName = typeName;
  String defaultAnnotStyleName = CAS.TYPE_NAME_ANNOTATION;
  Style defaultAnnotStyle = this.styleMap.get(defaultAnnotStyleName);
  GridLayout layout = new GridLayout(0, 1);
  JPanel topPanel = new JPanel(layout);
  this.textPane = new JTextPane();
  Style style = this.styleMap.get(typeName);
  if (style == null) {
    style = defaultAnnotStyle;
  }
  Style defaultStyle = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);
  this.textPane.addStyle(defaultStyleName, defaultStyle);
  setCurrentStyle(style);
  this.fgColor = StyleConstants.getForeground(this.currentStyle);
  this.bgColor = StyleConstants.getBackground(this.currentStyle);
  this.fgIcon = new ColorIcon(this.fgColor);
  this.bgIcon = new ColorIcon(this.bgColor);
  topPanel.add(createColorPanel("Foreground: ", this.fgIcon, FG));
  topPanel.add(createColorPanel("Background: ", this.bgIcon, BG));
  setTextPane();
  topPanel.add(this.textPane);
  JPanel buttonPanel = new JPanel();
  createButtonPanel(buttonPanel);
  topPanel.add(buttonPanel);
  return topPanel;
}
 
Example #28
Source File: ImageSubstituter.java    From WorldGrower with GNU General Public License v3.0 5 votes vote down vote up
public void subtituteImagesInTextPane(JTextPane textPane, String text) {
	JTextPaneMapper textPaneMapper = new JTextPaneMapper(textPane, imageInfoReader);
	String changedText = text;
	for(Entry<String, ImageIds> mapping : getTextToImageMapping().entrySet()) {
		changedText = tooltipImages.substituteImages(changedText, mapping.getKey(), mapping.getValue(), textPaneMapper::addImage);
	}
	textPaneMapper.addText(changedText);
}
 
Example #29
Source File: JTextPaneOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps {@code JTextPane.getInputAttributes()} through queue
 */
public MutableAttributeSet getInputAttributes() {
    return (runMapping(new MapAction<MutableAttributeSet>("getInputAttributes") {
        @Override
        public MutableAttributeSet map() {
            return ((JTextPane) getSource()).getInputAttributes();
        }
    }));
}
 
Example #30
Source File: AddPropertyDialog.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Creates new form AddPropertyDialog */
public AddPropertyDialog(NbMavenProjectImpl prj, String goalsText) {
    initComponents();
    manager = new ExplorerManager();
    //project can be null when invoked from Tools/Options
    project = prj;
    okbutton = new JButton(NbBundle.getMessage(AddPropertyDialog.class, "BTN_OK"));
    manager.setRootContext(Node.EMPTY);        
    tpDesc.setEditorKit(new HTMLEditorKit());
    tpDesc.putClientProperty( JTextPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE );
    
    manager.addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            Node[] nds = getExplorerManager().getSelectedNodes();
            if (nds.length != 1) {
                okbutton.setEnabled(false);
            } else {
                PluginIndexManager.ParameterDetail plg = nds[0].getLookup().lookup(PluginIndexManager.ParameterDetail.class);
                if (plg != null) {
                    okbutton.setEnabled(true);
                    tpDesc.setText(plg.getHtmlDetails(false));
                } else {
                    okbutton.setEnabled(false);
                    tpDesc.setText("");
                }
            }
        }
    });
    ((BeanTreeView)tvExpressions).setRootVisible(false);
    ((BeanTreeView)tvExpressions).setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    this.goalsText = goalsText;
    RequestProcessor.getDefault().post(new Loader());
}