java编程问题:在swing面板中展示某一URL地址的页面

java编程问题:在swing面板中展示某一URL地址的页面,第1张

你可以写个简单的JAVA浏览器

这有个源码

import javaawtBorderLayout;

import javaawteventActionEvent;

import javaawteventActionListener;

import javanetMalformedURLException;

import javanetURL;

import javautilloggingLevel;

import javautilloggingLogger;

import javaxswingJButton;

import javaxswingJFrame;

import javaxswingJPanel;

import javaxswingJTextField;

import orgjdesktopjdicbrowserIWebBrowser;

import orgjdesktopjdicbrowserWebBrowser;

import orgjdesktopjdicbrowserWebBrowserEvent;

import orgjdesktopjdicbrowserWebBrowserListenerAdapter;

/

@author hadeslee

/

public class Test1 extends JPanel implements ActionListener {

private JTextField input;

private JButton go;

private IWebBrowser web;

public Test1() {

super(new BorderLayout());

initWindow();

}

private void initWindow() {

try {

web = new WebBrowser();

webaddWebBrowserListener(new MyListener());

go = new JButton("转到");

input = new JTextField();

JPanel up = new JPanel(new BorderLayout());

upadd(input, BorderLayoutCENTER);

upadd(go, BorderLayoutEAST);

thisadd(up, BorderLayoutNORTH);

thisadd(webasComponent(), BorderLayoutCENTER);

inputaddActionListener(this);

goaddActionListener(this);

} catch (Exception ex) {

LoggergetLogger(Test1classgetName())log(LevelSEVERE, null, ex);

}

JFrame jf = new JFrame("JAVA浏览器");

jfadd(this, BorderLayoutCENTER);

jfsetSize(500, 300);

jfsetLocationRelativeTo(null);

jfsetVisible(true);

jfsetDefaultCloseOperation(JFrameEXIT_ON_CLOSE);

}

public void actionPerformed(ActionEvent ae) {

doOpen();

}

private void doOpen() {

try {

String text = inputgetText();

if (text == null || textequals("")) {

return;

}

if (!texttoLowerCase()startsWith(">

import javaawt;

import javaawtevent;

class MyDow extends Frame implements ActionListener{

private Label lName,lPassword;

private TextField tName,tPassword;

private Button login,rest,exitout;

private Label login_clew;

private int count=0;

private String myName="nihao";

private String myPassword="5201314";

public void setMyNP(String n,String p){

myName=n;

myPassword=p;

}

public MyDow(String str){

super(str);

}

public void init(){

setLayout(null);

setSize(400,300);

setVisible(true);

setResizable(false);

lName=new Label("姓名");

lNamesetBounds(50, 70, 60, 30);add(lName);

lPassword=new Label("密码");

lPasswordsetBounds(50, 120, 60, 30);add(lPassword);

tName=new TextField("");

tNamesetBounds(110, 70, 200, 30);add(tName);

tPassword=new TextField("");

tPasswordsetBounds(110, 120, 200, 30);add(tPassword);

login=new Button("登录");

loginsetBounds(90, 200, 60, 30);add(login);

rest=new Button("重输");

restsetBounds(170, 200, 60, 30);add(rest);

exitout=new Button("退出");

exitoutsetBounds(250,200,60,30);add(exitout);

login_clew=new Label("");

loginaddActionListener(this);

restaddActionListener(this);

exitoutaddActionListener(this);

}

public void actionPerformed(ActionEvent e){

if(egetSource()==login){

if(count<2){

if(tNamegetText()equalsIgnoreCase(myName)&&tPasswordgetText()equalsIgnoreCase(myPassword)){

removeAll();

add(login_clew);

add(exitout);

exitoutsetLabel("确定");

login_clewsetBounds(160,120,200,30);

login_clewsetText("欢迎XX用户!");

exitoutsetBounds(170,220,60,30);

}else{

add(login_clew);

login_clewsetBounds(90,160,200,30);

login_clewsetText("请输入正确的信息!");

count++;

}

}else{

add(login_clew);

login_clewsetBounds(90,160,200,30);

login_clewsetText("你输入的次数达到了3次,不能登录了!");

}

}else if(egetSource()==exitout){

Systemexit(1);

}else{

lNamesetText("");

lPasswordsetText("");

}

}

}

public class UserLogin {

public static void main(String args[]){

MyDow m=new MyDow("登录窗口");

minit();

}

}

以上就是关于java编程问题:在swing面板中展示某一URL地址的页面全部的内容,包括:java编程问题:在swing面板中展示某一URL地址的页面、如何用JAVA编程编写一个界面程序(急求!!!)、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zz/10217113.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-06
下一篇2023-05-06

发表评论

登录后才能评论

评论列表(0条)

    保存