aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes onclick of hyperlink Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "onclick of hyperlink" Watch "onclick of hyperlink" New topic
Author

onclick of hyperlink

Reshma Reddy
Ranch Hand

Joined: Dec 21, 2006
Posts: 197
Hi All,
I have one table with two fields, One is number and second is chart(this is hyper link), on click of this hyperlink I need to display another standalone program output (output is one chart with price and time).

How can I call this program on click of this hyperlink.


thanks in advance.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10523
    
    9

What are you using? HTML? JSP? Swing?


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Reshma Reddy
Ranch Hand

Joined: Dec 21, 2006
Posts: 197
Hi maneesh,


I am using swing

main class
=======




onclick of hyperlink calling this method,

HyperTextEditor.java
================



Onclick of this hyperlink, control needs to go another class(I need to mention that in this method) and run that class give that class output (chat is that class output).

thanks.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10523
    
    9

If you look at the JOptionPane#showXXX methods, you will notice the message is of type Object.
What you can do is create a JPanel instance, embed your graph onto it and pass the panel to the JOptionPane
Reshma Reddy
Ranch Hand

Joined: Dec 21, 2006
Posts: 197
Hi maneesh,

I am very new to this swing/awt can you please give me any sudo code to slove this, it is very urgent.

and my chart class name is:: BarChartDemo1.java (control needs to come this class and needs to run this)

thanks is advance.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10523
    
    9

http://faq.javaranch.com/java/EaseUp

1) Subclass JPanel. Let us call it ChartPanel
2) Create a new instance of ChartPanel and draw the required chart onto it.
3) Invoke JOptionPane#showXXX dialog and pass the chart panel instance as the "message"
Reshma Reddy
Ranch Hand

Joined: Dec 21, 2006
Posts: 197
Hi maneesh,

In BarChartDemo1.java is generating chart and it extends ApplicationFrame.

if I will take BarChartDemo1 instance and pass this instance to JPanel subclass and take this JPanel subclass instance and pass this to JOptionPane#showXXX , is it work or ?

thanks,
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19760
    
  20

Instead of calling JOptionPane.showXXX, just show the frame itself using setVisible(true):


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Reshma Reddy
Ranch Hand

Joined: Dec 21, 2006
Posts: 197
thanks maneesh,

It working....

once again thanks...
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10523
    
    9

vardhan reddy wrote:thanks maneesh,

You mean Thanks Rob

I do not think having multiple frame instances in an application is a good idea. That is what Dialogs were designed for.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19760
    
  20

I don't know. Sometimes a frame has an advantage over a dialog. It's not modal (but you can turn that off for dialogs as well), but it shows up in the task bar as well. That can be exactly what you want. Just be careful with EXIT_ON_CLOSE as the default close operation; it will close all your frames and exit the JVM. I doubt that's what you want for all frames, it's probably only desirable for the main frame.
Reshma Reddy
Ranch Hand

Joined: Dec 21, 2006
Posts: 197
thanks rob/maneesh,

for your timely help,

rob, yes it is closing all frames if I will close one frame I don't want this where I need to change.

and I have one doubt in my table I have ten fields and with respect charts if i will click any hyperlink it is showing only one chart(this chart is generated by BarChartDemo1.java), I need different chart for each instrument number, any suggestion



thanks.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10523
    
    9

Pass your instrument type in the constructor of BarChartDemo1 and construct the chart accordingly.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19760
    
  20

vardhan reddy wrote:rob, yes it is closing all frames if I will close one frame I don't want this where I need to change.

BarChartDemo1 extends ApplicationFrame which in turn extends JFrame, so just call setDefaultCloseOperation to DISPOSE_ON_CLOSE instead for those.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: onclick of hyperlink