超鏈接代碼java 超鏈接代碼軟件

java代碼怎么將"http://…"這樣一個路徑,寫成類似超鏈接那樣?

java超鏈接:

創(chuàng)新互聯(lián)專業(yè)為企業(yè)提供隆林網(wǎng)站建設、隆林做網(wǎng)站、隆林網(wǎng)站設計、隆林網(wǎng)站制作等企業(yè)網(wǎng)站建設、網(wǎng)頁設計與制作、隆林企業(yè)網(wǎng)站模板建站服務,十年隆林做網(wǎng)站經(jīng)驗,不只是建網(wǎng)站,更提供有價值的思路和整體網(wǎng)絡服務。

button.setLabel("htmla href=\"http:\\\angelsinklow"angelsinklow/a/html");

如果用start的話,這樣寫

Runtime.getRuntime().exec("cmd /c start ‘http:\\\angelsinklow");

Runtime.getRuntime().exec("iexplore ");

對于JEditorPane,JTextPane,JTextArea,JLabel可以使用

setText("htmlA href=''test/A/html")

對于JEditorPane使用

setEditorKitForContentType("text/html", new PatchedHTMLEditorKit());

addHyperlinkListener(HyperlinkListener ... );

需要引入java.net.url包。

try{getAppletContext().showDocument(new URL("http:\\\angelsinklow"),"打開位置");}

catch(Exception ex) {System.out.println("error"); }

就超鏈接了。

java如何實現(xiàn)超鏈接下載

java實現(xiàn)超鏈接下載方法如下:

response.setHeader("Content-disposition","attachment;filename="下載的文件名字);

備注:讓response調(diào)用setheader方法添加下載的頭給客戶的瀏覽器,瀏覽器收到該頭后就會打開相應的下載對話框。

java 的超鏈接代碼 怎么寫啊

a href="your target url"Link/a

如果在servlet中:

PrintWriter?out?=?res.getWriter();

out.println("a?href='your?target?url'Link/a");

如果是連接自己項目中的,請注意相對路徑的寫法。建議加上context path.

JAVA消息框中如何加入超鏈接地址

import java.awt.event.*;

import javax.swing.*;

import java.awt.*;

public class 超鏈接 extends JFrame implements ActionListener {

/**

*

*/

private static final long serialVersionUID = 107369444274434673L;

JFrame jf = new JFrame("一個超鏈接實現(xiàn)的例子");

JPanel jp = new JPanel();

JButton butt = new JButton("確定彈出");

MyDialog1 mydialog;

超鏈接() {

butt.addActionListener(this);

jp.add(butt);

jf.setContentPane(jp);

jf.pack();

jf.setBounds(40, 40, 200, 200);

jf.setVisible(true);

}

public static void main(String[] args) {

new 超鏈接();

}

public void actionPerformed(ActionEvent e) {

if (e.getSource() == butt) {

mydialog=new MyDialog1(jf,"提示",true);

mydialog.setVisible(true);

}

}

}

//1.須為有模式對話框

//2。要能在母窗體的中央彈出==未實現(xiàn)

//部分代碼可能有更好的實現(xiàn)....總之是要能加入那個自定義的JLabel

class MyDialog1 extends Dialog implements ActionListener{

static final int YES=1,NO=0;

int message=-1;

Button yes,no;

MyDialog1(Frame f,String s,boolean b){

super(f,s,b);

LinkLabel2 label = new LinkLabel2("百度一下,你就知道", "");

yes=new Button("Yes");

yes.addActionListener(this);

no=new Button("No");

no.addActionListener(this);

setLayout(new FlowLayout());

add(label);

add(yes);

add(no);

//setBounds(60,60,100,100);

setSize(350,100);

int winWidth=getBounds().width;//獲取窗口的款等于320

int winHeigth=getBounds().height;//獲取窗口的款等于350

Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();

int screenWidth = (int)dim.getWidth();//獲取屏幕的寬

int screenHeight = (int)dim.getHeight();//獲取屏幕的高

setLocation((screenWidth-winWidth)/2, (screenHeight-winHeigth)/2);//定制窗口的位置

addWindowListener(new WindowAdapter(){

public void windowClosing(WindowEvent e){

message=-1;setVisible(false);

}

}

);

}

public void actionPerformed(ActionEvent e){

if(e.getSource()==yes){

message=YES;setVisible(false);

}

else if(e.getSource()==no){

message=NO;setVisible(false);

}

}

public int getMessage(){

return message;

}

}

class LinkLabel2 extends JLabel {

private String text, url;

private boolean isSupported;

public LinkLabel2(String text, String url) {

this.text = text;

this.url = url;

try {

this.isSupported = Desktop.isDesktopSupported()

Desktop.getDesktop().isSupported(Desktop.Action.BROWSE);

} catch (Exception e) {

this.isSupported = false;

}

setText(false);

addMouseListener(new MouseAdapter() {

public void mouseEntered(MouseEvent e) {

setText(isSupported);

if (isSupported)

setCursor(new Cursor(Cursor.HAND_CURSOR));

}

public void mouseExited(MouseEvent e) {

setText(false);

}

public void mouseClicked(MouseEvent e) {

try {

Desktop.getDesktop().browse(

new java.net.URI(LinkLabel2.this.url));

} catch (Exception ex) {

}

}

});

}

private void setText(boolean b) {

if (!b)

setText("htmlfont color=blueu" + text);

else

setText("htmlfont color=redu" + text);

}

}

當前名稱:超鏈接代碼java 超鏈接代碼軟件
網(wǎng)頁地址:http://muchs.cn/article26/doshgjg.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供營銷型網(wǎng)站建設、標簽優(yōu)化、網(wǎng)站收錄、網(wǎng)站維護、企業(yè)建站、網(wǎng)站設計

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設公司