Write hyperlink to JTextArea
Hi, I am new in Swing.
I am using JTabbedPane with some buttons and JTextArea to write a link names there.
Is it possible to write this links to JTextArea as hyperlinks and add action listener there to start browser when user click on it ?
Thank's.
andrews
No - you'll need a JEditorPane. The API documentation (http://java.sun.com/javase/6/docs/api/javax/swing/JEditorPane.html) gives an example of link click handling. Sun's tutorial discusses editor panes here: http://java.sun.com/docs/books/tutorial/uiswing/components/text.html and later here: http://java.sun.com/docs/books/tutorial/uiswing/components/editorpane.html
You should be aware that JEditorPane acts a pretty minimal browser - but you could adapt the example in the API documentation to launch a browser.
Similar Messages
-
How do I give the program time to write to a JTextArea field
Hi,
I created a swing application which listens for user input with a simple button that starts a whole process of reading database records, looping the records, writing files to a file system etc.
What I would like to do, is to present the user of the application with regular feedback on how far the program is in the overall execution of this big task.
something like:
- file a.pdf moved
- file b.gif moved
etc..
I write these line of text to a JTextArea control in my main panel.
I know the routines work, as feedback from the other controls are posted without problems in the JTextArea.
In a previous life (...those days) I did some work with .Net, and with something similar I learned that sometimes the application needs some time to "catch up" to be able to write to an UI component, by sleeping the thread for a second after each pass.
However, Thread.sleep(1000) does not seem to do the trick in my swing app.
Any ideas on how to do this?
Thanks,
-RogierJTextArea.append() is a thread-safe method, so you can call it and java thread scheduling will do everything for you
I'm not sure what you mean by "catch up", if your GUI stays responsive during your long job, than textArea will be updated.
public void runVeryLongJob(){
for(int i=0;i<numOfTasksInLongJob;i++){
doStuff(i);
//update JTextArea
yourTextArea.append("Task "+i+" done");
}ok...camickr already answere this.. of course you have to be in separate thread for long job -
Is it possible to write hyperlink in each cell of Excel (report 6 and/or 10) in a way to run hyperlink after run report with one mouse click on the cell (active hyperlink) when excel is displayed.
I was trying with this example below but without succes beside this I can not find any solution on metalink:
Re: Hyperlink Related Issue
function F_enameFormatTrigger return boolean is
begin
if :ename = 'SMITH' then
srw.set_hyperlink('http://www.smith.com');
elsif :ename = 'JONES' then
srw.set_hyperlink('http://www.jones.com');
end if;
return (TRUE);
end;nagornyi, that is the problem, because I must type Enter if I want to make hyperlink active! So it is not enought just writing tekst but type Enter as well. Try to do this and tell me if I'm wrong.
-
Hyperlink in MS Word document to Oracle Portal 9.0.4 form does not work
Hi,
In a MS Word document a link to a Oracle Portal 9.0.4 form is written this way:
http://myserver/pls/portal/PORTAL.wwa_app_module.link?p_arg_names=_moduleid&p_arg_values=47602092358
When clicking on the link, and at the same time holding the Ctrl-button, an error is displayed
Error: An unexpected error occurred: ORA-01403: no data found (WWV-16016)
and the URL is changed to
http://myserver/pls/portal/PORTAL.wwa_app_module.show?p_sessionid=248080&p_header=true
But if the hyperlink is copy/pasted from the Word document to the addressline of any browser, the form is opened without problems.
Any proposals how to write hyperlink in MS Word to Portal forms will be much appreciated.
Thanks
Arnehi frank,
the new version of the RTE is only available from 9.0.4.1 onwards. it is not available in 9.0.2.x.
we have a white paper on OTN:
http://www.oracle.com/technology/products/ias/portal/pdf/cm_rte_9041_features.pdf
regards,
christian -
i am using a gui frame and a jTextArea on the frame. I need to ask the user a question and put it in the jTextArea using the append() method. But how to I get their input that they write in the jTextArea and store it in a String variable?
Ah, so you do know how to use your login to post again. I wonder why you don't post some kind of follow-up on your other thread. Usually I shy away from talking to people who ask me a question, I answer them, and they don't even have the common courtesy to say "thanks".
http://forum.java.sun.com/thread.jspa?threadID=613781 -
Exception when useing imporrt jxl.*
Hi it is my class i have written
import java.io.*;
import jxl.*;
import java.util.*;
import jxl.Workbook;
import jxl.write.DateFormat;
import jxl.write.Number;
import jxl.write.*;
import java.text.SimpleDateFormat;
class create
public static void main(String[] args)
try
String filename = "input.xls";
WorkbookSettings ws = new WorkbookSettings();
ws.setLocale(new Locale("en", "EN"));
WritableWorkbook workbook =
Workbook.createWorkbook(new File(filename), ws);
WritableSheet s = workbook.createSheet("Sheet1", 0);
WritableSheet s1 = workbook.createSheet("Sheet1", 0);
writeDataSheet(s);
writeImageSheet(s1);
workbook.write();
workbook.close();
catch (IOException e)
e.printStackTrace();
catch (WriteException e)
e.printStackTrace();
private static void writeDataSheet(WritableSheet s)
throws WriteException
/* Format the Font */
WritableFont wf = new WritableFont(WritableFont.ARIAL,
10, WritableFont.BOLD);
WritableCellFormat cf = new WritableCellFormat(wf);
cf.setWrap(true);
/* Creates Label and writes date to one cell of sheet*/
Label l = new Label(0,0,"Date",cf);
s.addCell(l);
WritableCellFormat cf1 =
new WritableCellFormat(DateFormats.FORMAT9);
DateTime dt =
new DateTime(0,1,new Date(), cf1, DateTime.GMT);
s.adCell(dt);
/* Creates Label and writes float number to one cell of sheet*/
l = new Label(2,0,"Float", cf);
s.addCell(l);
WritableCellFormat cf2 = new WritableCellFormat(NumberFormats.FLOAT);
Number n = new Number(2,1,3.1415926535,cf2);
s.addCell(n);
n = new Number(2,2,-3.1415926535, cf2);
s.addCell(n);
/* Creates Label and writes float number upto 3
decimal to one cell of sheet */
l = new Label(3,0,"3dps",cf);
s.addCell(l);
NumberFormat dp3 = new NumberFormat("#.###");
WritableCellFormat dp3cell = new WritableCellFormat(dp3);
n = new Number(3,1,3.1415926535,dp3cell);
s.addCell(n);
/* Creates Label and adds 2 cells of sheet*/
l = new Label(4, 0, "Add 2 cells",cf);
s.addCell(l);
n = new Number(4,1,10);
s.addCell(n);
n = new Number(4,2,16);
s.addCell(n);
Formula f = new Formula(4,3, "E1+E2");
s.addCell(f);
/* Creates Label and multipies value of one cell of sheet by 2*/
l = new Label(5,0, "Multipy by 2",cf);
s.addCell(l);
n = new Number(5,1,10);
s.addCell(n);
f = new Formula(5,2, "F1 * 3");
s.addCell(f);
/* Creates Label and divide value of one cell of sheet by 2.5 */
l = new Label(6,0, "Divide",cf);
s.addCell(l);
n = new Number(6,1, 12);
s.addCell(n);
f = new Formula(6,2, "F1/2.5");
s.addCell(f);
private static void writeImageSheet(WritableSheet s)
throws WriteException
/* Creates Label and writes image to one cell of sheet*/
Label l = new Label(0, 0, "Image");
s.addCell(l);
WritableImage wi = new WritableImage(0, 3, 5, 7, new File("image.png"));
s.addImage(wi);
/* Creates Label and writes hyperlink to one cell of sheet*/
l = new Label(0,15, "HYPERLINK");
s.addCell(l);
Formula f = new Formula(1, 15,
"HYPERLINK(\"http://www.andykhan.com/jexcelapi\", "+
"\"JExcelApi Home Page\")");
s.addCell(f);
}Hi Shamila,
Pls refer below link:-
jxl.read.biff.BiffException: Unable to recognize OLE stream at jxl.read.bif
The Exception rasied may be due to incompatable version.
Try to save your Excel file in the format 97-2003 and Try.
http://www.archivesat.com/JExcelApi/thread362381.htm
Deepak!!!
Edited by: Deepak Arora on Apr 13, 2010 8:11 AM
Edited by: Deepak Arora on Apr 13, 2010 8:24 AM -
How to address a component in a background tab in a JTabbedPane
Hello and greetings for everybody, this is my first post here. I have a question:
I want to write a simple little chat program, which makes use of a JTabbedpane, and if the user gets a private message from another user, it would open a new tab with the given user's nick in the tab title, and would create a JTextArea on the opened tab and write the message to that specific JTextarea. My question: Is it possible to write on the JTextarea, while the given tab is in the background? How can I address that specific JTextarea on the specified tab?
Thank you very much in advance for the answers, and I wis you all a nice day!// create a Map<String, JTextArea>
public static void privMsg(String nick) {
if (mainwindow.tabpane.indexOfTab(nick)==-1) { // look for the nick in the map, not on the tabbedpane (if map.get(nick) != null
javax.swing.JScrollPane panel=new javax.swing.JScrollPane();
javax.swing.JTextArea msgBox=new javax.swing.JTextArea();
msgBox.setEditable(false);
msgBox.setAutoscrolls(true);
msgBox.setLineWrap(true);
panel.setViewportView(msgBox);
mw.tabpane.addTab(nick,panel);
mw.tabpane.setSelectedIndex(mw.tabpane.indexOfTab(nick));
msgBox.append("Private conversation: "+nick+"\n");
// add the nick and the msgBox to the map
// if the nick already has been added to the map, (meaning there's already a tab open for that nick), then get that textpane and write to it. That's the basic idea behind MVC, which you'd do yourself a huge favor by reading into. You separate the display of the data from the data itself. That way when you update the data (Model), you don't have to deal with gui code (View). The actions the user takes are also separated into the Controller. -
Scroll 2 JScrollPanes together?
Quick question. (I hope it's quick anyway.)
I have 2 JTextAreas side by side added to JScrollPanes.
I past a list in the one on the left, click a button to do something with that list and it writes to the JTextArea on the right like a log file.
If the list is longer than the JTextArea is tall, It puts a scroll bar on the right. And when the log pane gets too long, I keep the scrollbar on it at the bottom with this line of code:
somelog.setCaretPosition(somelog.getText().length());My question is...Can I make the scrollbars of both syncronized? Because right now, only the one on the right keeps up with the bottom of it's text. I would like them both to scroll at the same time. Because there is one line of log output for each item in the list. I would like for when the log starts scrolling, the list scrolls with it so the items remain lined up.
Thanks!
TimTry sharing the scrollpanes' scrollbars' model
scrollList.getVerticalScrollBar().setModel(scrollLog.getVerticalScrollBar().getModel());db -
Printing out French characters
Hi to everyone. I'm trying to make a small application that will help me learn french verbes. I have the verbes in a file (written with notepad on windows) and I want to print them usign System.out.println(); The problem is I'm in Greece, so my locale is set to greek. I've no trouble printing greek. I've tried changing the locale with
Locale.setDefault(new Locale("fr", "FR"); but still French characters come out wrong (Copyright characters, question marks etc.) Can someone enlighten me? Thanksdon't use System.out.println(), perhaps write to a JTextArea. The problem is your console/terminal/dos
-
Printing gives wrong characters
When I print a web-page, a lot of garbled characters appear on the print. This happens with different printers and also when I print to a pdf. Also, the printing header is completely garbled.
In IE these pages print normally.don't use System.out.println(), perhaps write to a JTextArea. The problem is your console/terminal/dos
-
Urgent! JScrollPane for Window
To use JScrollPane for a JTextArea, we usually will write as follow:
JTextArea text = new JTextArea (5,15);
JScrollPane scroll = new JScrollPane (text);
JPanel pane = new JPanel;
pane.add(scroll);
setContent(pane);
But if i want to add JScrollPane to a window, what should I write after
"JScrollPane scroll = new JScrollPane (.......)"?
and my this window is only to display a 2D graphic. So, I will have code as below,
GraphMsg graMsg = new GraphMsg();
Container content = getContentPane();
content.add(graMsg);
JScrollPane scrollMsg = new JScrollPane(..............);
How should I add the JScrollPane to a JPanel?
Thanks...Just add the panel to the JFrame... I assume that's what you mean by "window".
JTextArea text = new JTextArea (5,15);
JScrollPane scroll = new JScrollPane (text);
JPanel panel = new JPanel;
panel.add(scroll);
JFrame frame = new JFrame();
frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add(panel, BorderLayout.CENTER);
frame.pack();
frame.setVisible(true); -
Hallo all,
I need your help ;) I am having a JTextArea and I want to write into this JTextArea a kind of URL link like http://www.abc.com and when the user clicks on this link it will open this link in a browser. How can I manage to do it? Do you know a tutorial site or a brief example for it?SomasekharPatil wrote:
Use html code to display the link http://www.abc.com
Example http://www.abc.com
Make sure that JTextArea is html enabled.The API does do say "displays plain text". Do you mean a JEditorPane? Even then to make it open in a browser rather than just the editor pane you need to do a little more than simply include the link, you also need to write a HyperlinkListener that calls [Desktop.browser|http://java.sun.com/javase/6/docs/api/java/awt/Desktop.html#browse(java.net.URI)].
@OP
[*Java Tutorials: * How to Use Editor Panes and Text Panes|http://java.sun.com/docs/books/tutorial/uiswing/components/editorpane.html] -
How could we move images that are brought in to an applat viewer with the help of mouse one at a time?
the one to which the mouse pointere is pointed?
please do explain it I am a beginner.
Edited by: Afzal_a_s on May 8, 2009 3:10 AMCut/copy/paste are not a security issue. I use these as a good way to get around security - my applet writes code into JTextArea, users copy this and then paste into their own code.
Why not just go on a single click?
If you stick with a TextArea (no Swing) your applet will work in MSIE which has a 1.1 JVM. JTextArea would be much better, but you'll have to wrestle with EMBED and OBJECT tags. (You'll have to wrestle with that in a couple years when the Microsoft license expires.) This is all laid out at:
http://martinrinehart.com, Articles, Launching Applets.
As you're academic, everything there is freeware. The javascript that solves all the launch issues is
http://martinrinehart.com/examples/launchApplet.js -
How to write selected text in JTextArea in selected location
iam using JTextArea ...
i want to writer selected text in selected location,,,,,,use
JTextArea.getSelectedText() and
JTextArea.replaceRange(String str, int start, int end)
methods. -
How to make hyperlinks in JTextField/JtextArea ??
My JTextField/JtextArea has got this Text.
String text = "Get information from http://www.hotmail.com, if you have problems go to http://www.google.com " ;
How to make hyperlinks for http://www.hotmail.com and http://www.google.com texts only???
And how to call those sites???Add a mouse listener, when the user double clicks - see if they've clicked on text that is a valid link.
The limitation of using textfield or textarea is that you get no styling. I dont know why you're refusing those suggestions, but you're just creating more work for yourself.
Maybe you are looking for
-
Trying Trial Version: How do I open a file to edit?
I managed to do this somehow a week ago. Now the program only recognizes files I have previously imported. It will not allow me to search folders on drive to select individual photos. At present, The only file folders it recognizes are those I initi
-
How can I get rid off "Download" in action menu
Dear All, In interactive report, How can I get rid off "Download" in action menu. Thanks In Advance,
-
Hello, One of my co-worker changed our the ssh ciphers that we currently use. We made a change to /etc/ssh/ssh_config on our Solaris 10 servers. Security said that we have to use aes128-ctr or higher, but not aes128-cbc. The issue is that many of the
-
WILL FINAL EXPORT FROM QUICKTIME OVERWRITE OTHERS
I have a project that was created using jpegs and mp4's that were exported using the H.264 format, I initially exported entire project with H.264 only to not be able to play on LG Google TV... after talking to LG, realized I needed to save project wi
-
Remove Bullets from Featured Product List - Style a module
I have a list of Featured Products by the Tag/Module: {module_productfeaturelist,Featured Product}. Everything works great, except I am getting big bullet before each product listed. Obviously I need to add styling "list-style:none" but I can't figur