Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / October 2005

Tip: Looking for answers? Try searching our database.

editor how to

Thread view: 
Bruintje Beer - 30 Sep 2005 15:47 GMT
Hi,

I want to write my own editor (don't shoot I know there are good etitors) .
Can somebody give me a hint which component I can use for my editor for
example JPanel, JTextArea or ???.

John
Andrew Thompson - 30 Sep 2005 16:32 GMT
> I want to write my own editor (don't shoot I know there are good etitors) .
> Can somebody give me a hint which component I can use for my editor for
> example JPanel, JTextArea or ???.

What do you want to edit?  I would recopmmend different components
for plain text or bytecodes ((J)TextArea) than formatted text like
RTF or HTML (JTextPane/JEditorPane).
Oliver Wong - 30 Sep 2005 16:39 GMT
>> I want to write my own editor (don't shoot I know there are good etitors)
>> . Can somebody give me a hint which component I can use for my editor for
[quoted text clipped - 3 lines]
> for plain text or bytecodes ((J)TextArea) than formatted text like
> RTF or HTML (JTextPane/JEditorPane).

   You'd probably want a JFrame and a JScrollPane somewhere in there too.
And maybe a JMenu, with "File->Save" and "File->Open" MenuItems. That would
take you into JFileChooser territory.

You might be interested "A Visual Index to the Swing Components":
http://java.sun.com/docs/books/tutorial/uiswing/components/components.html

   - Oliver
Andrew Thompson - 30 Sep 2005 17:06 GMT
>>>I want to write my own editor (don't shoot I know there are good etitors)
>>>. Can somebody give me a hint which component I can use for my editor for
[quoted text clipped - 5 lines]
>
>     You'd probably want a JFrame ...

Why so fussy?  We have, (as potential 'root' containers)
(J)Applet, JWindow, JDialog, JOptionPane, internal frames
(what are they called again?)..  A lot of choices.

I chose (quite wisely, by chance) to avoid the entire
complications of the host containers.  One step at a
time.   ;-)
Oliver Wong - 30 Sep 2005 20:40 GMT
>>>>I want to write my own editor (don't shoot I know there are good
>>>>etitors) . Can somebody give me a hint which component I can use for my
[quoted text clipped - 13 lines]
> complications of the host containers.  One step at a
> time.   ;-)

   I'd actually imagine that the first step would be use a JFrame. I can't
imagine the OP doing much with a JTextArea without a root container, and
getting an empty window to show up somewhere on the screen is the GUI
universe's equivalent of "Hello World".

   As for not using the alternatives, JFrame is probably the closest to
what the OP wants, given that (s)he's writing a text editor, and that (s)he
seems new to GUIs (and thus probably doesn't want to do anything too fancy
for a first try).

   (J)Applet: Gotta teach the OP about signing.
   JWindow: Gotta teach the OP how to provide his/her own title bar and
other decorators.
   JDialog: they're (usually) dependent on a Frame anyway, so you're
supposed to have a JFrame involved with this solution.
   JOptionPane: uses a JDialog behind the scenes, so same rationale as
above.

   The JInternalFrame might actually be suitable for the OP's project, but
again it adds a bit of complication. Perhaps when the OP is ready to write
his/her second text editor...

   - Oliver
Andrew Thompson - 30 Sep 2005 21:00 GMT
...
>     I'd actually imagine that the first step would be use a JFrame. I can't
> imagine the OP doing much with a JTextArea without a root container, and
[quoted text clipped - 5 lines]
> seems new to GUIs (and thus probably doesn't want to do anything too fancy
> for a first try).

<(slightly) tongue in cheek>
not 'too fancy'?  Then we're talking 'Frame/TextArea'!
It'll do plain text just fine.   The AWT TextArea even
has a built-in scrollbars, so no need for the JScrollPane.
(And FileDialog is a lot easier to use than that damnable
JFileChooser!)
</(slightly) tongue in cheek>
Oliver Wong - 30 Sep 2005 21:23 GMT
> The AWT TextArea even
> has a built-in scrollbars, so no need for the JScrollPane.

   Seriously? It's been a long time since I've used AWT...

   BTW, are there any reasons (other than supporting clients running older
version of Java) to use AWT these days?

   - Oliver
Andrew Thompson - 30 Sep 2005 22:08 GMT
>>The AWT TextArea even
>>has a built-in scrollbars, so no need for the JScrollPane.
>
>     Seriously?

Sure.  You can specify the scroll-bar behaviour
in the constructor..
<http://java.sun.com/j2se/1.5.0/docs/api/java/awt/TextArea.html#TextArea(java.lan
g.String,%20int,%20int,%20int
)>

>..It's been a long time since I've used AWT...

I prefer to use Swing wherever practical (old VM's
being the main problem).  Whenever I do AWT I go to
'reach for..' that toolbar, or color chooser,
or tabbed pane, or HTML rendering component, or..
only to curse and think how I will either implement it,
or more often, redesign the app(let - usually) around it.

>     BTW, are there any reasons (other than supporting clients running older
> version of Java) to use AWT these days?

My main reason for mentioning AWT these days is usually
to point out that most of the 'Swing' GUI building
involves a lot of classes and packages in the 'AWT'.
E.G. ..most of the layouts, some of the AWT GUI events
and exceptions, classes for color/color spaces, images,
DND, fonts, geometry and printing..

Noobs who get 'seduced' by Swing often fail to explore
the sheer extent of what the AWT (in general) provides.

Ultimately I feel it would have been better to separate
the packages of the GUI components from the rest of the
events, layouts, printing, images etcetera., but then..
maybe that's just me.
Roedy Green - 01 Oct 2005 01:59 GMT
>    BTW, are there any reasons (other than supporting clients running older
>version of Java) to use AWT these days?

copy/paste works.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.

Pete Barrett - 01 Oct 2005 20:13 GMT
>> The AWT TextArea even
>> has a built-in scrollbars, so no need for the JScrollPane.
[quoted text clipped - 3 lines]
>    BTW, are there any reasons (other than supporting clients running older
>version of Java) to use AWT these days?

Support for native look and feel? Swing pluggable LookAndFeelS are
quite good, but they're not native widgets, while the AWT widgets
ought to have a native peer somewhere around, which will presumably
fit into the native look and feel better than any pure Java component
can do. At the very least, Swing implementations will lag behind the
OS UI lokk and feel by a few months.

Pete Barrett
Roedy Green - 30 Sep 2005 20:19 GMT
>I want to write my own editor (don't shoot I know there are good etitors) .
>Can somebody give me a hint which component I can use for my editor for
>example JPanel, JTextArea or ???.

JEditorPane JTextPane are likely starting places.  For a very simple
one JTextArea.

see http://mindprod.com/jgloss/jtextpane.html
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.