java实现屏幕录制代码 如何实现屏幕录制
怎么用java编写如下程序在屏幕上输出如下图形 * *** ***** ******* ***** *** * 循环语句做(if语句)
这个图形对吧?
创新互联专注于企业全网整合营销推广、网站重做改版、西秀网站定制设计、自适应品牌网站建设、HTML5、商城网站建设、集团公司官网建设、外贸营销网站建设、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为西秀等各大城市提供网站开发制作服务。
*
***
*****
*******
*****
***
*
你确定不是 for/while/do-while loop?if 不是循环语句吧
用for loop做的:
public class NestedLoop{
public static void main (String[] args){
for (int i=0; i7; i++){
if (i %2 == 0){
for (int s=0; s(7-i-1)/2; s++){
System.out.print(" ");
}
for (int d=0; di +1; d++){
System.out.print("*");
}
System.out.println();
}
}
for (int i=5; i-1; i--){
if (i %2 == 0){
for (int s=0; s(7-i-1)/2; s++){
System.out.print(" ");
}
for (int d=0; di+1; d++){
System.out.print("*");
}
System.out.println();
}
}
}
}
给点分呗?我时差党,大半夜12点多跟这给你做题~ ^ ^
java如何实现屏幕录制功能?
这种功能一本不用JAVA写,因为他要和系统的本地资源打交道。
你可以使用VC、VB、delphi这类原生开发工具做。
也可以使用C#来写。
能用java代码打开一个应用程序吗?
可以,java功能可是相当强大的。
这个是调用应用程序的代码:
Runtime ec;
ec=Runtime.getRuntime();
ec.exec("这里是应用程序的路径或者命令");
比如:ec.exec("c:\\123.exe");
利用java编写代码实现如下功能,需要全部代码
很简单的应用,为了节省字数,代码注释我就不加了
首先是显示层,LoinWindow:
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
public class LoinWindow extends JFrame implements ActionListener, FocusListener {
private JPanel mainPanel, namePanel, btnPanel;
private JTextField tfName, tfPsd;
private JButton btnLogin, btnCancel;
private static final int WIDTH = 300;
private static final int HEIGHT = 200;
private LoginService service = new LoginService();
public LoinWindow() {
super("登录窗体");
}
public void launch() {
setSize(WIDTH, HEIGHT);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
GridLayout mainLayout = new GridLayout(2, 1);
mainLayout.setVgap(10);
mainPanel = new JPanel(mainLayout);
GridBagLayout nameLayout = new GridBagLayout();
namePanel = new JPanel(nameLayout);
namePanel.setBorder(new EmptyBorder(10, 10, 10, 10));
JLabel nameLabel = new JLabel("姓名:");
tfName = new JTextField();
JLabel psdLabel = new JLabel("密码:");
tfPsd = new JTextField();
JLabel blank = new JLabel(" ");
namePanel.add(nameLabel);
namePanel.add(tfName);
namePanel.add(blank);
namePanel.add(psdLabel);
namePanel.add(tfPsd);
GridBagConstraints s = new GridBagConstraints();
s.fill = GridBagConstraints.BOTH;
s.gridwidth = 1;
s.weightx = 0;
s.weighty = 0;
nameLayout.setConstraints(nameLabel, s);
s.gridwidth = 0;
s.weightx = 1;
s.weighty = 0;
nameLayout.setConstraints(tfName, s);
s.gridwidth = 0;
s.weightx = 4;
s.weighty = 0;
nameLayout.setConstraints(blank, s);
s.gridwidth = 1;
s.weightx = 0;
s.weighty = 0;
nameLayout.setConstraints(psdLabel, s);
s.gridwidth = 3;
s.weightx = 1;
s.weighty = 0;
nameLayout.setConstraints(tfPsd, s);
FlowLayout btnLayout = new FlowLayout();
btnLayout.setAlignment(FlowLayout.CENTER);
btnPanel = new JPanel(btnLayout);
btnLogin = new JButton("确定");
btnCancel = new JButton("取消");
btnPanel.add(btnLogin);
btnPanel.add(btnCancel);
btnCancel.addActionListener(this);
btnLogin.addActionListener(this);
mainPanel.add(namePanel);
mainPanel.add(btnPanel);
setContentPane(mainPanel);
tfName.addFocusListener(this);
tfPsd.addFocusListener(this);
pack();
setSize(WIDTH, HEIGHT);
setLocationRelativeTo(null);
}
@Override
public void actionPerformed(ActionEvent e) {
Object source = e.getSource();
if(source == btnCancel) {
System.exit(0);
} else if(source == btnLogin) {
String username = tfName.getText();
String password = tfPsd.getText();
boolean success = service.login(username, password);
if(success) {
warn("成功", "登录成功!");
} else {
warn("失败", "您输入的用户名或密码错误 !");
}
}
}
@Override
public void focusGained(FocusEvent arg0) {
}
@Override
public void focusLost(FocusEvent e) {
Object source = e.getSource();
if(source == tfName) {
String username = tfName.getText();
try {
service.matchUsername(username);
} catch (LoginException e1) {
warn("验证错误", e1.getMessage());
}
} else if(source == tfPsd) {
String password = tfPsd.getText();
try {
service.matchPassword(password);
} catch (LoginException e1) {
warn("验证错误", e1.getMessage());
}
}
}
private void warn(String title, String msg) {
JOptionPane.showMessageDialog(null, msg, title, JOptionPane.INFORMATION_MESSAGE);
}
public static void main(String[] args) {
new LoinWindow().launch();
}
}
然后是模型层:LoginDao
public class LoginDao {
public boolean login(String username, String password) {
if(username.equals("admin") password.equals("12345")) {
return true;
}
return false;
}
}
LoginService
import java.util.regex.Pattern;
public class LoginService {
private static final Pattern LOGIN_PATTERN = Pattern.compile("[a-zA-Z]+");
private static final Pattern PASSWORD_PATTERN = Pattern.compile("[1-9]+");
private LoginDao dao = new LoginDao();
public boolean matchUsername(String username) throws LoginException {
if(null == username || username.isEmpty()) {
return false;
}
if(!LOGIN_PATTERN.matcher(username).matches()) {
throw new LoginException("您输入的用户名不合法,请输入英文!");
}
return true;
}
public boolean matchPassword(String password) throws LoginException {
if(null == password || password.isEmpty()) {
return false;
}
if(!PASSWORD_PATTERN.matcher(password).matches()) {
throw new LoginException("您输入的密码不合法,请输入数字!");
}
return true;
}
public boolean login(String username, String password) {
if(null == username || username.isEmpty()) {
return false;
}
if(null == password || password.isEmpty()) {
return false;
}
if(!dao.login(username, password)) {
return false;
}
return true;
}
}
LoginException
public class LoginException extends Exception {
public LoginException(String arg0) {
super(arg0);
}
}
不知道分层设计思想是不是我想的这样
用java实现录像机功能
底层的我不会,不知调用那个工具包,看楼下的啦. 楼下的,好象可以通过虚拟机调用win32 API的啦,楼下去翻翻资料.
网页题目:java实现屏幕录制代码 如何实现屏幕录制
网站路径:http://scyanting.com/article/hpsgid.html