sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #25725
Re: [Question #248226]: enum java
Question #248226 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/248226
Jeremy gave more information on the question:
I made a completely separate program to test out. Here it what I have:
file 1
package com.main.Listener;
public interface SpecialListener {
public void runSpecialProgramming();
}
file 2
package com.main;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JPanel;
import com.main.Listener.SpecialListener;
public class MainView extends JPanel implements ActionListener {
private JButton m_special = new JButton("Special Program");
private SpecialListener m_speciallistener;
public MainView()
{
setLayout(new GridLayout(1,1));
m_special.addActionListener(this);
this.add(m_special);
}
public void setSpecialListener(SpecialListener _listener)
{
this.m_speciallistener = _listener;
}
public void actionPerformed(ActionEvent arg0) {
if (m_speciallistener != null)
m_speciallistener.runSpecialProgramming();
}
}
file 3:
package com.main;
import java.awt.FlowLayout;
import javax.swing.JFrame;
import org.sikuli.script.FindFailed;
import org.sikuli.script.Screen;
import com.main.Controller.MainController;
import com.main.Listener.SpecialListener;
public class MainProgram extends JFrame{
MainView m_mainview = new MainView();
MainController m_controller = new MainController();
public MainProgram(){
setLayout(new FlowLayout());
add(m_mainview);
pack();
m_mainview.setSpecialListener(new SpecialListener()
{
public void runSpecialProgramming() {
//m_controller.runSpecialCoding();
// if (TestFailed()){
Screen s = new Screen();
try {
s.click(images.Android_Home);
} catch (FindFailed e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// }
}
private boolean TestFailed() {
Screen s = new Screen();
try {
s.click(images.Android_Home);
} catch (FindFailed e) {
System.out.println("try failed");
return false;
}
return true;
}
});
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
public enum images{
Android_Home {
public String toString() {
return "..\\..\\" + "Images\\Android_Home.png";
}
};
private images(){
}
}
}
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.