Thread View: aus.computers.java
2 messages
2 total messages
Started by Michael Rowlands
Mon, 28 Jun 1999 00:00
Beginner Needs Help: Trying to get a Text Editor going
Author: Michael Rowlands
Date: Mon, 28 Jun 1999 00:00
Date: Mon, 28 Jun 1999 00:00
41 lines
2289 bytes
2289 bytes
Hi,
I am trying to get a text editor going and I am having a few problems with
CheckboxMenuItem, I want to create a CheckboxMenuItem which allows the user
to select if the font is plain,bold, or italic and to deselect plan if
italic or bold is select and vice versa.
The code complies but when I click on plain for instance italic and bold are
still ticked. I have used the following code (all of my code is in the
attachment)
public void itemStateChanged(ItemEvent event) /*also tried same code in
public void actionPerformed
(ActionEvent e)*/
CheckboxMenuItem item = (CheckboxMenuItem)event.getSource();
if (item.equals(fontPlain)) file://try putting text strings in i.e.
"Plain"etc
fontPlain
{
fontPlain.setState(true);
fontItalic.setState(false);
fontBold.setState(false);
repaint(); file://friend suggested
}
}
I have declared fontPlain as "private CheckboxMenuItem fontPlain = new
CheckboxMenuItem("Plan");" and set it on the menu by
" MenuItem fontPlain = new CheckboxMenuItem("Plain",true); file://insure
that
var is "true"
fontPlain.addActionListener(this);
fontStyle.add(fontPlain);"
I believe that this is my main problem is that the menu is not refreshing
but I do not know how to fix it
Many Thanks
Michael Rowlands
Re: Beginner Needs Help: Trying to get a Text Editor going
Author: P.Sarat Chandra Sai
Date: Mon, 28 Jun 1999 00:00
Date: Mon, 28 Jun 1999 00:00
73 lines
3415 bytes
3415 bytes
Real tricky question you got. I took me too much time to figure out
what was wrong. I couldnt figure out at first but finally I got this
idea. As far as the code is concerned it is fine. But when you say
fontPlain.addActionListener(this) , there lies the problem. Does your
application or applet or class which includes the initialization
implements the ActionListener Interface? Otherwise try doing it. But
then as you say the code compiles well, then there should be no
problem. But check this out and if it does not work, I got another
solution. But that afterwards.If this aint working send me the code in
mail and I will fix it up for you.
In article <930523282.266344@Chaos.es.co.nz>,
"Michael Rowlands" <michaelrowlands@bigfoot.com> wrote:
> Hi,
> I am trying to get a text editor going and I am having a few problems
with
> CheckboxMenuItem, I want to create a CheckboxMenuItem which allows
the user
> to select if the font is plain,bold, or italic and to deselect plan
if
> italic or bold is select and vice versa.
> The code complies but when I click on plain for instance italic and
bold are
> still ticked. I have used the following code (all of my code is in
the
> attachment)
>
> public void itemStateChanged(ItemEvent event) /*also tried same code
in
> public void actionPerformed
> (ActionEvent e)*/
>
> CheckboxMenuItem item = (CheckboxMenuItem)event.getSource();
>
> if (item.equals(fontPlain)) file://try putting text strings in i.e.
> "Plain"etc
> fontPlain
> {
> fontPlain.setState(true);
> fontItalic.setState(false);
> fontBold.setState(false);
> repaint(); file://friend suggested
> }
> }
>
> I have declared fontPlain as "private CheckboxMenuItem fontPlain =
new
> CheckboxMenuItem("Plan");" and set it on the menu by
> " MenuItem fontPlain = new CheckboxMenuItem("Plain",true);
file://insure
> that
> var is "true"
> fontPlain.addActionListener(this);
> fontStyle.add(fontPlain);"
> I believe that this is my main problem is that the menu is not
refreshing
> but I do not know how to fix it
>
> Many Thanks
>
> Michael Rowlands
>
>
--
P.Sarat Chandra Sai ,Java Developer ,@urservice
Join <A HREF="http://www.deja.com/~javadev">Java
Developer's Forum</A> to get personal attention
and answers to your doubts by e-mail
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads