ui的java代码 ui java

ligerui使用loadData动态加载树节点时,struts2的java代码怎么写

方法很简单。插件中是将数据写死在js里面的。只要是这个格式即可。所以在你从后台把数据从数据库读取出来后。按照tree需要的这个格式,把数据拼接成这个格式。通过ajax传回前台再调用绑定方法即可。

苏尼特右网站制作公司哪家好,找成都创新互联公司!从网页设计、网站建设、微信开发、APP开发、响应式网站等网站项目制作,到程序开发,运营维护。成都创新互联公司于2013年创立到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选成都创新互联公司

读取数据-组成需要的格式-传到前台js中-再执行tree的绑定方法调用即可。

如何在另一个类中调用已经写好的UiAutomator Java代码中的方法

如果你使用Eclipse可以直接new UiAutomator对象,例如Uiautomator ui = new Uiautomator(),调用方法几时ui.方法名。

调用其他类的方法名一般是新建对象,然后通过对象加“.”调用方法。如果是静态方法就直接类名.方法

java的UI程序 简单 排错

问题出在KeyEvent上。请注意你的MAIN类的名字叫KeyEvent,而MyKeyMonitor类重写的方法keyPressed的入参的类型也是KeyEvent(这个KeyEvent应该是java.awt.event包下的),也就是说,当你的MAIN类和MyKeyMonitor在同一包内时,当触发keyPressed事件时,JAVA会自动去生成你MAIN类的实体,不会去生成java.awt.event包下的正确的KeyEvent实体,所以,你的程序才不能正确的捕获产生的键盘事件。

