Closed GoogleCodeExporter closed 8 years ago
Thanks!
However adding a toolbar will require the users to use a new component, which
has the
JEditorPane, JScrollBar and any other things (including the Toolbar and possible
status bar). This is not the initial design of "use your own editor, your own
gui,
and just call setContentType to have syntax colors"
I'll see how it can be done within the framework. In the meantime, you should
be
able to get the actions from the JEditorPane and add them to any toolbar in
your own
application.
Please vote if you think it's a good idea to provide a component with integrated
scrollbar, toolabr and status bar, in addition to the current method.
Original comment by ayman.al...@gmail.com
on 9 Mar 2009 at 2:32
That makes sense. Maybe an additional factory method to create a toolbar with
those
actions is appropriate in this case. That way the user can put it wherever they
want, and add to it however they want.
Original comment by chad.dor...@gmail.com
on 9 Mar 2009 at 4:36
I just added a method to the DefaultSyntaxKit that will add all popup menu
items,
with separators, to a ToolBar component passed to it.
I'll perform more tests and put on SVN shortly.
Original comment by ayman.al...@gmail.com
on 12 Mar 2009 at 10:37
committed initial draft in r100. Any suggestions for implementing drop down
buttons
in the toolbar for nested menu?
Original comment by ayman.al...@gmail.com
on 12 Mar 2009 at 10:55
I just tried out this feature, and I love it. However, I'm not sure if I'm
using it
right, because 'addToolBarActions()' is not a static function, and the examples
only
reference static functions such as 'DefaultSyntaxKit.initKit();'. Here is the
code I
used:
DefaultSyntaxKit kit = new jsyntaxpane.syntaxkits.GroovySyntaxKit();
editorPane.setEditorKit(kit);
kit.addToolBarActions(editorPane, jToolBar1);
Am I using these objects correctly? If so, maybe I could add this example to the
Wiki, to help out other new-comers.
Original comment by djet...@gmail.com
on 14 Mar 2009 at 7:50
Your code will work, but it is better to use something like the tester, as
below:
EditorKit kit = jEdtTest.getEditorKit();
if (kit instanceof DefaultSyntaxKit) {
DefaultSyntaxKit defaultSyntaxKit = (DefaultSyntaxKit) kit;
defaultSyntaxKit.addToolBarActions(jEdtTest, jToolBar1);
}
jToolBar1.validate();
I did not make the method static, so that you will get the kit that is
appropriate
to the editor you have, as above.
You should also remember to call the validate() method on the toolbar to have
the
buttons displayed. validate is not called for you because you may want to add
more
stuff to the toolbar.
Original comment by ayman.al...@gmail.com
on 15 Mar 2009 at 5:14
I was playing around with the new toolbar, which is very cool by the way, and
noticed
that some of the actions throw NullPointerExceptions when they are used before
text
has been entered into the editorpane. This is not a problem with the toolbar
really,
but with the actions themselves. They are acting on a null reference to the
SyntaxDocument, which apparently only becomes non-null once the user types
something
into the editor pane. To test it out, try clicking undo/redo before any text
has
been entered.
Original comment by chad.dor...@gmail.com
on 15 Mar 2009 at 6:26
My previous comment was not entirely correct. The NullPointerException does
appear
sometimes, but not under those exact conditions. I will try to root cause the
exact
conditions under which I am seeing the exceptions.
Original comment by chad.dor...@gmail.com
on 15 Mar 2009 at 7:19
I tried undo/redo before any text, but no NPE thrown. I'm using the provided
SyntaxTester.
Can you be more specific?
Original comment by ayman.al...@gmail.com
on 15 Mar 2009 at 7:21
Ok here we go, open the jsyntaxeditor, click the find button on the toolbar to
bring
up the find dialog. Close it without doing any find/replace. Now click the
redo
button on the toolbar.
Original comment by chad.dor...@gmail.com
on 15 Mar 2009 at 7:24
Still can't do it. Can you give me the NPE trace? I'll see how it was created
then.
Thanks
Original comment by ayman.al...@gmail.com
on 15 Mar 2009 at 7:41
Weird, I am also using your SyntaxTester. I will see if I can reproduce in
more than
the one way I described before. Either way, here is the NPE.
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at jsyntaxpane.actions.UndoAction.actionPerformed(UndoAction.java:34)
at
jsyntaxpane.actions.DefaultSyntaxAction.actionPerformed(DefaultSyntaxAction.java
:64)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at
javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.jav
a:236)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:272)
at java.awt.Component.processMouseEvent(Component.java:6134)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
at java.awt.Component.processEvent(Component.java:5899)
at java.awt.Container.processEvent(Container.java:2023)
at java.awt.Component.dispatchEventImpl(Component.java:4501)
at java.awt.Container.dispatchEventImpl(Container.java:2081)
at java.awt.Component.dispatchEvent(Component.java:4331)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4301)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3965)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3895)
at java.awt.Container.dispatchEventImpl(Container.java:2067)
at java.awt.Window.dispatchEventImpl(Window.java:2458)
at java.awt.Component.dispatchEvent(Component.java:4331)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269
)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174
)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Original comment by chad.dor...@gmail.com
on 15 Mar 2009 at 7:45
Here are the exact steps I am using to recreate this:
1.) Open SyntaxTester
2.) Click in editor pane to give it focus
3.) Click find button on toolbar
4.) Close the find dialog by clicking the X (close) button for the dialog. Do
this
without having performed any find or replace
5.) Click the undo button on the toolbar
Original comment by chad.dor...@gmail.com
on 15 Mar 2009 at 7:53
Still could not recreate :-(
But i did make some changes anyway. Make sure you get the latest r105, which
should
display a better looking toolbar.
Original comment by ayman.al...@gmail.com
on 15 Mar 2009 at 8:23
This issue does not happen in r105, so thanks for fixing it inadvertently. And
yes,
the appearance of the toolbar looks much cleaner.
Original comment by chad.dor...@gmail.com
on 15 Mar 2009 at 9:04
Okay then. Another one bites the dust.
Case closed :-)
Original comment by ayman.al...@gmail.com
on 15 Mar 2009 at 9:12
If you are still looking for a good way to show a drop down button in the
toolbar for
a nested menu, check out this page on Geertjan Wielenga's blog.
http://java.dzone.com/news/drop-down-buttons-swing-new-al
He discusses a drop down button class created for the Netbeans Platform, but
that can
be used even outside the platform via a self-contained JAR. In fact, I suspect
the
drop down button class could be extracted from the JAR as well so you could
include
it directly in your library. Furthermore, the comments on the page discuss
other
drop down button alternatives.
Original comment by chad.dor...@gmail.com
on 15 Mar 2009 at 8:02
Original issue reported on code.google.com by
chad.dor...@gmail.com
on 9 Mar 2009 at 6:32