/* * Make_Bookmarklet.bsh -- removes the newlines and tabs in the current buffer, * making the text appropriate for use as a javascript bookmarklet. * * delvinj@gmail.com * Mar 10, 2006 */ void makeBookmarklet() { String s; if(textArea.getSelectedText() != null) s = textArea.getSelectedText(); else s = textArea.getText(); s = s.replaceAll("\\n", "").replaceAll("\\t", ""); MouseListener ma = new MouseAdapter() { public void mousePressed(MouseEvent e) { ((JTextArea)e.getSource()).selectAll(); } }; JTextArea ta = new JTextArea("javascript:(function(){" + s + "})();"); ta.setLineWrap(false); ta.setWrapStyleWord(false); ta.addMouseListener(ma); ta.setEditable(false); ta.setFont(UIManager.getFont("TextField.font")); JScrollPane sp = new JScrollPane(ta); sp.setPreferredSize(new Dimension(600,120)); JOptionPane.showMessageDialog(view, sp, "Scriptlet", JOptionPane.PLAIN_MESSAGE); } makeBookmarklet();