解决的方法有两个,一个是改变你MAIN类的名字,二是指明MyKeyMonitor类keyPressed方法入参的明确包,即写成public void keyPressed(java.awt.event.KeyEvent e) {

Java代码运行器

import java awt BorderLayout;

import java awt Color;

import java awt EventQueue;

import java awt event ActionEvent;

import java awt event ActionListener;

import java io BufferedReader;

import java io BufferedWriter;

import java io File;

import java io FileInputStream;

import java io FileOutputStream;

import java io InputStreamReader;

import java io OutputStreamWriter;

import javax swing JButton;

import javax swing JColorChooser;

import javax swing JFileChooser;

import javax swing JFrame;

import javax swing JLabel;

import javax swing JMenu;

import javax swing JMenuBar;

import javax swing JMenuItem;

import javax swing JOptionPane;

import javax swing JPanel;

import javax swing JScrollPane;

import javax swing JTextArea;

import javax swing JTextField;

import javax swing JTextPane;

import javax swing SwingUtilities;

import javax swing UIManager;

import javax swing border EtchedBorder;

import javax swing text BadLocationException;

import javax swing text Document;

import javax swing text SimpleAttributeSet;

import javax swing text StyleConstants;

import javax swing text StyledEditorKit;

public class RunJava extends JFrame {

private JTextField textField_ ;

private JTextField textField;

private String url = System getProperty( user dir ) + \\ ;

private JTextPane textArea_ ;

private JTextArea textArea;

private static String cmd = first ;

private static Process pro = null;

private Thread InPutThread = null;

private Thread OutPutThread = null;

private Thread ErrorThread = null;

private JMenu File Edit;

private JMenuBar Part;

private JMenuItem Open InsertMain SaveAs Save Exit MarkColor;

private File file;

private String [] Keyword = { abstract default if private this boolean do implements protected throw break double import public throws byte else instanceof return transient case extends int short try catch final interface static void char finally long strictfp volatile class float native super while const for new switch continue goto package synchronized };

public static void main(String args[]) {

EventQueue invokeLater(new Runnable() {

public void run() {

try {

RunJava frame = new RunJava();

frame setVisible(true);

} catch (Exception e) {

e printStackTrace();

}

}

});

}

public RunJava() throws Exception {

super( Java代码运行器 );

File = new JMenu( 文件 );

Part = new JMenuBar();

Edit = new JMenu( 编辑 );

Part add(File);

Part add(Edit);

Open = new JMenuItem( 打开 );

Open addActionListener(new ActionListener() {

public void actionPerformed(final ActionEvent arg ) {

JFileChooser fileChooser = new JFileChooser(); // 实例化文件选择器

fileChooser setFileSelectionMode(JFileChooser FILES_AND_DIRECTORIES); // 设置文件选择模式 此处为文件和目录均可

if (fileChooser showOpenDialog(RunJava this) == JFileChooser APPROVE_OPTION) { // 弹出文件选择器 并判断是否点击了打开按钮

String fileName = fileChooser getSelectedFile() getAbsolutePath(); // 得到选择文件或目录的绝对路径

System out println(fileName);

file = new File(fileName);

InputData();

}

}

});

Save = new JMenuItem( 保存 );

Save addActionListener(new ActionListener() {

public void actionPerformed(final ActionEvent arg ) {

if(file==null){

JFileChooser fileChooser = new JFileChooser(); // 实例化文件选择器

fileChooser setFileSelectionMode(JFileChooser FILES_AND_DIRECTORIES); // 设置文件选择模式 此处为文件和目录均可

if (fileChooser showSaveDialog(RunJava this) == JFileChooser APPROVE_OPTION) { // 弹出文件选择器 并判断是否点击了打开按钮

String fileName = fileChooser getSelectedFile() getAbsolutePath(); // 得到选择文件或目录的绝对路径

System out println(fileName);

file = new File(fileName);

OutputData();

}

}else{

OutputData();

}

}

});

SaveAs = new JMenuItem( 另存为 );

SaveAs addActionListener(new ActionListener() {

public void actionPerformed(final ActionEvent arg ) {

JFileChooser fileChooser = new JFileChooser(); // 实例化文件选择器

fileChooser setFileSelectionMode(JFileChooser FILES_AND_DIRECTORIES); // 设置文件选择模式 此处为文件和目录均可

if (fileChooser showSaveDialog(RunJava this) == JFileChooser APPROVE_OPTION) { // 弹出文件选择器 并判断是否点击了打开按钮

String fileName = fileChooser getSelectedFile() getAbsolutePath(); // 得到选择文件或目录的绝对路径

file = new File(fileName);

OutputData();

}

}

});

Exit = new JMenuItem( 退出 );

Exit addActionListener(new ActionListener() {

public void actionPerformed(final ActionEvent arg ) {

int j=JOptionPane showConfirmDialog(RunJava this 真的要退出吗? 退出 JOptionPane YES_OPTION JOptionPane QUESTION_MESSAGE);

if (j == JOptionPane YES_OPTION){

System exit( );

}

}

});

File add(Open);

File add(Save);

File add(SaveAs);

File add(Exit);

InsertMain = new JMenuItem( 新建 );

InsertMain addActionListener(new ActionListener() {

public void actionPerformed(final ActionEvent arg ) {

String str = public class test {\n

+    public static void main(String[] args) {\n

+     System out println(\ hello java\ );\n

+    }\n + } ;

textArea_ setText(str);

textField setText(getName(textArea_ getText()));

}

});

MarkColor = new JMenuItem( 标注颜色 );

MarkColor addActionListener(new ActionListener() {

public void actionPerformed(final ActionEvent e) {

String str = public class test {\n

+    public static void main(String[] args) {\n

+     System out println(\ hello java\ );\n

+    }\n + } ;

int a = str indexOf( class );

//     System out println(a);

setDocs(str substring(a a+ ) Color RED true );

}

});

Edit add(InsertMain);

Edit add(MarkColor);

setJMenuBar(Part);

getContentPane() setLayout(null);

setBounds( );

setDefaultCloseOperation(JFrame EXIT_ON_CLOSE);

final JPanel panel = new JPanel();

panel setLayout(new BorderLayout());

panel setBounds( );

getContentPane() add(panel);

textArea_ = new JTextPane();

panel add(new JScrollPane(textArea_ ) BorderLayout CENTER);

final JPanel panel_ = new JPanel();

panel_ setLayout(new BorderLayout());

panel_ setBorder(new EtchedBorder(EtchedBorder LOWERED));

panel_ setForeground(Color BLUE);

panel_ setBounds( );

getContentPane() add(panel_ );

textArea = new JTextArea();

panel_ add(new JScrollPane(textArea) BorderLayout CENTER);

try {

UIManager setLookAndFeel( sun java swing plaf nimbus NimbusLookAndFeel );

} catch (Exception ex ) {

try {

UIManager setLookAndFeel( sun java swing plaf windows WindowsClassicLookAndFeel );

} catch (Exception ex ) {

UIManager setLookAndFeel( sun java swing plaf windows WindowsLookAndFeel );

}

}

SwingUtilities updateComponentTreeUI(this);

textField = new JTextField();

textField setToolTipText( 不填自动从Java代码中提取类名 );

textField setBounds( );

getContentPane() add(textField);

final JLabel label = new JLabel();

label setText( 类名: );

label setBounds( );

getContentPane() add(label);

setResizable(false);// 屏蔽最大化按钮

textField_ = new JTextField();

textField_ setBounds( );

textField_ setToolTipText( 可以和Java交互信息 );

getContentPane() add(textField_ );

final JButton button_ = new JButton();

button_ addActionListener(new ActionListener() {

public void actionPerformed(final ActionEvent arg ) {

cmd = textField_ getText();

}

});

button_ setText( CMD命令发送 );

button_ setBounds( );

getContentPane() add(button_ );

final JButton button_ = new JButton();

button_ addActionListener(new ActionListener() {

public void actionPerformed(final ActionEvent arg ) {

String name = textField getText();

if (name trim() length() == ) {

textField setText(getName(textArea_ getText()));

}

FileOut(textField getText() + java textArea_ getText());

File file = new File(url + textField getText() + class );

if (file exists()) {

file delete();

}

String exe = cmd ;

try {

pro = Runtime getRuntime() exec(exe);

if (InPutThread != null)InPutThread stop();

if (OutPutThread != null)InPutThread stop();

if (ErrorThread != null)InPutThread stop();

InPutThread = new Thread(new RunTimeInput());

OutPutThread = new Thread(new RunTimeOutput(new InputStreamReader(pro getInputStream())));

ErrorThread = new Thread(new RunTimeOutput(new InputStreamReader(pro getErrorStream())));

InPutThread start();

OutPutThread start();

ErrorThread start();

exec( javac + textField getText() + java );

Thread sleep( );

exec( java + textField getText() + );

} catch (Exception e) {

e printStackTrace();

}

}

});

button_ setText( 编译/运行 );

button_ setBounds( );

getContentPane() add(button_ );

}

public void FileOut(String name String Content) {

File file = new File(url + name);

if (file exists())

file delete();

try {

file createNewFile();

FileOutputStream out = new FileOutputStream(file);

byte buf[] = Content getBytes();

out write(buf);

out flush();

out close();

} catch (Exception ex) {

ex printStackTrace();

}

}

public class RunTimeInput implements Runnable {

private BufferedWriter bw = null;

public void run() {

bw = new BufferedWriter(new OutputStreamWriter(pro getOutputStream()));

while (true) {

try {

if (cmd != null cmd length() ) {

bw write(cmd + \n\n );

bw flush();

cmd = null;

}

Thread sleep( );

} catch (Exception e) {

e printStackTrace();

}

}

}

}

public class RunTimeOutput implements Runnable {

InputStreamReader isr = null;

public RunTimeOutput(InputStreamReader is) {

isr = is;

}

private BufferedReader br = null;

public void run() {

br = new BufferedReader(isr);

while (true) {

try {

String s = br readLine();

if (s != null) {

textArea setText(textArea getText() + \n + s);

textArea setSelectionStart(textArea getText() length());

}

Thread sleep( );

} catch (Exception e) {

e printStackTrace();

}

}

}

}

public void exec(String Content) {

cmd = Content;

}

public String getName(String str) {

String name = ;

if (str indexOf( class ) != ) {

String[] s = str split( \\s+ );

for (int i = ; i s length; i++) {

if (s[i] equals( class )) {

if ((i + ) s length)

name = s[i + ];

int a = ;

if((a=name indexOf( { ))!= ){

name= name substring( a);

}

}

}

}

return name;

}

public void OutputData() {

try {

FileOutputStream out = new FileOutputStream(file);

byte buf[] = textArea_ getText() getBytes();

out write(buf);

out flush();

out close();

} catch (Exception e) {

e printStackTrace();

}

}

public void InputData() {

try {

FileInputStream in = new FileInputStream(file);

int a = (int)file length();

byte buf[] = new byte[a];

int len = in read(buf);

if (len == ){

System out println( 文件为空 );

}else{

textArea_ setText(new String(buf len));

}

} catch (Exception e) {

e printStackTrace();

}

}

/**

* @param str 内容

* @param col 颜色

* @param bold 是否粗体

* @param fontSize 字体大小

*/

public void setDocs(String str Color col boolean bold int fontSize) {

SimpleAttributeSet attrSet = new SimpleAttributeSet();

StyleConstants setForeground(attrSet col);

// 颜色

if (bold == true) {

StyleConstants setBold(attrSet true);

}// 字体类型

StyleConstants setFontSize(attrSet fontSize);

// 字体大小

Document doc = textArea_ getDocument();

try {

doc insertString(doc getLength() str attrSet);

} catch (BadLocationException e) {

System out println( BadLocationException: + e);

}

}

}

lishixinzhi/Article/program/Java/hx/201311/26653


当前题目:ui的java代码 ui java
新闻来源:http://ybzwz.com/article/ddspjse.html