「java网页按钮」javaweb按钮
本篇文章给大家谈谈java网页按钮,以及javaweb按钮对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。
本文目录一览:
- 1、java按一下按钮就能跳到另一个界面怎么实现
- 2、java在页面上通过按钮控制任务开始、暂停、继续执行等操作
- 3、java获取ie中某个页面的网页游戏中的按钮怎么写?
- 4、用Java 或者VB 知道一个网页按钮的ID和类之后 怎么模拟出点击和选择的功能
- 5、java程序中如何实现单击页面a中的按钮跳转到页面b
java按一下按钮就能跳到另一个界面怎么实现
java实现的简单登录页面,从一个按钮点击后跳转的页面的jframe写法:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class jb{
public static void main(String args[]){
JFrame f=new JFrame("点我跳转");
Container contentPane=f.getContentPane();
contentPane.setLayout(new GridLayout(1,2));
Icon icon=new ImageIcon("b.jpg");
JLabel label2=new JLabel("a",icon,JLabel.CENTER);
label2.setHorizontalTextPosition(JLabel.CENTER);
contentPane.setLayout(new FlowLayout( FlowLayout.CENTER,10,10));
JButton bb=new JButton("图片");
bb.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
JFrame bf=new JFrame("新窗体");
Icon icon=new ImageIcon("enter.jpg");
JLabel label2=new JLabel(icon);
bf.getContentPane().add(label2);
bf.setSize(300,360);
bf.show();
}});
contentPane.add(label2);
contentPane.add(bb);
f.pack();
f.show();
}}
java在页面上通过按钮控制任务开始、暂停、继续执行等操作
页面上,用html写好按钮,然后按钮的点击事件,调用后台java写的任务操作方法即可。
java获取ie中某个页面的网页游戏中的按钮怎么写?
Desktop desktop = Desktop.getDesktop(); desktop.browse(new URI("URL地址")); 这个是用你默认的浏览器 打开指定超链
用Java 或者VB 知道一个网页按钮的ID和类之后 怎么模拟出点击和选择的功能
整体思路
模拟鼠标点击
获取坐标
OK请推荐
import
java.awt.*;
import
java.awt.event.*;
import
javax.swing.*;
public
class
TestFrame
extends
JFrame
{
private
JButton
btn1
=
new
JButton("Button
1");
private
JButton
btn2
=
new
JButton("Button
2");
private
Robot
robot;
public
TestFrame()
{
setLayout(new
GridLayout(0,
1));
add(btn1);
add(btn2);
btn1.addMouseListener(new
MouseAdapter()
{
public
void
mouseClicked(MouseEvent
event)
{
if
(event.getButton()
==
MouseEvent.BUTTON1)
System.out.println(btn1.getText()
+
"鼠标左键点击");
if
(event.getButton()
==
MouseEvent.BUTTON3)
System.out.println(btn1.getText()
+
"鼠标右键点击");
}
});
btn2.addMouseListener(new
MouseAdapter()
{
public
void
mouseClicked(MouseEvent
event)
{
if
(event.getButton()
==
MouseEvent.BUTTON1)
System.out.println(btn2.getText()
+
"鼠标左键点击");
if
(event.getButton()
==
MouseEvent.BUTTON3)
System.out.println(btn2.getText()
+
"鼠标右键点击");
}
});
addMouseMotionListener(new
MouseMotionAdapter()
{
public
void
mouseMoved(MouseEvent
event)
{
}
});
}
public
void
simulationClick()
throws
AWTException
{
//模拟鼠标点击代码
Point
p1
=
btn1.getLocation();
Point
p2
=
btn2.getLocation();
System.out.println(p1.x
+
","
+
p1.y);
System.out.println(p2.x
+
","
+
p2.y);
Point
p
=
MouseInfo.getPointerInfo().getLocation();
int
x
=
p.x;
int
y
=
p.y;
robot
=
new
Robot();
System.out.println(x
+
","
+
y);
robot.mouseMove(p1.x
+
10,
p2.y
+
10);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
robot.mouseMove(x,
y);
}
public
static
void
main(String[]
args)
{
EventQueue.invokeLater(new
Runnable()
{
public
void
run()
{
TestFrame
frame
=
new
TestFrame();
frame.pack();
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
try
{
frame.simulationClick();
}
catch
(AWTException
e)
{
e.printStackTrace();
}
}
});
}
}
java程序中如何实现单击页面a中的按钮跳转到页面b
java程序中的jsp页面点击按钮跳转到页面b的方式如下:
1.jsp页面的方式如下:a href="....b.jsp"跳转/a
response.sendRedirect("b.jsp")
jsp:forward page="b.jsp"/
2.在swing里,给button加一个监听器,然后在监听事件中打开另一个页面。
在jsp或是静态网页里,onclick=“JavaScript:window.location=’xx‘”
关于java网页按钮和javaweb按钮的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。