Results 1 to 5 of 5
  1. #1
    yahyaaa is offline Member
    Join Date
    Sep 2008
    Posts
    28
    Rep Power
    0

    Default help with button content

    Dear All,

    I made a GUI based on java.... what is the code for button that opens a a program for you ..

    lets say I want to press button and this will open excel or what ever program for me..

    How can I achieve this ?

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,559
    Rep Power
    25

    Default

    There are two parts to your project:
    One - recognize and handle button presses - look at Action and ActionListeners.
    Two - invoking another program - look at Process and Runtime

  3. #3
    yahyaaa is offline Member
    Join Date
    Sep 2008
    Posts
    28
    Rep Power
    0

    Default

    Please give me more detail... what to search for ?

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    answered in the sun java forums.

  5. #5
    serjant's Avatar
    serjant is offline Senior Member
    Join Date
    Jun 2008
    Location
    Ukraine,Zaporozhye
    Posts
    487
    Rep Power
    7

    Default

    Java Code:
    JButton exec=new JButton("Open Excel");
    exec.addActionListener(new ActionListener(){
          public void actionPerformed(ActionEvent e){
                  try {
            // Execute a command 'excel'
            String command = "excel";
            Process child = Runtime.getRuntime().exec(command);
        
         
        } catch (IOException e) {
        }
    }
    });


    [/code]
    Last edited by serjant; 09-20-2008 at 10:55 PM.

Similar Threads

  1. Content Assist
    By michael19 in forum Eclipse
    Replies: 3
    Last Post: 11-20-2008, 07:09 PM
  2. Two content panes in one GUI?
    By Leprechaun in forum New To Java
    Replies: 1
    Last Post: 01-31-2008, 04:02 AM
  3. Getting content type from a website
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-26-2007, 01:06 PM
  4. Asbru Web Content Management 6.5
    By johnt in forum Java Software
    Replies: 0
    Last Post: 08-08-2007, 08:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •