The Artima Developer Community
Sponsored Link

Java Answers Forum
Toogle effect using a JButton

3 replies on 1 page. Most recent reply: Jan 24, 2005 10:52 PM by Matthias Neumair

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
Sanjay Perera

Posts: 42
Nickname: angel6
Registered: Apr, 2004

Toogle effect using a JButton Posted: Jan 20, 2005 4:36 AM
Reply to this message Reply
Advertisement
Hello people,
Question 1.
I have a problem. I want to have the toggle effect for a Jbutton. How to do that?
Example: In microsoft paint, click on Pencil button and it will look like PRESSED until you click another button. How to do that with a JButton. Do I have to use a panel or something similar and change its 3D effects for mouse clicks? I have done like that in some other languages like Visual FOx Pro.

Question 2.
I am using Sun One studio 5. For a JPanel I added an icon and when executing through ID I cannot see the Icon. But when I am executing the class using Command Prompt I see it. What is the problem? I experienced this problem in JBuilder too. Any reason for that? But when providing full path as....
Icon image = new ImageIcon("C:\icon.jpg");
it gets displayed through IDE.

Question 3.
How to get the current path? Example is for JApplet you can use getCodeBase(). What are similar functions.


Thanks for the trouble,
Sanjay Perera


Matthias Neumair

Posts: 660
Nickname: neumi
Registered: Sep, 2003

Re: Toogle effect using a JButton Posted: Jan 20, 2005 10:00 AM
Reply to this message Reply
1. There is a object called JButtonGroup.

If you assign all JToggleButtons to the same group. only one of them can be selected at the same time.


2. Did you type it in manually?
SunOne uses a form builder.
It only shows things you ad using the graphical interface.

3.
System.getProperties().getProperty("user.dir")

Sanjay Perera

Posts: 42
Nickname: angel6
Registered: Apr, 2004

Re: Toogle effect using a JButton Posted: Jan 22, 2005 7:51 PM
Reply to this message Reply
Thanks, Toggle Button was accomplished. Yes I typed them manually. Reason was that GUI form used the absolute path of the icon and I didn't want that. What I wanted to have was the relative paht. By the way I am not using GUI form editor because I want to do everything manually (At least for sometime to get familiar and memorize important teqniques).

Matthias Neumair

Posts: 660
Nickname: neumi
Registered: Sep, 2003

Re: Toogle effect using a JButton Posted: Jan 24, 2005 10:52 PM
Reply to this message Reply
You can use relative paths in the GUI editor.

One way to do it is using the classpath option.

You can type the path manually, but only in the properties panel.


I don't think there exists any GUI editor wich reads your code and then creates the components.

I'm using Netbeans IDE.
Netbeans creats a .form file wich contains all the informations displayed on the screen. From this file it creates the java source code. The locked parts of the code are the parts created by the IDE. You can add components manually, but they won't be shown in the editor.

If you have specialized components you have to add them manually or to create a Java Bean and import that one in the IDE. Creating GUI Beans is a lot of work, so normally I use the GUI Editor to create all the standard stuff and then add my additoinal components.

Flat View: This topic has 3 replies on 1 page
Topic: Performance in ways of Exception Handling. Previous Topic   Next Topic Topic: Garbage collector

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use