Button to launch another java file????

Hi there,
Was wondering if someone could help with the following:
I have a button, which once clicked opens another java file, and am aving some difficulty in doing this.
The file which has the button is:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;
import java.util.*;
class JFrameHolidayPlannerGUI extends JFrame
     //declare the variable using in here
     private JButton exit;
     private JButton clear;
     private JTextField t;
     private JLabel employeeId;
     private JTextField t2;
     private JLabel days;
     private JButton find;
     private JMenuItem close;
     private JMenu file;
     private JMenuBar menubar;
     private JButton add;
     private JPanel panel1;
          public JFrameHolidayPlannerGUI()
          //Set the title of the frame
          super("Company Holiday Tracking System");
          this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          Container contentPane = this.getContentPane();
          //Created a pane with four panels and null columns
          contentPane.setLayout(new GridLayout(4,0));
          JMenuBar menubar = new JMenuBar();
          setJMenuBar(menubar);
          JMenu file = new JMenu("file");
          JMenuItem open = new JMenuItem ("Open...");
          JMenuItem save = new JMenuItem("Save");
          JMenuItem close = new JMenuItem ("Close");
          JMenuItem print = new JMenuItem ("Print...");
          menubar.add(file);
          file.add(open);
          file.add(print);
          file.add(close);
          file.add(save);
          close.addActionListener(
               new ActionListener()
                    public void actionPerformed(ActionEvent e)// Define the action to take after user enters the name
                         //if (e.getSource() == exit)
                         System.exit(0);
          JPanel panel = new JPanel();
          panel.setLayout(new FlowLayout(FlowLayout.LEFT));
          contentPane.add(panel);
          JLabel employeeId = new JLabel("Please Enter the employeeId", JLabel.CENTER);
          final JTextField t = new JTextField(15);
          t.setToolTipText("Please Enter the employeeId");
          t.setEditable(true);
          t.setText("Enter employeeId in here");
          JButton find = new JButton("Search for a Record");
          find.setToolTipText("Click to search for an employee record");
          find.addActionListener(
               new ActionListener()
                    public void actionPerformed (ActionEvent e)
                         System.out.println("time");
          panel.add(employeeId);
          panel.add(t);
          panel.add(find);
          contentPane.add(panel);
          JPanel p2 = new JPanel();
          p2.setLayout(new FlowLayout(FlowLayout.LEFT));
          contentPane.add(p2);
          days = new JLabel("How many days would you like?", JLabel.LEFT);
          final JTextField t2 = new JTextField(15);
          t2.setToolTipText("How manys days would you like?");
          t2.setEditable(true);
          t2.setText("Enter the numbers of days in here");
          JButton submit = new JButton ("SUBMIT");
          find.setToolTipText("Press enter to submit holiday request");
          submit.addActionListener(
               new ActionListener()
                    public void actionPerformed(ActionEvent e)
                         JFrame = new JFrame();
                         frame.addWindowListener(new WindowAdapter() {
                                   public void windowClosing(WindowEvent e) {
                                        System.open();
          p2.add(days);
          p2.add(t2);
          p2.add(submit);
          contentPane.add(p2);
          JPanel panel1 = new JPanel();
          panel1.setLayout(new FlowLayout(FlowLayout.LEFT));
          contentPane.add(panel1);
          JButton save1 = new JButton("Save");
          save1.setToolTipText("Click to save");
          panel1.add(save1);
          exit = new JButton("Exit");
          exit.setToolTipText("Click to exit");
          panel1.add(exit);
          exit.addActionListener(
               new ActionListener()
                    public void actionPerformed(ActionEvent e)// Define the action to take after user enters the name
                         //if (e.getSource() == exit)
                         System.exit(0);
          JButton clear = new JButton("Clear");
          clear.setToolTipText("Click to clear the information");
          panel1.add(clear);
          clear.addActionListener(
               new ActionListener()
                    public void actionPerformed(ActionEvent e)// Define the action to take after user enters the name
                         t2.setText(" ");
                         t.setText(" ");
          add = new JButton("Add");
          add.setToolTipText("Click to add an employee");
          panel1.add(add);
          this.pack();
          this.setVisible(true);
     public static void main(String[] arg)
          JFrameHolidayPlannerGUI jf = new JFrameHolidayPlannerGUI();
and the file that needs to be opened is:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;
import java.util.*;
class JFrameSubmitValidate extends JFrame
     private static String label = "Are you sure you want to Submit?";
          public JFrameSubmitValidate()
               //Set the title of the frame
               super("Vaidator");
               this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
               Container contentPane = this.getContentPane();
               //Created a pane with four panels and null columns
               contentPane.setLayout(new GridLayout(2,0));
               JLabel validate = new JLabel(label);
               JButton OK = new JButton("OK");
               JPanel panel = new JPanel();
               contentPane.add(validate);
               contentPane.add(OK);
               this.pack();
               this.setVisible(true);
          public static void main(String[] arg)
               JFrameSubmitValidate sv = new JFrameSubmitValidate();
thanx for your time.
kev.

Similarly to this above discussion, I would like to know how to launch another java file by clicking a button "submit". Can you guys guide me based on the code i have shown below..?
import java.awt.*;
import java.awt.event.*;
class MenuFrame extends Frame implements ActionListener
Label login=new Label("Login ID :",Label.CENTER);
TextField lname=new TextField(12);
Label pass=new Label("Password :",Label.CENTER);
TextField lpass=new TextField(10);
Button submit=new Button("Submit");
public MenuFrame(String title)
super(title);
setLayout(new FlowLayout());
add(login);
add(lname);
add(pass);
add(lpass);
add(submit);
submit.addActionListener(this);
addWindowListener(new CloseWindow());
public void actionPerformed(ActionEvent e)
Object source=e.getSource();
if(source == submit)
lname.setText("w");
lpass.setText("w");
repaint();
public static void main(String args[])
MenuFrame m=new MenuFrame("Java Chat Application");
m.setSize(200,200);
m.show();
class CloseWindow extends WindowAdapter{
public void windowClosing(WindowEvent event){
System.exit(0);

Similar Messages

  • How to invoke another Java file in Java program?

    Hello all,
    Now I am building a commnity of agents that can talk in Java, I have another Java-Based dialogue system to handle the dialogue between the agents. But I don'y know how to invoke the Java dialogue system file in the agent class.
    Is there any methods can call another .java file in a Java program?
    Help!!!!!please

    Yep, vaguest of the vaguey vague vague.
    Anyhoo,
    I'm guessing you want to call a method from a different class?
    Assuming you have the "Runner" class and then "Agent1", "Agent2", etc.
    Agent1 whatever = new Agent1();

  • Trying to compile a .java file from another .java file

    Hello,
    I'm trying to compile a .java file from another .java file using Runtime.exec...
    String c[]=new String[3];
    c[0]="cmd.exe"; c[1]="/c" ; c[2]="javac Hello.java";
    Process p=Runtime.exec(c);
    If anyone can help me in atleast getting the command prompt when Runtime.exec("cmd.exe") is executed...that would be great...I tried out notepad.exe, calc, explorer instead of cmd.exe...all the commands display their respective windows..except cmd.exe...the command prompt doesnt appear...
    Please help me ASAP....
    Thanks for your help in advance...
    Regards.
    AKhila.

    try this. ur code will be compliled and will get .class file. but console won't appear. is it a must for u?
    public class Exec{
         public static void main(String a[]) throws Exception{
              String c[]=new String[3];
              c[0]="cmd.exe"; c[1]="/c" ; c[2]="javac Hello.java";
              Process p=Runtime.getRuntime().exec(c);
              // or Runtime.getRuntime().exec("javac Hello.java");

  • How can i launch another java application using Runtime class?

    I created a java process which invokes another java application called Launch as shown below,
    Process p=Runtime.getRuntime().exec("java -classpath=C:\\Program Files\\bin\\nettools\\ui\\updates Launch");
    But it is not working...can any one help me on this?
    Edited by: deepakchandaran on Sep 20, 2007 7:10 AM

    You could search the forum and Google.
    it has been answered before.
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

  • Button to launch another application

    what is js for launching another applicatoin?

    I found this:
    To add  script to open a user-specified PDF file
    Add the following script to the Open  button:
    app.openDoc(FilePath.rawValue);
    In the help section under "Opening an application from a form". This
    wouldn't seem to fit what you want for 2 reasons.
    1. The example requires the user to input the path of the file into
    a text field
    2. It doesn't work. I get a js error saying that security settings
    prevent access to that method
    If you can get around the security settings and the path to the
    application is a known quantity for your prospective users, I would
    think you could hard code in the path on the click event. The problem
    is getting around the security settings.
    addendum:
    I'm able to get another Adobe pdf to open with this script but so far
    nothing else.

  • Calling a method from another Java file.

    I think I'm doing this right, but I'm obviously going wrong somewhere.
    In order to not have one big long java file, I've created one main one to execute the program, and another to do some of the functions. I'm using eclipse, btw.
    In the main file, I have
    currentTB = getActiveTB(playerArea);If it works, it should get send the player area variable to the getActiveTB method, and store the value it returns in the currentTB variable, right?
    In the other file, I have;
    package scenes;
    public class sceneIndex {
         private TerrainBlock getActiveTB(String areaCode) {
              TerrainBlock tBlock = new TerrainBlock();
                     **DOES STUFF**
              return tBlock;
    }I have it set up so the second file is in the source folder "resources" and the package "scenes." The problem is I'm not calling it properly. I'm missing something simple, I think. The only error I'm getting is;
    The method getActiveTB(String) is undefined...
    Where am I screwing up?
    EDIT: Yeah, I'm a rookie here trying to figure it out on my own. My computer science courses, so far, conveniently all consist of just one big java file. Easier to write, sure, but not very efficient/organized.
    Message was edited by:
    SuckerPunch

    Yeah, so this is still pissing me off. I'm not sure what else to do. I've tried this a million different ways, in both eclipse and netbeans. Whatever. Here's the code, I'd love it if someone could point out the boneheaded mistake I'm making. I'm getting a little frustrated at being stuck on such a simple problem.
    Main.javaimport com.jme.app.BaseGame;
    import com.jme.input.KeyBindingManager;
    import com.jme.input.KeyInput;
    import com.jme.math.Vector3f;
    import com.jme.renderer.Camera;
    import com.jme.renderer.ColorRGBA;
    import com.jme.scene.Node;
    import com.jme.system.DisplaySystem;
    import com.jme.system.JmeException;
    import com.jme.util.Timer;
    import com.jmex.terrain.TerrainBlock;
    import resources.*;
    public class Main extends BaseGame {
         /* General Variable Declaration */
         private String scene;   // Tells application which scene to load, default loads default scene
         private int width, height, depth, freq; // Creates variables to store information
         private boolean fullscreen;             // on the user's window
         private Camera playerCam; // Defines the main camera for the player, first person view
         private Timer timer; // Creates a timer to be used for FPS calculations
         private Node currentScene; // The basis for building the scene the player is in
         private TerrainBlock currentTB; // This variable holds the current landscape
         private String playerArea = new String("initial"); // Contains the string
                                                                        // code for the scene
                                                                        // the player is in,
                                                                        // defaults to the opening scene, unless changed by
                                                                        // the player loading their game
            public static void main(String[] args) {
              /* Initializes and Starts the Applications. */
              Main app = new Main();
              app.setDialogBehaviour(ALWAYS_SHOW_PROPS_DIALOG, Main.class.getClassLoader().getResource("img/spunch.jpg"));
              app.start();
         protected void update(float interpolation) {
         protected void render(float interpolation) {
         protected void initSystem() {
               * Application initialization properties (window, camera, renderer, key
               * bindings, etc)
              // Stores variables for window properties
              width = properties.getWidth();
              height = properties.getHeight();
              depth = properties.getDepth();
              freq = properties.getFreq();
              fullscreen = properties.getFullscreen();
              // Assigns renderer and creates game window
              try {
                   display = DisplaySystem.getDisplaySystem(properties.getRenderer());
                   display.createWindow(width, height, depth, freq, fullscreen);
                   playerCam = display.getRenderer().createCamera(width, height);
              } catch (JmeException e) {
                   e.printStackTrace();
                   System.exit(1);
              // Sets background to black, should never be seen anyway
              display.getRenderer().setBackgroundColor(ColorRGBA.black);
              // Initializes the camera
              playerCam.setFrustumPerspective(45.0f, (float) width / (float) height,
                        1, 1000);
              Vector3f loc = new Vector3f(250.0f, 100.0f, 250.0f);
              Vector3f left = new Vector3f(-0.5f, 0.0f, 0.5f);
              Vector3f up = new Vector3f(0.0f, 1.0f, 0.0f);
              Vector3f dir = new Vector3f(-0.5f, 0.0f, -0.5f);
              // Moves and orients the camera
              playerCam.setFrame(loc, left, up, dir);
              // Update the camera since it has been changed
              playerCam.update();
              // Create a timer for FPS updates
              timer = Timer.getTimer();
              // Assign the camera as the primary display in the application
              display.getRenderer().setCamera(playerCam);
              // Initialize the escape key as a way to exit the program
              KeyBindingManager.getKeyBindingManager().set("exit",
                        KeyInput.KEY_ESCAPE);
         protected void initGame() {
              /* Game initialization */
              display.setTitle("Slumlords"); // Displays title in window
                    SceneIndex sIndex = new SceneIndex();
              currentTB = sIndex.getActiveTB(playerArea);
              currentScene.attachChild(currentTB);
              currentScene.updateGeometricState(0.0f, true);
              currentScene.updateRenderState();
         protected void reinit() {
         protected void cleanup() {
    }SceneIndex.javapackage resources;
    import javax.swing.ImageIcon;
    import com.jme.bounding.BoundingBox;
    import com.jme.image.Texture;
    import com.jme.math.Vector3f;
    import com.jme.scene.state.TextureState;
    import com.jme.system.DisplaySystem;
    import com.jme.util.TextureManager;
    import com.jmex.terrain.TerrainBlock;
    import com.jmex.terrain.util.MidPointHeightMap;
    import com.jmex.terrain.util.ProceduralTextureGenerator;
    public class SceneIndex {
         private DisplaySystem display;
         public TerrainBlock getActiveTB(String areaCode) {
              TerrainBlock tBlock = new TerrainBlock();
              if (areaCode == "initial") {
                   // Generates random terrain data
                   MidPointHeightMap heightMap = new MidPointHeightMap (64, 1.0f);
                   // Scale the data
                   Vector3f terrainScale = new Vector3f(4, 0.0575f, 4);
                   // Create the terrain block
                   tBlock = new TerrainBlock("Terrain", heightMap.getSize(), terrainScale, heightMap.getHeightMap(), new Vector3f(0, 0, 0), false);
                   tBlock.setModelBound(new BoundingBox());
                   tBlock.updateModelBound();
                   // Creating a blended texture based on the height map
                   ProceduralTextureGenerator pTexture = new ProceduralTextureGenerator(heightMap);
                   pTexture.addTexture(new ImageIcon(SceneIndex.class.getClassLoader().getResource("img/grass.gif")), -128, 0, 128);
                   pTexture.addTexture(new ImageIcon(SceneIndex.class.getClassLoader().getResource("img/dirt.jpg")), 0, 128, 255);
                   pTexture.addTexture(new ImageIcon(SceneIndex.class.getClassLoader().getResource("img/granite.jpg")), 128, 255, 384);
                   pTexture.createTexture(64);
                   // Assigning the texture to the terrain
                   TextureState tState = display.getRenderer().createTextureState();
                   Texture t1 = TextureManager.loadTexture(pTexture.getImageIcon().getImage(), Texture.MM_LINEAR_LINEAR, Texture.FM_LINEAR, true);
                   tState.setTexture(t1, 0);
                   tBlock.setRenderState(tState);
              return tBlock;
    }Again, I've tried this a few different ways, and I either get a "Could Not Find Symbol" error referring to the getActiveTB(playerArea); in Main, or it just says java.lang.NoClassDefFoundError: and Exception in thread "main".
    Whatever.

  • How do you run another Java file from a master Java file?

    We're making a game in Java at school, and we need to know how we can run a Java file from another one - like inside the master Java file, we need to have a command to run game.java (something like that). Thanks!

    We're making a game in Java at school, and we need to know how we can run a Java file from another one - like inside the master Java file, we need to have a command to run game.java (something like that). Thanks!One doesn't "run a Java file", and there's no conventional definition of "master Java file". If you want to call the main() method of another class, just make sure the class is in your classpath and call the method. If you want to start up a separate JVM with that class as a process, use Runtime.exec() or similar method.
    ~

  • How to pass the value of variable to another java file?

    Hi. I have 2 java files (LogonAction.java and PCAction.java). The value of variable(String getrole) depends on the logon user. How can I use this value of variable in PCAction.java? I want to execute a sql statement in PCAction.java which is (String sql="Select * from PP where role"+"='" + getrole + "'") Thanks a lot.
    LogonAction.java is below:
    package test;
    import test.jdbc.util.ConnectionPool;
    import java.sql.*
    import java.util.*;
    import javax.servlet.http.*;
    import org.apache.commons.logging.*;
    import org.apache.struts.action.*;
    import org.apache.struts.util.*;
    import org.apache.commons.beanutils.PropertyUtils;
    public final class LogonAction extends Action {
    private Log log = LogFactory.getLog("org.apache.struts.webapp.Example");
    private ConnectionPool pool;
    public LogonAction() {
    pool = ConnectionPool.getInstance();
    public String getrole;
    public ActionForward execute(ActionMapping mapping,
    ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response)
    throws Exception {
    Locale locale = getLocale(request);
    MessageResources messages = getResources(request);
    ActionErrors errors = new ActionErrors();
    String username = (String)PropertyUtils.getSimpleProperty(form, "username");
    String password = (String)PropertyUtils.getSimpleProperty(form, "password");
    String getusername=CheckUser(username,password);
    getrole=getusername;
    java.lang.System.out.println(getrole);
    if ("".equals(getusername))
    errors.add(ActionErrors.GLOBAL_ERROR,
    new ActionError("error.password.mismatch"));
    getusername=username+getusername;
    // Report any errors we have discovered back to the original form
    if (!errors.isEmpty()) {
    saveErrors(request, errors);
    return (mapping.getInputForward());
    // Save our logged-in user in the session
    HttpSession session = request.getSession();
    session.setAttribute(Constants.USER_KEY, getusername);
    if (log.isDebugEnabled()) {
    log.debug("LogonAction: User '" + username +
    "' logged on in session " + session.getId());
    // Remove the obsolete form bean
    if (mapping.getAttribute() != null) {
    if ("request".equals(mapping.getScope()))
    request.removeAttribute(mapping.getAttribute());
    else
    session.removeAttribute(mapping.getAttribute());
    // Forward control to the specified success URI
    return (mapping.findForward("success"));
    * Look up the user, throwing an exception to simulate business logic
    * rule exceptions.
    * @param database Database in which to look up the user
    * @param username Username specified on the logon form
    * @exception ModuleException if a business logic rule is violated
    public String CheckUser(String username,String password){
    Connection con = null;
    try
    con = pool.getConnection();
    String sql = "SELECT * from user WHERE userid = ? AND password= ?";
    PreparedStatement ps = null;
    ResultSet rs = null;
    try {
    if (con.isClosed()) {
    throw new IllegalStateException("error.con.isClosed");
    ps = con.prepareStatement(sql);
    ps.setString(1,username);
    ps.setString(2,password);
    rs = ps.executeQuery();
    String returnstr="";
    while(rs.next())
    returnstr=rs.getString("role");
    java.lang.System.out.println(returnstr);
    return returnstr;
    } catch (SQLException e) {
    e.printStackTrace();
    throw new RuntimeException("error.ps.executeQuery");
    } finally {
    try {
    if (ps != null)
    ps.close();
    if (rs != null)
    rs.close();
    } catch (SQLException e) {
    e.printStackTrace();
    throw new RuntimeException("error.rs.close");
    catch (SQLException e)
    e.printStackTrace();
    throw new RuntimeException("Unable to get connection.");
    finally
    try
    if (con != null)
    con.close();
    catch (SQLException e)
    throw new RuntimeException(e.getMessage());
    }

    You can use PreparedStatement and
    String cmd = "select * from PP where role=?";
    PreparedStatement stmt = conn.prepareStatement(cmd);
    stmt.setString(1,theRole);

  • How to execute one java file in another java file

    Hi All!
    I hava a problem.. I need to validate functionality of one java file in my Junit test case.. so, I need to run that java file in my test file..
    How should I start with???? Are there any java API's for that.. I checked 'system' ..but which function will suite that functionality,,I am not sure about..

    I need to check the functionality of deletetion which
    is done by a java class.. Now I need to check this
    functionality..whether it is deleting or not... in my
    test case.. so, for that I need to execute that java
    file in similar manner as how we normally do it...,
    in my test case..So let the test case create a file and have your class delete it. What's there to run?

  • Calling another java file

    I have a main class ( packet.java for example) and I need to call another file (filter.java) to display a dialog box. Both files are in the same package, but all I want to do is when a button is clicked in packet.java, I want it to display the dialog box in filter.java.

    example:
    you have to source files with one class in each:
    file1:
    public class HelloWorld {
       private String helloText = null;
       public HelloWorld(String text) { // constructor
          helloText = text;
       public String getMessage() {
          return "Hello " + helloText;
    }file2 (which accesses the class in file1):
    public class Foo {
       public static void main(String[] args)  {
          for(int i=0; i<args.length; i++) {
             HelloWorld hello = new HelloWorld(args);
    System.out.println(hello.getMessage());
    if you run the app like this:
    java Foo blackieul Thofthe output will be:
    Hello blackieul
    Hello ThofPlease specify your problem more detailed - e.g. post an exception message or the fragment of code where you don't know what to do...

  • How To load or display another java file class!!!

    Master I am newbie just starting to learn about java. I have probelm to make my project for exam. anybody can help me for solve this probe thanks i need that soon.
    I have 3 file's java and the probe is after login i want to go to another file to display.
    - frm_login
    - SMSCENTER
    -SMSCENTERservice
    This the source code:
    -frm_login.java
    /* Indonesia
    * Ady Leo
    * Univeristas Budi Luhur
    import javax.microedition.lcdui.Alert;
    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.Form;
    import javax.microedition.lcdui.TextBox;
    import javax.microedition.lcdui.TextField;
    import javax.microedition.lcdui.Ticker;
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    * @adyleo
    * Jakarta, Indonesian
    * contact me : [email protected]
    * open source , u can use this free, edit this free, dont forget to feedback to me
    public class frm_login extends MIDlet implements CommandListener {
    private Display display;
    private Form formLogin;
    private TextField username;
    private TextField pass;
    private Ticker loginnews;
    private Command cmdKeluar;
    private Command cmdPilih;
    private Command cmdSch;
    private TextBox formAdmin;
    private Ticker ticker3;
    private Command cmdKeluar2;
    private SMSCENTER smscenter;
    private Alert alert;
    public frm_login() {
    display = Display.getDisplay(this);
    formLogin = new Form("LOGIN");
    username = new TextField("username", "", 50, TextField.ANY);
    pass = new TextField("password", "", 50, TextField.PASSWORD);
    loginnews = new Ticker("LOGIN USER");
    cmdKeluar = new Command("Keluar", Command.EXIT, 1);
    cmdPilih = new Command("Login", Command.OK, 2);
    cmdSch = new Command("Check", Command.OK, 3);
    formLogin.setTicker(loginnews);
    formLogin.append(username);
    formLogin.append(pass);
    formLogin.addCommand(cmdKeluar);
    formLogin.addCommand(cmdPilih);
    formLogin.setCommandListener(this);
    formAdmin = new TextBox("Welcome Halim", "Checks Your Flight Schedule", 40, TextField.ANY);
    ticker3 = new Ticker("WELCOME ABDUL HALIM ALHADY");
    formAdmin.setTicker(ticker3);
    formAdmin.addCommand(cmdKeluar);
    formAdmin.addCommand(cmdSch);
    formAdmin.setCommandListener(this);
    alert = new Alert("Error...!!!");
    alert.setTimeout(2500);
    public void startApp() {
    display.setCurrent(formLogin);
    public void pauseApp() {
    public void destroyApp(boolean unconditional) {
    public void commandAction(Command c, Displayable d) {
    if (c == cmdKeluar) {
    destroyApp(false);
    notifyDestroyed();
    } else if( c == cmdPilih ) {
    String PESAN_ERROR = "";
    if (username.getString().trim().equals(""))
    PESAN_ERROR += " Username Atau Password Anda Salah ";
    if (pass.getString().trim().equals(""))
    PESAN_ERROR += " Silakan Coba Lagi!!! ";
    if (username.getString().trim().equals("messi") && pass.getString().trim().equals("lodewijk")) {
    display.setCurrent(formAdmin);
    } else {
    alert.setString(PESAN_ERROR);
    display.setCurrent(alert);
    } else if ( c == cmdKeluar2 ){
    destroyApp(false);
    notifyDestroyed();
    //this the probe i want after i click the cmdSch will action to display another file java.. please help me
    } else if ( c == cmdSch ) {
         smscenter = new SMSCENTER();     
                   display.setCurrent(smscenter);
    -SMSCENTER.java
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    public class SMSCENTER extends MIDlet implements CommandListener {
    Display display;
    SMSCENTERservice form;
    List list;
    Command cmExit;
    public SMSCENTER() {
    display = Display.getDisplay(this);
    public void startApp() {
    list = new List("Sistem SMS Center", List.IMPLICIT);
    list.append("cek detil ", null);
    list.append("cek service ", null);
    list.append("cek surat", null);
    cmExit = new Command("Keluar", Command.EXIT, 1);
    list.addCommand(cmExit);
    list.setCommandListener(this);
    display.setCurrent(list);
    public void pauseApp() {
    public void destroyApp(boolean unconditional) {//KOMPONEN 3
    public void exitMIDlet() {
    destroyApp(false);
    notifyDestroyed();
    public void commandAction(Command c, Displayable s) {//even dari tombol"nya
    if (c == List.SELECT_COMMAND) {
    switch (list.getSelectedIndex()) {
    case 0://jika menu yang pertama yg dipilih maka jalankan
    form = new SMSCENTERservice(this, display, 0);
    display.setCurrent(form);
    break;
    case 1:
    form = new SMSCENTERservice(this, display, 1);
    display.setCurrent(form);
    break;
    case 2:
    form = new SMSCENTERservice(this, display, 2);
    display.setCurrent(form);
    break;
    } else if (c == cmExit) {
    exitMIDlet();
    -SMSCENTERservice.java
    import java.io.IOException;
    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.*;
    import javax.microedition.io.*;
    import java.util.*;
    public class SMSCENTERservice extends Form implements CommandListener, Runnable {
    private Display display;
    private Command cmdBack, cmdKirim;
    private SMSCENTER midlet;
    private TextField tfdetil,tfservice,tfsurat;
    private TextBox arti =new TextBox("","",1024,0);
    private Command cmdInputK = new Command("Input", Command.OK,1);
    private Command cmdKembaliK = new Command("Kembali", Command.BACK,2);
    private Alert alert,alert2,alert3,alert4;
    Object o;
    koneksi konek = new koneksi();
    String url = "";
    private int Index;
    private String messaage, address, pesan;
    private int index;
    private String port;
    public SMSCENTERservice(SMSCENTER midlet, Display display, int index) {
    super("Sistem SMS Gateway");
    this.display = display;
    this.midlet = midlet;
    this.index = index;
    switch (index) {
    case 0:
    append("cek detil");
    tfdetil = new TextField("DETIL SERVICE", "", 160, TextField.ANY);
    append(tfdetil);
    break;
    case 1:
         append("cek service ");
    tfservice = new TextField("SERVICE", "", 160, TextField.ANY);
              append(tfservice);
    break;
    case 2:
    append("cek surat");
    tfsurat = new TextField("SURAT SERVICE", "", 160, TextField.ANY);
    append(tfsurat);
    break;
    cmdBack = new Command("Kembali", Command.BACK, 1);
    addCommand(cmdBack);
    cmdKirim = new Command("Kirim", Command.OK, 1);
    addCommand(cmdKirim);
    setCommandListener(this);
    public void commandAction(Command c, Displayable d) {
         o=c;
    if (c == cmdBack) {
    display.setCurrent(midlet.list);
    } else if (c == cmdKirim) {
    switch (index) {
    case 0:
    url = "http://localhost/service/proses.php?katakunci=detil_service&NomorDetil=" + tfdetil.getString();
    break;
    case 1:
    url = "http://localhost/service/proses.php?katakunci=service&NomorService=" + tfservice.getString();
    break;
    case 2:
    url = "http://localhost/service/proses.php?katakunci=surat_service&NomorSurat=" + tfsurat.getString();
    break;
    public void run() {
    try {
         if(konek.downloadpage(url))
                   arti.setString(konek.b.toString());
                   arti.addCommand(cmdInputK);
                   arti.addCommand(cmdKembaliK);
                   arti.setCommandListener(this);
                   display.setCurrent(arti);
    else
              alert2 = new Alert("warning!", "Masukan kata lebih dahulu....",null, AlertType.INFO);
              display.setCurrent(alert2);
    catch (IOException e)
    Sorry if i am posting not on the good way or worng places, anyway i hope someone can help me just in form login i am sutck...
    I am student just newbie for java programing.
    thnks a lot

    Please reformat that mess with {noformat}{noformat} tags. No-one can read it until you do.                                                                                                                                                                                                                                                                                                                                   

  • How to call inner class method in one java file from another java file?

    hello guyz, i m tryin to access an inner class method defined in one class from another class... i m posting the code too wit error. plz help me out.
    // test1.java
    public class test1
         public test1()
              test t = new test();
         public class test
              test()
              public int geti()
                   int i=10;
                   return i;
    // test2.java
    class test2
         public static void main(String[] args)
              test1 t1 = new test1();
              System.out.println(t1.t.i);
    i m getting error as
    test2.java:7: cannot resolve symbol
    symbol : variable t
    location: class test1
              System.out.println(t1.t.geti());
    ^

    There are various ways to define and use nested classes. Here is a common pattern. The inner class is private but implements an interface visible to the client. The enclosing class provides a factory method to create instances of the inner class.
    interface I {
        void method();
    class Outer {
        private String name;
        public Outer(String name) {
            this.name = name;
        public I createInner() {
            return new Inner();
        private class Inner implements I {
            public void method() {
                System.out.format("Enclosing object's name is %s%n", name);
    public class Demo {
        public static void main(String[] args) {
            Outer outer = new Outer("Otto");
            I junior = outer.createInner();
            junior.method();
    }

  • Access another java file

    hello
    quick question again
    i have the main java page that calls and child page . when the child pg is called and loads , a custom sequence from the EOImpl.java gets the next number which is a primary key. if i choose to update a record all the correct data is called but in the background the sequence gets the next number which isnt used. so i might have 11 12 (then i update 12) 14 15 16 (i updated 16 twice) then 19 the wasted number is 13 17 18. trying to get a continuous number
    i would like to put this in the EOImpl.java .... if (pageContext.getParameter("save") != null ){   then call the sequence }
    its like this right now
    public void create(AttributeList attributeList)
    super.create(attributeList);
    setPbId(getOADBTransaction().getSequenceValue("Sequence_107_S"));
    trying to get this
    public void create(AttributeList attributeList)
    super.create(attributeList);
    if (pageContext.getParameter("save") != null )
    {     setPbId(getOADBTransaction().getSequenceValue("Sequence_107_S"));
    so when i put that bit of code in the EOImpl.java i get the error Error(79,11): variable pageContext not found in class ...
    how do i extend the child page to the EOImpl.java (not sure if i used terms) or what seem to be the problem.
    thanks

    You cant have pagecontext value in the EO create method.
    As far as my knowledge goes, such gaps are okay. Most of the times if a user navigates to the create screen, the data would be created. Only very few of those transactions would be lost.
    Regards
    Sumit

  • One button to launch another

    i have several buttons on one stage that are supposed to do
    the same thing. they're all very code intensive so i'd just like to
    code one and have the rest simply act as though selecting them
    selects the button with all the script. I'd think this would be
    simple but I haven't tracked down the solution yet. thoughts
    anyone??
    thanks

    show the code for two of your buttons.

  • How to reference another java file?

    nvm
    Edited by: kingryanj on Nov 24, 2008 7:06 AM

    BigDaddyLoveHandles wrote:
    He wrote [*nvm*|http://www.urbandictionary.com/define.php?term=nvm]!
    I bet he discovered imports

Maybe you are looking for