JOptionpane.showOptionDialog help

Object[] options = {"YES", "NO"};
JOptionPane.showOptionDialog (null, "Are you sure you want to leave", "Warning",
JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE,
null, options, options [0]
there is the code now i cant figure out a way to make the program exit if you say yes.. i know how stupid of me can some one plz help me?
should i write a if with a system.exit or what?

Swing related questions should be posted in the Swing forum.
Search the forum before posting a questions
Here is a simple example found in the Swing forum:
http://forum.java.sun.com/thread.jspa?forumID=57&threadID=695964

Similar Messages

  • Change the initial focus to "message" in JOptionPane.showOptionDialog?

    JPanel panel = new JPanel (false);
    JTextArea txtArea = new JTextArea (msg, 2, 60);
    JScrollPane sPane = new JScrollPane (txtArea);
    panel.add (sPane);
    int button = JOptionPane.showOptionDialog (frame, panel, titleStr, optionType, JOptionPane.PLAIN_MESSAGE, null, null, null);
    Is there a way to make txtArea to have the initial focus?
    Thanks,
    Ben

    Hi,
    Check out this post:
    Hide the 'no data found' message
    I hope that helps.
    -Marc

  • Simple JOptionPane.showOptionDialog() question

    Could you please help me:
    Here's a piece of code:
    JPasswordField field = new JPasswordField();
    int choice = JOptionPane.showOptionDialog(null, field, "Enter password:", 0,
    JOptionPane.QUESTION_MESSAGE, null,
    new String[] {"ОК", "Cancel"}
    , null);
    How to make an enter-key-press on JPasswordField to be equivalent to pressing OK key?? If it's possible or i should use bigger constructions (like private class PasswordAskClass extends JDialog) ???
    Thanks in advance for your replies.

    The problem is that you don't have a reference to the OK button.
    1) use a JDialog like you suggest.
    2) Create the buttons yourself, and pass them into JOptionPane as arguments.
    Then you'll be able to add a KeyMap to your JPasswordField that when ENTER is pressed, it sends an action event to your OK button.

  • A question about JOptionPane.showOptionDialog()?

    one problem confused me.
    import javax.swing.*;
    class Test
    public Test()
         int n;
         String title;
         Object[] message = new Object[3];
         Object[] obj = new Object[2];
         message[0] = "Name ";
         message[1] = "Age";
         title = "Information";
         obj[0] = "OK";
         obj[1] = "Cancel";
         n = JOptionPane.showOptionDialog(null,
         message,
         title,
    JOptionPane.OK_CANCEL_OPTION,
              JOptionPane.INFORMATION_MESSAGE,
                        null,
                        obj,
                        obj[0]);               
         public static void main(String[] args)
              new Test();
    i run the java compiler in command line.
    c:\proj1>javac Test.java
    c:\proj1>java Test
    Having done the program, i found that command line didnot return to "c:\proj1>"
    only after "Ctrl-c" can that return back to the "c:\proj1". i didnot meet this problem when i run other java projects.
    what's the problem?
    thanks!

    Implement a call to System.exit(0) at the point you want the programm to close.
    (Depending on the return code of your option dialog)

  • JOptionPane.showInputDialog Help!!!!

    Hello,
    I'm using JOptionPane.showInputDialog(Component parentComponent,
    Object message,
    String title,
    int messageType,
    Icon icon,
    Object[] selectionValues,
    Object initialSelectionValue ).
    which prompts the user to add some text and the same will be stored for later retrieval.
    In this case, JOptionPane pops up with a label, textfield,OK & Cancel buttons.
    Default focus is given to to the TextField.
    Is there anyway to get access to the TextField via code ?
    For example, if the user types "Hello World" in the given TextField, then I need to get the Text entered in
    the TextField in the following manner.
    String myStr = myJOptionPaneTextField().getText();
    System.out.println("Entered Text is "+ myStr);
    How can I Achieve the same ?
    Thanks in advance
    Regards
    vargav

    Why? At what point do you know you should manipulate the text? Usually, it would be when the user clicks OK, at which point it doesn't matter because the dialog is dismissed. So what kind of operations do you expect to be able to do?
    Aside from that, I'm not sure how to get the text field in the option pane, per se... It can be gotten by digging thru the pane's components til you find a text field. But you'd need to do that in a separate thread. So it's not really feasible to do that.... There is an alternative:
    The message is an object, and it can be an array of objects, which will all be added, and thus can include a message string and a text field...
    JTextField myfield = new JTextField();
    Object[] obj = new Object[2];
    obj[0] = "Enter some text here:";
    obj[1] = myfield;
    if(JOptionPane.showOptionDialog(obj, "Enter Text", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {
       String value = myfield.getText();
    }Then you can do whatever you want with the text field... but the same problem is there, you have lost the dialog before you can do anything.

  • JOptionPane.showOptionDialog(..) -problem

    Hi!
    I'm trying to ask the size of area of game with OptionDialog. Then this
    code should open the game frame. But the OptionDialog doesn't react
    to clicking. (doesn't close). Could you find the errorpoint?
    I have trying to find it many days.
    Could it be probably so that the main-method can't open frame after frame (first optionDialog then gameframe)?
    Gameframe opens when I test it to replace getGameAreaSize()-method simply with:
    public int getGameAreaSize() {
    return 10;
    import java.awt.event.*;
    import java.awt.*;
    import javax.swing.*;
    public class BattleShipGame {
         private int gameAreaSize;
         private Gameframe gameFrame;
         public Gameframe getGameframe() {
            if (gameFrame == null) {
                 gameFrame = new Gameframe();
                 gameFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            return gameFrame;
         public int getGameAreaSize() {
           Object[] options = {"10 x 10",
                               "12 x 12",
                               "14 x 14"};
           int n = JOptionPane.showOptionDialog(new Frame(),
           "Choose the area of the game: ",
           "question about area",
            JOptionPane.YES_NO_CANCEL_OPTION,
            JOptionPane.QUESTION_MESSAGE,
            null,
            options,
            options[2]);
            if (n==0) return (gameAreaSize = 10);
            if (n==1) return (gameAreaSize = 12);
            if (n==2) return (gameAreaSize = 14);
            else return (gameAreaSize = 0);
         public static void main(String[] args) {
            BattleShipGame bsg = new BattleShipGame();
            int size = bsg.getGameAreaSize();
            Gameframe gameframe = bsg.getGameframe();
            gameframe.setVisible(true);

    int n = JOptionPane.showOptionDialog(new Frame(),
    should be :
    int n = JOptionPane.showOptionDialog(this,
    Because when you start a new frame that hasn't got the focus and you let that frame pop the optionpane the mouse listener andsoon isn't listening to the optionpane.

  • Cannot Import javax.swing.JOptionPane   Please HELP!!!

    import javax.swing.JOptionPane;
    this line of code returns the error:
    C:\Java Files\BankAccount\BankAccount_Test.java:1: Class javax.swing.JOptionPane not found in import.
    import javax.swing.JOptionPane;
    ^
    1 error
    Process completed.
    Please help, I don't know what the problem could be....

    Swing was not part of any JDK's earlier than 1.2. Swing (or anything with a J in front of it, ie. JFrame, JOptionPane, etc...) was probably the most dramatic (if not largest) modification/addition to the Java language, that's why versions later than, and including, 1.2 are known as "Java 2".

  • JOptionPane.showMessageDialog() help

    I am trying to do a search on names inwhich i input into a file and then show them on a joptionpane. My problem is that I can't get it to run b/c it says that i have incompatable types. Please help if at all possible.
    String name, custid, num, result;
    int id, element;
    public void search(){
    num = JOptionPane.showInputDialog("Enter Customer ID:");
    id = Integer.parseInt(num);
    name = tree.lookUp(id);
    result = JOptionPane.showMessageDialog(null,new JTextArea(name));
    }

    result = JOptionPane.showMessageDialog(null,new JTextArea(name));your wrong if the JOptionPane.showMessageDialog()'return type is void,it means it hasn't a return value and you want to put a value to "result",you should use like this
    JOptionPane.showMessageDialog(null,new JTextArea(name));

  • JOptionPane Help Needed

    I basically have two problems with JOptionPane that I've searched for answers yet I haven't found an applicable answer for my application. Here they are:
    1) How can I get a JPasswordField in a JOptionPane to be given focus when the JOptionPane is displayed?
    2) How can I get the default key mappings for JOptionPane not to work or atleast make it where when a user hits "Enter", it activates the button that has current focus? I have a problem with highlighting "Cancel" and hitting "Enter".
    Here is my code being used for the JOptionPane:
    String pwd = "";
    int tries = 0;
    JPasswordField txt = new JPasswordField(10);
    JLabel lbl = new JLabel("Enter Password :");
    JLabel lbl1 = new JLabel("Invalid Password.  Please try again:");
    JPanel pan = new JPanel(new GridLayout(2,1));
    int retval;
    while(tries < 3 && !valid)
         if(tries > 0)
              pan.remove(lbl);
              pan.remove(txt);
              pan.add(lbl1);
              pan.add(txt);
              txt.setText("");
         else
              pan.add(lbl);
              pan.add(txt);
         retval = JOptionPane.showOptionDialog(DBPirate.appWindow,pan,
         "Password Input",                              JOptionPane.OK_CANCEL_OPTION,                              JOptionPane.QUESTION_MESSAGE,
         null,null,null);
         if(retval == JOptionPane.OK_OPTION)
              pwd = new String(txt.getPassword());
              setPassword(pwd);
              if(cryptoUtil.testPassword(pwd))
                   valid = true;
              else
                   tries += 1;
         else
              System.exit(0);
    }Any help would be appreciated. Thanks, Jeremy

    Hello Jeremy,
    I am not too happy with my code, for I think there must be something more efficient and elegant. But after trying in vain with KeyListener and ActionMap this is presently the only way I could do it.
    // JOptionPane where the <ret>-key functions just as the space bar, meaning the
    // button having focus is fired.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class ReturnSpace extends JFrame implements ActionListener
    { JButton bYes, bNo, bCancel;
      JDialog d;
      JOptionPane p;
      public ReturnSpace()
      { setSize(300,300);
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        Container cp= getContentPane();
        cp.setLayout(new FlowLayout());
        JButton b= new JButton("Show OptionPane");
        b.addActionListener(this);
        p=new JOptionPane("This is the question",
              JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_CANCEL_OPTION);
        d=p.createDialog(this,"JOptionPane with changing default button.");
        FocusListener fl= new FocusAdapter()
        { public void focusGained(FocusEvent e)
          {     JButton focusButton= (JButton)(e.getSource());
         d.getRootPane().setDefaultButton(focusButton);
        int i=1;
    //    if (plaf.equals("Motif")) i=2;
        bYes = (JButton)((JPanel)p.getComponent(i)).getComponent(0);
        bYes.addFocusListener(fl);
        bNo = (JButton)((JPanel)p.getComponent(i)).getComponent(1);
        bNo.addFocusListener(fl);
        bCancel = (JButton)((JPanel)p.getComponent(i)).getComponent(2);
        bCancel.addFocusListener(fl);
        cp.add(b);
        setVisible(true);
        d.setLocationRelativeTo(this);
      public void actionPerformed(ActionEvent e)
      { bYes.requestFocus();
        d.setVisible(true);
        Object value = p.getValue();
        if (value == null || !(value instanceof Integer))
        { System.out.println("Closed");
        else
        { int i = ((Integer)value).intValue();
          if (i == JOptionPane.NO_OPTION)
          { System.out.println("No");
          else if (i == JOptionPane.YES_OPTION)
          { System.out.println("Yes");
          else if (i == JOptionPane.CANCEL_OPTION)
          { System.out.println("Cancelled");
      public static void main(String argsv[])
      { new ReturnSpace();
    }Greetings
    Joerg

  • Need some help with JOptionPane

    Hi everyone. I want to create an OptionDialog with 3 textfields. So we have...
    String message1 = "The first Field";
    JTextField tf1 = new JTextField();
    String message2 = "The second Field";
    JTextField tf2 = new JTextField();
    String message3 = "The third Field";
    JTextField tf3 = new JTextField();
    Object o[] = {message 1, tf1, message2, tf2, message3, tf3};
    int result = JOptionPane.showOptionDialog(this, o, "A dialog", JOptionPane.OK_CANCEL_DIALOG,JOptionPane.QUESTION_MESSAGE, null, null, null);
    if(result == JOptionPane.OK_OPTION){
    Various actions here
    }However I want my dialog to focus in the first textfield, rather than, for example, in the OK button. I've tried a few alchemies but nothing actually worked. So I want your help :-). Is it possible to have the text indicator (you know that blinking | ) in the textfield? Can I do the same with a combo box too? I mean, how can I tell the programm to have selected the first option of the combobox when the dialog pops up?
    Thanx in advance

    Issue fixed.
    try
                String m1 = "One Field";
                String m2 = "Two Fields";
                String m3 = "Three fields";
                JTextPane tf1 = new JTextPane();
                JTextPane tf2 = new JTextPane();
                JTextPane tf3 = new JTextPane();
                Object o[] = {m1, tf1, m2, tf2, m3, tf3};
                JOptionPane pane = new JOptionPane(o, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, null, o[1]);
                JDialog dialog = pane.createDialog(this, "A new Dialog");
                dialog.setVisible(true);
                Object selectedValue = pane.getValue();
                if(((Integer)selectedValue).intValue() == JOptionPane.OK_OPTION)
                    <<VARIOUS ACTIONS HERE!>>
    catch(Exception e){ }Thnx everyone for stopping by!

  • JoptionPane need some help understanding, with buttons PLEASE SOMEONE :)

    Hi all I was hoping that someone would be kind enough to explain to me how I can add a method to buttons in a JoptionPane.
    Also can I pplease ask for you to look at this code I think I have stuff something as it is not working the way that I want,
    I want to add something like this to the ok button.
    String check = LastNameJText.getText()+FirstNameJText.getText();
    System.out.println(check);
          if
            //check to see if First & Last name have been entered.
            (check != null){
            return;
            else //create a dialog that shows Title,first & Last Name
             // & ask if you would like to make an new ordre
              String d= System.getProperty("line.separator");
           Object[] options = {"Cancel","OK",};
           int n = JOptionPane.showOptionDialog(null,
           "Do you really want to add a new shoe order for:"+ d +
           (String) TitleComboBox.getSelectedItem()+" "+FirstNameJText.getText()+" "+LastNameJText.getText(),"New Order",
           JOptionPane.YES_OPTION,
           JOptionPane.INFORMATION_MESSAGE,
           null,
           options,
        options[0]);
          if //Check to see if First & Last name text feilds are clear.
    (check == null){
    return ;
    else
       //make sure that all text fields are clear for new order
            ClearAllTextFields();

    When I do that i get
    "Order.java": Error #: 300 : variable options not found in class epod_1_0.Order at line 2152, column 4
    "Order.java": Error #: 300 : variable options not found in class epod_1_0.Order at line 2153, column 4
    why would this be ?
    This is the code
    String check = LastNameJText.getText()+FirstNameJText.getText();
    System.out.println(check);
          if
            //check to see if First & Last name have been entered.
            (check != null){
            return;
            else //create a dialog that shows Title,first & Last Name
             // & ask if you would like to make an new ordre
              String d= System.getProperty("line.separator");
          int result = JOptionPane.showOptionDialog(null,
       "Do you really want to add a new shoe order for:"+ d +
       (String) TitleComboBox.getSelectedItem()+" "+FirstNameJText.getText()+
        " "+LastNameJText.getText(),"New Order",
       JOptionPane.YES_OPTION,
       JOptionPane.INFORMATION_MESSAGE,
       null,
       options,
       options[0]);
    switch(result){
       case JOptionPane.YES_OPTION: // Add your code for yes
          break;
       case JOptionPane.NO_OPTION: // Add your code for no
         dispose();
          break;
          if //Check to see if First & Last name text feilds are clear.
    (check == null){
    return ;
    else
       //make sure that all text fields are clear for new order
            ClearAllTextFields();
      }

  • STRANGE problem with JOptionPane.showMessageDialog .. HELP!!!

    Please look at the code below and tell me what is wrong with it and my code is very very very simple!!! And I can't seem to understand why this error is coming up.
    import javax.swing.JOptionPane;
    public class ShowMessageDialog {
    public ShowMessageDialog() {
    //empty constructor for now
    public void show () {
    JOptionPane.showMessageDialog (null, "Please try again!!", "Error Message", JOptionPane.ERROR_MESSAGE);
    }This class is invoked by another class named SendPacketBack which does nothing but checks for one condition in an if statment and then make an object of this class and calls this show() method and this error comes up. Please look at the error below and tell me why it is telling me java.lang.NoClassDefFoundError and not telling me which class???
    java.lang.NoClassDefFoundError
         at java.lang.Class.forName0(Native Method)
         at java.lang.Class.forName(Class.java:141)
         at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:62)
         at sun.awt.motif.MToolkit.<clinit>(MToolkit.java:81)
         at java.lang.Class.forName0(Native Method)
         at java.lang.Class.forName(Class.java:141)
         at java.awt.Toolkit$2.run(Toolkit.java:748)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:739)
         at javax.swing.ImageIcon.<init>(ImageIcon.java:205)
         at javax.swing.LookAndFeel$1.createValue(LookAndFeel.java:274)
         at javax.swing.UIDefaults.getFromHashtable(UIDefaults.java:184)
         at javax.swing.UIDefaults.get(UIDefaults.java:129)
         at javax.swing.MultiUIDefaults.get(MultiUIDefaults.java:44)
         at javax.swing.UIDefaults.getIcon(UIDefaults.java:410)
         at javax.swing.UIManager.getIcon(UIManager.java:537)
         at javax.swing.plaf.basic.BasicOptionPaneUI.getIconForType(BasicOptionPaneUI.java:555)
         at javax.swing.plaf.basic.BasicOptionPaneUI.getIcon(BasicOptionPaneUI.java:543)
         at javax.swing.plaf.basic.BasicOptionPaneUI.createMessageArea(BasicOptionPaneUI.java:313)
         at javax.swing.plaf.basic.BasicOptionPaneUI.installComponents(BasicOptionPaneUI.java:154)
         at javax.swing.plaf.basic.BasicOptionPaneUI.installUI(BasicOptionPaneUI.java:122)
         at javax.swing.JComponent.setUI(JComponent.java:449)
         at javax.swing.JOptionPane.setUI(JOptionPane.java:1693)
         at javax.swing.JOptionPane.updateUI(JOptionPane.java:1715)
         at javax.swing.JOptionPane.<init>(JOptionPane.java:1678)
         at javax.swing.JOptionPane.showOptionDialog(JOptionPane.java:828)
         at javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:642)
         at javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:613)
         at cc.ShowMessageDialogue.show(ShowMessageDialogue.java:13)
         at cc.SendPacketBack.sendPacketTo(SendPacketBack.java:62)
    I would appreciate any suggestions or advice to solve this issue.
    Regards
    Khurram

    Yes X server is alright. I should have mentioned one thing though in my previous email is that there is another class which extends JFrame and is part of the package that this class is in also running in the background but that class does not interact with this class at all and does not even know if it exists!
    I don't know if that thing is causing some kind of problem which is not coming up here?
    Khurram

  • Help needed with project

    Hello everyone. Some help would be appreciated. I have created a wildlife resort database with access.
    It has an animals table with 5 entries, a species table with 3 entries and a user table with 3 entries.
    I have set up a JDBC-ODBC bridge.
    The server side of this application when run gets stuck upon pressing connect the first time so I have to run the server again while the first server window is running in the background and press connect for it to start running. The server works just fine after that. I can add and remove from the tables using the server.
    When I run the client and try to connect it, it doesn't accept the hostname. I can't connect or log in.
    I think the problem is with the threads but I'm not sure what to do to fix it.
    Also I use java beans for coding.
    These are some errors I get when running the client:
    java.lang.IllegalThreadStateException
    at java.lang.ThreadGroup.add(ThreadGroup.java:856)
    at java.lang.Thread.start(Thread.java:573)
    at org.apache.tools.ant.taskdefs.ProcessDestroyer.removeShutdownHook(ProcessDestroyer.java:145)
    at org.apache.tools.ant.taskdefs.ProcessDestroyer.remove(ProcessDestroyer.java:198)
    at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:487)
    at org.apache.tools.ant.taskdefs.Java.fork(Java.java:746)
    at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:170)
    at org.apache.tools.ant.taskdefs.Java.execute(Java.java:83)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
    at org.apache.tools.ant.Task.perform(Task.java:364)
    at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:64)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
    at org.apache.tools.ant.Task.perform(Task.java:364)
    at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:377)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
    at org.apache.tools.ant.Task.perform(Task.java:364)
    at org.apache.tools.ant.Target.execute(Target.java:341)
    at org.apache.tools.ant.Target.performTasks(Target.java:369)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
    at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:217)
    at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:236)
    at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:125)
    Exception in thread "Thread-7" java.lang.NullPointerException
    at Client.Connect.connecting(Connect.java:45)
    at Client.ClientGUI.run(ClientGUI.java:214)
    at java.lang.Thread.run(Thread.java:595)
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at Client.Connect.userPass(Connect.java:206)
    at Client.ClientGUI.actionPerformed(ClientGUI.java:164)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
    at javax.swing.AbstractButton.doClick(AbstractButton.java:302)
    at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1000)
    at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1041)
    at java.awt.Component.processMouseEvent(Component.java:5488)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3093)
    at java.awt.Component.processEvent(Component.java:5253)
    at java.awt.Container.processEvent(Container.java:1966)
    at java.awt.Component.dispatchEventImpl(Component.java:3955)
    at java.awt.Container.dispatchEventImpl(Container.java:2024)
    at java.awt.Component.dispatchEvent(Component.java:3803)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
    at java.awt.Container.dispatchEventImpl(Container.java:2010)
    at java.awt.Window.dispatchEventImpl(Window.java:1766)
    at java.awt.Component.dispatchEvent(Component.java:3803)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
    These are the classes I have created:
    On the client side:
    //imports needed for the GUI and I/O Operations
    import java.awt.event.*;
    import java.awt.*;
    import javax.swing.*;
    import java.io.*;
    public class ClientGUI extends JFrame implements ActionListener, Runnable {
    JPanel pane = new JPanel();
    //Create the Menubar Items
    JMenuBar bar = new JMenuBar();
    JMenu jMenu1 = new JMenu();
    JMenu jMenu2 = new JMenu();
    JMenu jMenu3 = new JMenu();
    JMenuItem Exit = new JMenuItem();
    JMenuItem Open = new JMenuItem();
    JMenuItem Close = new JMenuItem();
    JMenuItem Find = new JMenuItem();
    static JMenuItem Add = new JMenuItem();
    static JMenuItem Remove = new JMenuItem();
    static JMenuItem Connect1 = new JMenuItem();
    static JMenuItem Disconnect = new JMenuItem();
    static JMenuItem Login = new JMenuItem();
    static JMenuItem Logout = new JMenuItem();
    static boolean check = true;
    static JLabel running = new JLabel("You are not Connected");
    //Creates the animal JTable and adds it to a scrollpane
    public static String[] animalH = {"Id" , "Name" , "Description" , "Species Id"};
    public static Object rows1 [] [] = new Object[40][4];
    public static JTable animal = new JTable(rows1 , animalH);
    JScrollPane animalP;
    //Creates the species JTable and adds it to a scrollpane
    public static String[] speciesH = {"Species Id" , "Species Name"};
    public static Object rows2 [] [] = new Object[40][2];
    public static JTable species = new JTable(rows2 , speciesH);
    JScrollPane speciesP;
    public static Thread runner;
    //Declares Globale variables
    static int currentT;
    int respones;
    static String hostname;
    static boolean connected = false;
    /** Creates a new instance of ClientGUI */
    public ClientGUI() {
    super("SA Wildlife -- Client");
    setSize(800 , 600);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    getContentPane().add(running , BorderLayout.SOUTH);
    Add.setEnabled(false);
    Remove.setEnabled(false);
    Logout.setEnabled(false);
    Disconnect.setEnabled(false);
    try {
    jbInit();
    }catch(Exception e) {
    e.printStackTrace();
    addListener();
    setJMenuBar(bar);
    setVisible(true);
    //Add the actionListeners to the components
    public void addListener(){
    Open.addActionListener(this);
    Close.addActionListener(this);
    Exit.addActionListener(this);
    Connect1.addActionListener(this);
    Disconnect.addActionListener(this);
    Find.addActionListener(this);
    Login.addActionListener(this);
    Logout.addActionListener(this);
    Add.addActionListener(this);
    Remove.addActionListener(this);
    //Add the actions which the components must perform
    public void actionPerformed(ActionEvent evt){
    Object s = evt.getSource();
    if (s == Open){
    choice();
    Close();
    if (respones == 0){
    currentT = 1;
    clearTableAnimals();
    Connect.allAnimal();
    animal = new JTable(rows1, animalH);
    animalP = new JScrollPane(animal);
    getContentPane().add(animalP, BorderLayout.CENTER);
    setVisible(true);
    }else if (respones == 1 ){
    currentT = 2;
    clearTableSpecies();
    Connect.allSpecies();
    species = new JTable(rows2 , speciesH);
    speciesP = new JScrollPane(species);
    getContentPane().add(speciesP, BorderLayout.CENTER);
    setVisible(true);
    }else if (s == Close){
    Close();
    }else if (s == Exit){
    exit();
    }else if (s == Connect1){
    hostname = JOptionPane.showInputDialog(null , "Please enter Hostname");
    if (check = true){
    runner = new Thread(this);
    runner.start();
    Connect1.setEnabled(false);
    Disconnect.setEnabled(true);
    }else if (s == Disconnect){
    Connect.out.println("Bye");
    runner = null;
    try {
    Connect.out.close();
    Connect.in.close();
    Connect.clientSocket.close();
    } catch (IOException ioe) {
    JOptionPane.showMessageDialog(null,
    "Error " + ioe.toString(),
    "IO Exception",
    JOptionPane.ERROR_MESSAGE);
    System.exit(0);
    }else if (s == Find){
    choice();
    Close();
    if (respones == 0){
    currentT = 1;
    String Aname = JOptionPane.showInputDialog(null , "Enter Animal name to find ");
    clearTableAnimals();
    Connect.findAnimal(Aname);
    animal = new JTable(rows1, animalH);
    animalP = new JScrollPane(animal);
    getContentPane().add(animalP, BorderLayout.CENTER);
    setVisible(true);
    }else{
    currentT = 2;
    String Sname = JOptionPane.showInputDialog(null , "Enter Species name to find ");
    clearTableSpecies();
    Connect.findSpecies(Sname);
    species = new JTable(rows2 , speciesH);
    speciesP = new JScrollPane(species);
    getContentPane().add(speciesP, BorderLayout.CENTER);
    setVisible(true);
    }else if( s== Login){
    String name = JOptionPane.showInputDialog(null , "Please enter a UserName");
    String password = JOptionPane.showInputDialog(null , "Please enter a Password");
    Connect.userPass(name , password);
    }else if (s == Logout){
    Logout();
    }else if (s== Add){
    choice();
    Close();
    if(respones == 0){
    currentT = 1;
    String id = JOptionPane.showInputDialog(null , "Enter an Animal id");
    String name = JOptionPane.showInputDialog(null , "Enter an Animal Name");
    String desc = JOptionPane.showInputDialog(null , "Enter an Animal Description");
    String speciesid = JOptionPane.showInputDialog(null , "Enter an Animal species id");
    clearTableAnimals();
    Connect.toAddAnimal(id , name , desc , speciesid);
    Connect.allAnimal();
    animal = new JTable(rows1, animalH);
    animalP = new JScrollPane(animal);
    getContentPane().add(animalP, BorderLayout.CENTER);
    setVisible(true);
    }else{
    currentT = 2;
    String id = JOptionPane.showInputDialog(null , "Enter a Species id");
    String name = JOptionPane.showInputDialog(null , "Enter a Species name");
    clearTableSpecies();
    Connect.toAddSpecies(id , name);
    Connect.allSpecies();
    species = new JTable(rows2 , speciesH);
    speciesP = new JScrollPane(species);
    getContentPane().add(speciesP, BorderLayout.CENTER);
    setVisible(true);
    }else if (s == Remove){
    choice();
    Close();
    if(respones == 0){
    currentT = 1;
    String id = JOptionPane.showInputDialog(null , "Enter an Animal id to Remove");
    Connect.toRemoveAnimal(id);
    }else{
    currentT = 2;
    String id = JOptionPane.showInputDialog(null , "Enter a Species id to Remove");
    Connect.toRemoveSpecies(id);
    public void run() {
    Connect connect = new Connect();
    while (runner != null) {
    try {
    connect.connecting();
    catch (IOException ioe) {
    System.out.println("Error: " + ioe);
    ClientGUI.running.setText("You are now connected");
    //Method the creates the dialog box for the user to choose what he wants to do
    void exit(){
    String [] option = { "Exit" , "Minimize" , "Cancel" };
    int which = JOptionPane.showOptionDialog(null , "Sure you want to exit"
    , "Exiting" , 0 , JOptionPane.WARNING_MESSAGE ,
    null , option , option[2] );
    if (which == 0){
    System.exit(1);
    }else if (which == 1){
    setState(JFrame.ICONIFIED);
    }else{}
    //Closes the current table on the panel
    public void Close(){
    if(currentT == 1){
    animalP.setVisible(false);
    }else if (currentT == 2){
    speciesP.setVisible(false);
    }else{}
    //Method that give the user a choice on which table to perform actions on
    public void choice(){
    String[] choices = {"Animals" , "Species"};
    respones = JOptionPane.showOptionDialog(null ,
    "Please select Table" , "Table" , 0 , JOptionPane.INFORMATION_MESSAGE ,
    null , choices , choices[1] );
    //Clears the Species table
    public void clearTableSpecies(){
    for (int i = 0; i < 40; i++){
    rows2[0] = "";
    rows2[i][1] = "";
    //Clears the Animal table
    public void clearTableAnimals(){
    for (int i = 0; i < 40; i++){
    rows1[i][0] = "";
    rows1[i][1] = "";
    rows1[i][2] = "";
    rows1[i][3] = "";
    //Method for the Logout button
    public void Logout(){
    JOptionPane.showMessageDialog(null , "You are now logged out ");
    Login.setEnabled(true);
    Add.setEnabled(false);
    Remove.setEnabled(false);
    Logout.setEnabled(false);
    //Main Methof
    public static void main(String[] args) {
    ClientGUI GUI1 = new ClientGUI();
    // Adds all components to the panel
    private void jbInit() throws Exception {
    jMenu1.setText("File");
    Exit.setText("Exit");
    jMenu2.setText("Table Action");
    Open.setText("Open Table");
    Add.setText("Add to Table");
    Remove.setText("Remove from Table");
    Find.setText("Find In table");
    Close.setText("Close Current");
    jMenu3.setText("Client");
    Connect1.setText("Connect");
    Disconnect.setText("Disconnect");
    Login.setText("Login");
    Logout.setText("Logout");
    bar.add(jMenu1);
    bar.add(jMenu2);
    bar.add(jMenu3);
    jMenu1.add(Exit);
    jMenu2.add(Open);
    jMenu2.add(Add);
    jMenu2.add(Remove);
    jMenu2.add(Find);
    jMenu2.add(Close);
    jMenu3.add(Connect1);
    jMenu3.add(Disconnect);
    jMenu3.add(Login);
    jMenu3.add(Logout);
    package Client;
    import java.io.*;
    import java.net.*;
    import javax.swing.*;
    import java.util.*;
    public class Connect {
    static public Socket clientSocket = null;
    static public PrintWriter out = null;
    static public BufferedReader in = null;
    public void connecting() throws IOException {
    try{
    clientSocket = new Socket(ClientGUI.hostname , 1234);
    out = new PrintWriter(clientSocket.getOutputStream() , true);
    in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
    }catch (UnknownHostException e){
    JOptionPane.showMessageDialog(null , "Dont know about host");
    ClientGUI.check = false;
    ClientGUI.Connect1.setEnabled(true);
    ClientGUI.Disconnect.setEnabled(false);
    ClientGUI.runner = null;
    }catch(IOException i){
    ClientGUI.check = false;
    JOptionPane.showMessageDialog(null,"Couldnt get i/O for the connection to 127.0.0.0.1");
    ClientGUI.Connect1.setEnabled(true);
    ClientGUI.Disconnect.setEnabled(false);
    ClientGUI.runner = null;
    if (ClientGUI.check = true){
    String fromServer;
    StringTokenizer token1;
    String First;
    String Second;
    String Third;
    while ( (fromServer = in.readLine()) != null) {
    System.out.println("From SerVer ---------------> " + fromServer);
    token1 = new StringTokenizer(fromServer, "%");
    StringTokenizer token2;
    StringTokenizer token3;
    First = token1.nextToken();
    System.out.println("First ------- > " + First);
    if (First.equalsIgnoreCase("SelectedAnimal")) {
    System.out.println("IT's ON ");
    Second = token1.nextToken();
    System.out.println("Second ----> " + Second);
    int y = 0;
    int x = 0;
    System.out.println("In the 1while");
    token2 = new StringTokenizer(Second, "$");
    while (token2.hasMoreTokens()) {
    System.out.println("In the 2while");
    token3 = new StringTokenizer(token2.nextToken(), "@");
    x = 0;
    while (token3.hasMoreTokens()) {
    ClientGUI.rows1[y][x] = token3.nextToken();
    x++;
    y++;
    else if (First.equalsIgnoreCase("SelectedSpecies")) {
    System.out.println("IT's ON BITCH ");
    Second = token1.nextToken();
    System.out.println("Second ----> " + Second);
    int y = 0;
    int x = 0;
    System.out.println("In die 1while");
    token2 = new StringTokenizer(Second, "$");
    while (token2.hasMoreTokens()) {
    System.out.println("In die 2while");
    token3 = new StringTokenizer(token2.nextToken(), "@");
    x = 0;
    while (token3.hasMoreTokens()) {
    ClientGUI.rows2[y][x] = token3.nextToken();
    x++;
    y++;
    else if (First.equalsIgnoreCase("FoundAnimal")) {
    Second = token1.nextToken();
    if (! (Second.equalsIgnoreCase("NONE"))) {
    System.out.println("Second ----> " + Second);
    int y = 0;
    int x = 0;
    System.out.println("In the 1while");
    token2 = new StringTokenizer(Second, "$");
    while (token2.hasMoreTokens()) {
    System.out.println("In the 2while");
    token3 = new StringTokenizer(token2.nextToken(), "#@#");
    x = 0;
    while (token3.hasMoreTokens()) {
    ClientGUI.rows1[y][x] = token3.nextToken();
    x++;
    y++;
    else {
    JOptionPane.showMessageDialog(null,
    "Could not find Animal , Please try again");
    else if (First.equalsIgnoreCase("FoundSpecies")) {
    Second = token1.nextToken();
    if (! (Second.equalsIgnoreCase("NONE"))) {
    System.out.println("Second ----> " + Second);
    int y = 0;
    int x = 0;
    System.out.println("In die 1while");
    token2 = new StringTokenizer(Second, "$");
    while (token2.hasMoreTokens()) {
    System.out.println("In die 2while");
    token3 = new StringTokenizer(token2.nextToken(), "#@#");
    x = 0;
    while (token3.hasMoreTokens()) {
    ClientGUI.rows2[y][x] = token3.nextToken();
    x++;
    y++;
    else {
    JOptionPane.showMessageDialog(null,
    "Could not find Species , Please try again");
    else if (First.equalsIgnoreCase("FoundUser")) {
    System.out.println("From Server --- > " + First);
    String login = token1.nextToken();
    System.out.println("Find true or false ---- > " + login);
    if (login.equalsIgnoreCase("isUser")) {
    JOptionPane.showMessageDialog(null, "You are now logged in");
    ClientGUI.Add.setEnabled(true);
    ClientGUI.Remove.setEnabled(true);
    ClientGUI.Logout.setEnabled(true);
    ClientGUI.Login.setEnabled(false);
    else {
    JOptionPane.showMessageDialog(null,
    "Invalid Username or Password, Please try again");
    else if (First.equalsIgnoreCase("RecordAddedA")) {
    JOptionPane.showMessageDialog(null, "Record Added");
    else if (First.equalsIgnoreCase("RecordAddedS")) {
    JOptionPane.showMessageDialog(null, "Record Added");
    else if (First.equalsIgnoreCase("SQLE")) {
    System.out.println("ERROR SQL ERROR");
    else if (First.equalsIgnoreCase("Blah1")) {
    System.out.println("ERROR Ander ERROR");
    else if (First.equalsIgnoreCase("AnimalRemoved")) {
    JOptionPane.showMessageDialog(null, "Record Removed");
    else if (First.equalsIgnoreCase("SpeciesRemoved")) {
    JOptionPane.showMessageDialog(null, "Record Removed");
    }else{
    System.out.println("BLAAAAAAAAH");
    static public void Close() throws IOException{
    out.println("bye");
    ClientGUI.runner = null;
    ClientGUI.Disconnect.setEnabled(false);
    ClientGUI.Connect1.setEnabled(true);
    out.close();
    in.close();
    clientSocket.close();
    static public void allAnimal(){
    out.println("SELECTANIMALS");
    static public void allSpecies(){
    out.println("SELECTSPECIES");
    static public void findAnimal(String name){
    out.println("FINDANIMAL" + "@" + name);
    static public void findSpecies(String name){
    out.println("FINDSPECIES@" + name);
    static public void userPass(String name , String password){
    System.out.println("FINDUSER -----> " + name + " " + password);
    out.println("FINDUSER@" + name + "@" + password);
    static public void toAddAnimal(String id , String name , String desc , String species){
    out.println("toAddAnimal@" + id +"@" + name +"@" + desc +"@" + species );
    static public void toAddSpecies(String id , String name){
    out.println("toAddSpecies@" + id +"@" + name );
    static public void toRemoveAnimal(String id){
    out.println("toRemoveAnimal@" + id);
    static public void toRemoveSpecies(String id){
    out.println("toRemoveSpecies@" + id);
    On the server side:
    package Server;
    ////import everything necesary for the Database Connection
    import java.sql.*;
    import java.util.StringTokenizer;
    import javax.swing.*;
    import java.util.*;
    public class DatabaseConnect {
    //Declaration of Globale variables
    static int hoeveel = 0;
    static ResultSet rec ;
    static String bidData[] = new String[100];
    static String toSend[] = new String[100];
    //Connects the program to the database
    public DatabaseConnect() {
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    String source = "jdbc:odbc:Database";
    Connection dbconnect = DriverManager.getConnection(source);
    Statement st = dbconnect.createStatement();
    }catch(ClassNotFoundException cnf){
    System.out.println("classNotFound" + cnf);
    }catch(SQLException se) {
    System.out.println("SqlExeption" + se);
    //Selects the data from the databas and adds the data to the tables
    public void open(){
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    String source = "jdbc:odbc:Database";
    Connection dbconnect = DriverManager.getConnection(source);
    Statement st = dbconnect.createStatement();
    if (ServerGUI.currentT == 1){
    hoeveel = 0;
    rec = st.executeQuery("SELECT * FROM ANIMALS");
    while (rec.next()) {
    bidData[hoeveel++] = rec.getString(1) + "@#@" +
    rec.getString(2) + "@#@" +
    rec.getString(3) + "@#@" +
    rec.getString(4);
    readintoTable1();
    }else if (ServerGUI.currentT == 2){
    hoeveel = 0;
    rec = st.executeQuery("SELECT * FROM SPECIES");
    while (rec.next()) {
    bidData[hoeveel++] = rec.getString(1) + "@#@" + rec.getString(2);
    readintoTable2();
    }else if(ServerGUI.currentT == 3){
    hoeveel = 0;
    rec = st.executeQuery("SELECT * FROM USER");
    while (rec.next()) {
    bidData[hoeveel++] = rec.getString(1) + "@#@" + rec.getString(2)
    + "@#@" + rec.getString(3);
    readintoTable3();
    }catch(ClassNotFoundException cnf){
    System.out.println("classNotFound" + cnf);
    }catch(SQLException se) {
    System.out.println("SqlExeption" + se);
    //Clean the table and reads the data into the animal table
    public void readintoTable1(){
    for(int a = 0; a < 40; a++){
    ServerGUI.rows1[a][0] = "";
    ServerGUI.rows1[a][1] = "";
    ServerGUI.rows1[a][2] = "";
    ServerGUI.rows1[a][3] = "";
    for (int i = 0; i < hoeveel; i++) {
    StringTokenizer str = new StringTokenizer(bidData[i], "@#@");
    ServerGUI.rows1[i][0] = str.nextToken();
    ServerGUI.rows1[i][1] = str.nextToken();
    ServerGUI.rows1[i][2] = str.nextToken();
    ServerGUI.rows1[i][3] = str.nextToken();
    //Clean the table and reads the data into the Species table
    public void readintoTable2(){
    for(int a = 0; a < 40; a++){
    ServerGUI.rows2[a][0] = "";
    ServerGUI.rows2[a][1] = "";
    for (int i = 0; i < hoeveel; i++) {
    StringTokenizer str = new StringTokenizer(bidData[i], "@#@");
    ServerGUI.rows2[i][0] = str.nextToken();
    ServerGUI.rows2[i][1] = str.nextToken();
    //Clean the table and reads the data into the User table
    public void readintoTable3(){
    for(int a = 0; a < 40; a++){
    ServerGUI.rows3[a][0] = "";
    ServerGUI.rows3[a][1] = "";
    ServerGUI.rows3[a][2] = "";
    for (int b = 0; b < hoeveel; b++) {
    StringTokenizer str = new StringTokenizer(bidData, "@#@");
    ServerGUI.rows3[b][0] = str.nextToken();
    ServerGUI.rows3[b][1] = str.nextToken();
    ServerGUI.rows3[b][2] = str.nextToken();
    //add animal information to the Animal table in the database
    public void addAnimal(String id , String name , String desc , String species_id){
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    String source = "jdbc:odbc:Database";
    Connection dbconnect = DriverManager.getConnection(source);
    Statement st = dbconnect.createStatement();
    int toAdd;
    String sqlstm = "INSERT INTO animals" + "(animal_id, animal_Name , description , species_id)" +
    "VALUES (" + id + ", '" + name + "', '" + desc + "', " + species_id + ")";
    toAdd = st.executeUpdate(sqlstm);
    dbconnect.close();
    JOptionPane.showMessageDialog(null , "New Record Added");
    ServerGUI.refreshAnimal();
    ServerGUI.currentT = 1;
    open();
    }catch(ClassNotFoundException cnf){
    JOptionPane.showMessageDialog(null,
    "Class Not Found -> " + cnf.toString(),
    "Error!!",
    JOptionPane.ERROR_MESSAGE);
    System.out.println("classNotFound" + cnf);
    }catch(SQLException se) {
    JOptionPane.showMessageDialog(null,
    "SQL Exception -> " + se.toString()
    + "\n Please make sure all data is entered correctly ",
    "Error!!",
    JOptionPane.ERROR_MESSAGE);
    System.out.println("SqlExeption" + se);
    //add animal information to the Species table in the database
    public void addSpecies(String id1 , String name1){
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    String source = "jdbc:odbc:Database";
    Connection dbconnect = DriverManager.getConnection(source);
    Statement st = dbconnect.createStatement();
    int toAdd;
    String sqlstm = "INSERT INTO species" + "(species_id, species_name)" +
    "VALUES ( '" + id1 + "', '" + name1 + "')";
    toAdd = st.executeUpdate(sqlstm);
    dbconnect.close();
    JOptionPane.showMessageDialog(null , "New Record Added");
    ServerGUI.refreshSpecies();
    ServerGUI.currentT = 2;
    open();
    }catch(ClassNotFoundException cnf){
    JOptionPane.showMessageDialog(null,
    "Class Not Found -> " + cnf.toString(),
    "Error!!",
    JOptionPane.ERROR_MESSAGE);
    System.out.println("classNotFound" + cnf);
    }catch(SQLException se) {
    JOptionPane.showMessageDialog(null,
    "SQL Exception -> " + se.toString()
    + "\n Please make sure all data is entered correctly ",
    "Error!!",
    JOptionPane.ERROR_MESSAGE);
    System.out.println("SqlExeption" + se);
    //add animal information to the User table in the database
    public void addUser(String id2 , String user , String pass){
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    String source = "jdbc:odbc:Database";
    Connection dbconnect = DriverManager.getConnection(source);
    Statement st = dbconnect.createStatement();
    int toAdd;
    String sqlstm = "INSERT INTO user" + "(user_id, user_name ,user_password)" +
    "VALUES ( '" + id2 + "', '" + user + "', '"+ pass + "')";
    toAdd = st.executeUpdate(sqlstm);
    dbconnect.close();
    JOptionPane.showMessageDialog(null , "New Record Added");
    ServerGUI.refreshUser();
    ServerGUI.currentT = 3

    Your code is completely unreliable and it should be placed inside a code block when you add it. Also your question would be better off in the JDBC forum than the networking one.

  • Need help in xml

    i want to know how to parse an xml doc using javax.xml.parsers
    i have written a simple ide for java with lots of options and the software would look better if i include xml support.
    u can find the code below.
    /* Thank you for your interest in viewing the source of Jcom */
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.util.jar.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.undo.*;
    import javax.swing.text.*;
    // The main Class.
    public class Jcom extends JFrame
    JTextArea t=new JTextArea();
    JTextField output;
    Font f=new Font("SansSerif",Font.PLAIN,13);
    int count=0,char_count=0,class_count=0,char_changed=0,recent_compile=0,tabinsert=0;
    String curfile,Dir="./",text,file="Untitled",Key_word="",ext="java";
    String menucomm[]={"New","Open","Save","Save as","Exit","Cut","Copy","Paste","Select All","Comment","Compile","Run","About","Shortcut List","Undo","Redo","Bookmark"};
    File o_file;
    OutputStream f1;
    MessageWindow mw=new MessageWindow("Console Window.");
    protected UndoManager undo = new UndoManager();
    static Jcom jc;
    StatusBar status;
    JProgressBar progress;
    displayProgress dp=new displayProgress("Loading in Progress.");
    JComboBox jb;
    // Constructor
    public Jcom(String title) throws Exception
    super(title);
    setVisible(true);
    //setIconImage(new ImageIcon("./images/icon.gif"));
    t.setMargin(new Insets(20,30,20,20));
    setSize(700,500);
    String vers = System.getProperty("java.version");
    if(vers.compareTo("1.1.2")>0)
    t.setDragEnabled(true); // Works only in version 1.4
    t.setAutoscrolls(true);
    t.setFont(f);
    t.setLineWrap(true);
    t.setWrapStyleWord(true);
    t.setTabSize(6);
    Dimension dim=getToolkit().getScreenSize();
    setLocation(dim.width/2-getWidth()/2,dim.height/2-getHeight()/2);
    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    addWindowListener(new Winlis());
    undo.discardAllEdits();
    //main() method
    public static void main(String arg[]) throws Exception
    jc=new Jcom("JCom - The Java IDE.");
    jc.addmenu();
    jc.addtools();
    // Ask for exit
    public void askexit()
    int ch=2;
    if(char_changed==1)
    ch=JOptionPane.showOptionDialog(null,"Save Changes you made to "+file+" ?","Confirm",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,null,null);
    if(ch==0)
    save_doc();
    System.exit(0);
    public boolean save_doc()
    try
         if(file.equals("Untitled") || file==null)
              save_doc_as();
         else
         String text=t.getText();
         byte buf[]=text.getBytes();
         o_file=new File(Dir,file);
         OutputStream f1=new FileOutputStream(o_file);
         f1.write(buf);
         f1.close();
         char_changed=0;
         setTitle(file+" - JCompile");
    //setIcon(new ImageIcon("./images/icon.gif");
         catch(Exception i)
         return false;
    output.setText(file+" Total lines : "+t.getLineCount());
    return true;
    public boolean save_doc_as()
         try
         FileDialog fd=new FileDialog(this,"Save this document as",FileDialog.SAVE);
         fd.setVisible(true);
         file=fd.getFile();
         if(file==null)
         file="Untitled";
         return false;
         Dir=fd.getDirectory();
         text=t.getText();
         byte buf[]=text.getBytes();
         o_file=new File(Dir,file);
         f1=new FileOutputStream(o_file);
         f1.write(buf);
         f1.close();
         setTitle(file+" - JCompile");
         char_changed=0;
         setTitle(file+" - JCompile");
    //setIcon(new ImageIcon("./images/icon.gif");
         catch(Exception e)
         return false;
    output.setText(file+" Total lines : "+t.getLineCount());
    return true;
    public boolean compileit()
         try
         if(file.equals("Untitled"))
         if(save_doc()==false)
         return false;
         if(file==null)
         return false;
         if(char_changed==1)
         if(save_doc()==false)
         return false;
         output.setText("Compiling "+file+" ...");
         mw.jt.setText("Compiling "+file+" ..."+"\n");
         String comm="Javac.exe "+Dir+file;
         Process ps=Runtime.getRuntime().exec(comm);
         Runtime.getRuntime().gc();     
         InputStream textfile=ps.getErrorStream();
         DataInputStream dai=new DataInputStream(textfile);
         String S=dai.readLine();
         int errorcount=0;
         while(S != null)
         errorcount++;
         mw.jt.append(S+"\n");
         S=dai.readLine();
         if(errorcount==0)
              output.setText("Compilation Successful. Alt+v to Run the code.");
         else
         output.setText("Some Errors/Warnings occured during the compilation.");
         mw.setVisible(true);
         mw.setTitle("Compilation Results.");
         return false;
         }// end of try
         catch(IOException ie)
         JOptionPane.showMessageDialog(null, "Some I/O Error has occured. Please save your file and continue.", "I/O Error.",JOptionPane. ERROR_MESSAGE);
         return false;
         catch(Exception e)
         JOptionPane.showMessageDialog(null, "Exception has occured. Please save your file and continue.", "Exception.",JOptionPane. ERROR_MESSAGE);           
         return false;
         return true;
    public void run_program()
         try
         if(file==null)
         return;
         if(!mw.isVisible())
         mw.setVisible(true);
         if(char_changed==1)
         if(save_doc()==false)
         return;
         if(compileit()==false)
         return;
         mw.jt.setText("\nExecuting "+file+" ..."+"\n");
         int pos_dot=file.indexOf('.');
         char class_name[]=file.toCharArray();
         String class_name_string=new String(class_name,0,pos_dot);
         String comm="java "+class_name_string;
         Runtime ru=Runtime.getRuntime();
         Process ps=ru.exec(comm);
         InputStream textfile=ps.getErrorStream();
         Runtime.getRuntime().gc();     
         DataInputStream dai=new DataInputStream(textfile);
         String S=dai.readLine();
         if(S!=null)
         mw.jt.append("\nFollowing Runtime Error has occured.\n");
         int errorcount=0;
         while(S != null)
         errorcount++;
         mw.jt.append(S+"\n");
         S=dai.readLine();
         DataInputStream din=new DataInputStream(ps.getInputStream());
         S=din.readLine();
         errorcount=0;
         while(S != null)
         errorcount++;
         mw.jt.append(S+"\n");
         S=din.readLine();
         mw.jt.append("Execution of "+file+" has terminated."+"\n");
         output.setText("Execution completed.");
         mw.setTitle("Execution Results.");
         catch(IOException ie)
         JOptionPane.showMessageDialog(null, "Exception has occured. Please save your work and continue. ", "I/O Error",JOptionPane. ERROR_MESSAGE);           
         return;
         catch(Exception e)
         JOptionPane.showMessageDialog(null, "Exception has occured. Please save your work and continue. ", "I/O Error",JOptionPane. ERROR_MESSAGE);           
         return;
    public void addtools()
    //Adding toolbar
    JToolBar toolbar=new JToolBar();
    String[] iconfiles={"./images/new.gif","./images/open.gif","./images/save.gif","./images/cut.gif","./images/copy.gif","./images/paste.gif","./images/compile.gif","./images/run.gif"};
    jb = new JComboBox();
    jb.addActionListener(new bookListen());
    String[] butcomm={"New","Open","Save","Cut","Copy","Paste","Compile","Run"};
    ImageIcon[] icons=new ImageIcon[iconfiles.length];
    JButton[] buttons = new JButton[iconfiles.length];
    for(int i=0;i<iconfiles.length;i++)
         icons=new ImageIcon(iconfiles[i]);
         buttons[i]=new JButton(icons[i]);
         buttons[i].addActionListener(new actListen());
         buttons[i].setActionCommand(butcomm[i]);
         buttons[i].setToolTipText(butcomm[i]);
         toolbar.add(buttons[i]);
         if(i+1%3==0)
         toolbar.addSeparator();
         getContentPane().add("North",toolbar);
    status=new StatusBar();
    getContentPane().add("South",status);
    // this adds fonts support to the toolbar
    /*JComboBox jc = new JComboBox();
         String[] fonts = getToolkit().getFontList();
         for (int i = 0; i < fonts.length; i++)
         jc.addItem(fonts[i]);
         toolbar.add(jc);*/
    output=new JTextField(30);
    output.setEditable(false);
    status.add(output);
    status.add(new JLabel("Bookmarks "));
    jb.setMaximumRowCount(8);
    status.add(jb); //Add bookmark list
    validate();
    }/* End of addtools*/
    public void addmenu()
    //Adding menu Bar
    JMenuBar mb= new JMenuBar();
    setJMenuBar(mb);
    JMenuItem new1,open,save,save_as,cut,copy,paste,sel_all,und,red,find,replace,exit,about,compile,check,runit,shortcut_list,bookmark;
    // Adding contents for menu bar
    JMenu file=new JMenu("File");
    JMenu edit=new JMenu("Edit");
    JMenu search=new JMenu("Search");
    JMenu tools=new JMenu("Tools");
    JMenu make=new JMenu("Make");
    JMenu help=new JMenu("Help");
    new1=new JMenuItem("New");
    new1.setToolTipText("Create a new file.");
    new1.setIcon(new ImageIcon("./images/new.gif"));
    new1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_MASK ));
    file.add(new1);
    new1.addActionListener(new actListen());
    open=new JMenuItem("Open");
    open.setToolTipText("Open an existing file.");
    open.setIcon(new ImageIcon("./images/open.gif"));
    open.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_MASK ));
    file.add(open);
    open.addActionListener(new actListen());
    save=new JMenuItem("Save");
    save.setToolTipText("Save changes.");
    save.setIcon(new ImageIcon("./images/save.gif"));
    save.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK ));
    file.add(save);
    save.addActionListener(new actListen());
    save_as=new JMenuItem("Save as");
    save_as.setToolTipText("Save changes as.");
    file.add(save_as);
    save_as.addActionListener(new actListen());
    exit=new JMenuItem("Exit");
    exit.setToolTipText("Exit.");
    exit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.ALT_MASK ));
    file.add(exit);
    exit.addActionListener(new actListen());
    exit.setIcon(new ImageIcon("./images/exit.gif"));
    mb.add(file);
    cut=new JMenuItem("Cut");
    cut.setToolTipText("Cut selection.");
    cut.setIcon(new ImageIcon("./images/cut.gif"));
    cut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK ));
    edit.add(cut);
    cut.addActionListener(new actListen());
    copy=new JMenuItem("Copy");
    copy.setToolTipText("Copy selection.");
    copy.setIcon(new ImageIcon("./images/copy.gif"));
    copy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK ));
    edit.add(copy);
    copy.addActionListener(new actListen());
    paste=new JMenuItem("Paste");
    paste.setToolTipText("Paste from clipboard.");
    paste.setIcon(new ImageIcon("./images/paste.gif"));
    paste.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_MASK ));
    edit.add(paste);
    paste.addActionListener(new actListen());
    sel_all=new JMenuItem("Select All");
    sel_all.setToolTipText("Select all.");
    sel_all.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_MASK ));
    edit.add(sel_all);
    sel_all.addActionListener(new actListen());
    und=new JMenuItem("Undo");
    und.setToolTipText("Undo.");
    und.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_MASK ));
    edit.add(und);
    und.addActionListener(new actListen());
    red=new JMenuItem("Redo");
    red.setToolTipText("Redo.");
    red.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Y, InputEvent.CTRL_MASK ));
    edit.add(red);
    red.addActionListener(new actListen());
    mb.add(edit);
    find=new JMenuItem("Find");
    search.add(find);
    find.setIcon(new ImageIcon("./images/find.gif"));
    find.addActionListener(new actListen());
    replace=new JMenuItem("Replace");
    search.add(replace);
    replace.setIcon(new ImageIcon("./images/replace.gif"));
    replace.addActionListener(new actListen());
    mb.add(search);
    JMenuItem tar_file=new JMenuItem("Create Archive");
    tools.add(tar_file);
    tar_file.addActionListener(new actListen());
    JMenuItem docu=new JMenuItem("Create Documentation");
    tools.add(docu);
    docu.addActionListener(new actListen());
    JMenuItem comment=new JMenuItem("Comment");
    comment.setToolTipText("Comment Selection.");
    tools.add(comment);
    comment.addActionListener(new actListen());
    bookmark=new JMenuItem("Bookmark");
    tools.add(bookmark);
    bookmark.addActionListener(new actListen());
    mb.add(tools);
    compile=new JMenuItem("Compile");
    compile.setToolTipText("Compile.");
    compile.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.ALT_MASK ));
    make.add(compile);
    compile.setIcon(new ImageIcon("./images/compile.gif"));
    compile.addActionListener(new actListen());
    runit=new JMenuItem("Run");
    runit.setToolTipText("Run.");
    runit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.ALT_MASK ));
    make.add(runit);
    runit.setIcon(new ImageIcon("./images/run.gif"));
    runit.addActionListener(new actListen());
    mb.add(make);
    shortcut_list=new JMenuItem("Shortcut List");
    help.add(shortcut_list);
    shortcut_list.addActionListener(new actListen());
    about=new JMenuItem("About");
    help.add(about);
    about.addActionListener(new actListen());
    mb.add(help);
    //Register with document listener.
    t.getDocument().addDocumentListener(new docListen());
    // Register with Undo Listener
    t.getDocument().addUndoableEditListener(new UndoHandler());
    //Register with Keyboard listener
    t.addKeyListener(new keyListen());
    JScrollPane scrollpane=new JScrollPane(t);
    Container cont=getContentPane();
    cont.add(scrollpane);
    validate();
    }/* End of addmenu */
    /* Frame for displaying console outputs */
    public class MessageWindow extends JFrame
    JTextArea jt;
    public MessageWindow(String title)
    super(title);
    setSize(400,400);
    //setIcon(new ImageIcon("./images/icon.gif"));
    jt =new JTextArea();
    jt.setEditable(false);
    JScrollPane scroll=new JScrollPane(jt);
    getContentPane().add(scroll);
    jt.addKeyListener(new keyListen());
    jt.addMouseListener(new mouseListen());
    validate();
    }//End of console display class
    /* Frame for displaying progress bar during an operation */
    public class displayProgress extends JFrame
    JLabel jl;
    public displayProgress(String title)
    super(title);
    setSize(300,100);
    setResizable(false);
    removeNotify();
    Dimension dim=getToolkit().getScreenSize();
    setLocation(dim.width/2-getWidth()/2,dim.height/2-getHeight()/2);
    getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER,8,30));
    jl=new JLabel("Lines Loaded : ");
    progress = new JProgressBar();
    progress.setMinimum(0);
    progress.setMaximum(45);
    getContentPane().add(jl);
    getContentPane().add(progress);
    validate();
    }//End of progress display.
    public void addNew() // To add a new Book Mark
    String selectedText=t.getSelectedText();
    if(selectedText!=null)
    jb.addItem(selectedText);
    jb.showPopup();
    output.setText("Bookmark added.");
    public void remove() // To remove a Bookmark
    jb.removeAllItems();
    /* Book Mark Handler*/
    class bookListen implements ActionListener
    public void actionPerformed(ActionEvent ae)
    String search=(String)jb.getSelectedItem();
    if(search!=null)
    findString(search);
    }//End of class
    // Undo Handler
    class UndoHandler implements UndoableEditListener
         public void undoableEditHappened(UndoableEditEvent e)
              undo.addEdit(e.getEdit());
    }// undo handler
    public class keyListen extends KeyAdapter
    KeyStroke ks;
    public void keyPressed(KeyEvent ke)
    try
    ks=KeyStroke.getKeyStrokeForEvent(ke);
    String s1=KeyEvent.getKeyModifiersText(ks.getModifiers()); //s1 has modifiers like Ctrl+Alt
    String s2=KeyEvent.getKeyText(ks.getKeyCode()); //s2 has key like 'a'
    if(s2.equals("Up") || s2.equals("Down") || s2.equals("Left") || s2.equals("Right"))
    int chcount=t.getCaretPosition();
    int linecount=t.getLineOfOffset(chcount)+1;
    output.setText("Character count : "+chcount+" Line Number : "+linecount);
    boolean flag=true;
    String search;
         if(s1.equals("Ctrl+Shift")) // Required
              output.setText("Looking for Macro ...");          
              if(s2.equals("S"))
              t.insert("\tSystem.out.println(\"\");",t.getCaretPosition());
              output.setText("Macro : Insert System.out.println() method.");          
              else if(s2.equals("C")) // Create a default constructor
              if(file.equals("Untitled"))
              flag=save_doc_as();
              if(flag)
              int pos_dot=file.indexOf('.');
              char class_name[]=file.toCharArray();
              String class_name_string=new String(class_name,0,pos_dot);
              t.insert("public "+class_name_string+"()\n\t{\n\n\t}",t.getCaretPosition());
              output.setText("Macro : Insert Default Constructor.");          
              else if(s2.equals("M"))
              t.insert("\tpublic static void main(String arg[])\n\t{\n\n\t}",t.getCaretPosition());
              output.setText("Macro : Insert Main method.");          
              else if(s2.equals("T"))
              t.insert("try\n{\n\n}\n\ncatch(Exception e)\n{\n\te.printStackTrace();\n}",t.getCaretPosition());
              output.setText("Macro : Insert try-catch block.");                              }
         }// Macro check end ctrl+alt
         // Additional check using only alt.
         else if(s1.equals("Alt"))
              if(s2.equals("F"))
              search=mw.jt.getSelectedText();
              if(search!=null)
              findString(search);
         } // Alt check
    }//try
    catch(Exception e)
         output.setText("Cannot find the Error Region.");
    }// Function end
    }/* End of Keylisten */
    public void findString(String search)
    try
    boolean found=false;
              String lineToFind=search;
              if(lineToFind==null)
              return;
              for(int i=0;i<t.getLineCount();i++)
              int offset=t.getLineStartOffset(i);
              String lineInArea=t.getText(offset,lineToFind.length());
              output.setText("Currently Looking ... "+lineInArea);
              if(lineInArea.equals(lineToFind))
              t.requestFocus();
              t.select(offset,offset+lineToFind.length());
              output.setText("Required Line Detected.");
              found=true;
              break;
              }//for loop
              if(found==false)
              output.setText("Cannot find Required Line.");
              found=false;
    catch(BadLocationException be)
         output.setText("Cannot find the Error Region.");
    }// end of find error.
    //Window Listener
    public class Winlis extends WindowAdapter
    public void windowClosing(WindowEvent we)
    askexit();
    //Document Listener
    public class docListen implements DocumentListener
    public void changedUpdate(DocumentEvent de)
    try
    char_changed=1;
    setTitle(file+" <changed> - JCompile");
    //setIcon(new ImageIcon("./images/save.gif");
    int chcount=t.getCaretPosition();
    int linecount=t.getLineOfOffset(chcount)+1;
    output.setText("Character count : "+chcount+" Line Number : "+linecount);
    catch(BadLocationException be)
    output.setText("Character count : "+t.getCaretPosition());
    public void insertUpdate(DocumentEvent de)
    try
    char_changed=1;
    setTitle(file+" <changed> - JCompile");
    //setIcon(new ImageIcon("./images/save.gif");
    int chcount=t.getCaretPosition();
    int linecount=t.getLineOfOffset(chcount)+1;
    output.setText("Character count : "+chcount+" Line Number : "+linecount);
    catch(BadLocationException be)
    output.setText("Character count : "+t.getCaretPosition());
    public void removeUpdate(DocumentEvent de)
    try
    char_changed=1;
    setTitle(file+" <changed> - JCompile");
    //setIcon(new ImageIcon("./images/save.gif");
    int chcount=t.getCaretPosition();
    int linecount=t.getLineOfOffset(chcount)+1;
    output.setText("Character count : "+chcount+" Line Number : "+linecount);
    catch(BadLocationException be)
    output.setText("Character count : "+t.getCaretPosition());
    }//Document Listener
    // Action Listener
    public class actListen implements ActionListener
    //Action listener
    public void actionPerformed(ActionEvent ae)
    String str=(String)ae.getActionCommand();
    int command_number=0;
    for(int i=0;i<20;i++)
    if(str.equals(menucomm[i]))
    command_number=i;
    break;
    switch(command_number)
         case 0:
         if(char_changed==1)
         int ch=JOptionPane.showOptionDialog(null,"Save Changes you made to "+file+" ?","Confirm",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,null,null);
         if(ch==0)
         save_doc();     
         t.setText("");
         char_changed=0;
         setTitle("Untitled");
         file="Untitled";
         remove();
         undo.discardAllEdits();
         break;
         case 1:
         //open_doc();
         int ch=2;
         if(char_changed==1)
         ch=JOptionPane.showOptionDialog(null,"Save Changes you made to "+file+" ?","Confirm",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,null,null);
              if(ch==0)
              save_doc_as();
         t.setText("");
         FileDialog fd=new FileDialog(jc,"Open a file",FileDialog.LOAD);
         fd.setVisible(true);
         file=fd.getFile();
         // Support for class files also
         int pos_dot=file.indexOf('.');
         ext=file.substring(pos_dot+1,file.length());
         if(ext.equalsIgnoreCase("class")) // it is a class file
         try
         Runtime r=Runtime.getRuntime();
         String comm="jad.exe -s .java "+file;
         r.exec(comm);
         file=file.substring(0,pos_dot)+".java";
         catch(Exception e)
         output.setText("Some error has occured in Decompiling the class file.");
         Dir=fd.getDirectory();
         if(file!=null)
         Thread ofile=new openFile();
         ofile.start();
         dp.setVisible(false);
         remove();
         break;
         case 2:
         // Save
         save_doc();
         break;
         case 3:
         save_doc_as();
         break;     
         case 4:
         // Exit
         askexit();
         break;
         case 5:
         t.cut();
         break;
         case 6:
         t.copy();
         break;
         case 7:
         t.paste();
         break;
         case 8:
         t.selectAll();
         break;
         case 9: //comment
         String otext=t.getSelectedText();
         if(otext!=null)
         String ntext="/*\n"+otext+"\n*/";
         t.replaceSelection(ntext);
         break;
         case 10:
         if(char_changed==1)
         save_doc();
         output.setText("Compiling "+file+" ...");
         compileit();
         break;
         case 11:
         if(char_changed==1)
         compileit();
         if(file.equals("Untitled"))
         save_doc_as();
         compileit();
         else
         output.setText("Executing "+file+" ...");
         run_program();
         break;
         case 12: //about
         JOptionPane.showMessageDialog(null, "Jcom - IDE for Java beta 1.0.\nVisit www.geocities.com/prabhus14 for updates.", "About",JOptionPane. INFORMATION_MESSAGE);           
         break;
         case 13: //Short Cut List
         mw.setVisible(true);
    mw.setTitle("Shortcut keys List.");
         mw.jt.setText("Shortcut Keys for Jcom.\nRight now only some of them are implemented.\nIn later versions users can customise these keys(called \"macros\" in Jcom) and can also add new ones!");
         mw.jt.append("\nMacros begin with Ctrl+Shift or Alt alone.\n\n");
         mw.jt.append("Ctrl+Shift+S\tTo insert System.out.println() method.\n");
         mw.jt.append("Ctrl+Shift+C\tTo create the default constructor for your class.\n");
         mw.jt.append("Ctrl+Shift+M\tTo insert main() method.\n");
         mw.jt.append("Ctrl+Shift+T\tTo insert try-catch block.\n");
         mw.jt.append("\nThe following macro is quite different and will differentiate Jcom from any other IDE.\n");
         mw.jt.append("\nAfter compiling if you get any errors then the console window will automatically appear with the messages.\n");     
         mw.jt.append("1. Select the line in the Error Message.(using mouse of course)\n");
         mw.jt.append("2. Press Alt+F or Right Click.\n");
         mw.jt.append("3. You will see the Error Region selected in your code.\n");
         mw.jt.append("Remember you must select right from the beginning of the line.\nRead Readme.html for more guidance.\n");     
         break;
         case 14:
         if(undo.canUndo())
              undo.undo();
              output.setText(undo.getUndoPresentationName());
         break;
         case 15:
         if(undo.canRedo())
              undo.redo();
              output.setText(undo.getRedoPresentationName());
         break;
         case 16: //Bookmark
         addNew();
         break;
    }/*End of action listener*/
    }//Action Listener
    // Mouse Listener
    class mouseListen extends MouseAdapter
    String search;
    public void mouseClicked(MouseEvent me)
    String vers = System.getProperty("java.version");
    if(vers.compareTo("1.1.2")>0)
    if(me.getButton()==3)
         search=mw.jt.getSelectedText();
         if(search!=null)
         findString(search);
    }//mouse listener
    // A thread for opening file.
    protected class openFile extends Thread
    openFile()
    setPriority(7);
    public void run()
    try
         int count=0;
         File fil1=new File(Dir,file);
         dp.setVisible(true);
         int factor=(int)fil1.length()/45;
         int i=1;
         FileInputStream textfile=new FileInputStream(fil1);
         DataInputStream dai=new DataInputStream(textfile);
         String S=dai.readLine();
         count+=S.length();
         dp.jl.setText("Lines Loaded : "+i++);
         if(ext.equals("class"))
         t.setText("/* Jcom - IDE for Java.\nVisit www.geocities.com/prabhus14 for updates.\n*/\n");
         while(S != null)
         if(ext.equals("class"))
         if(i>5)
         t.append(S+"\n");
         else
         t.append(S+"\n");
         S=dai.readLine();
         count+=S.length();
         progress.setValue((int)count/factor);
         dp.jl.setText("Lines Loaded : "+i++);
         }//while
         progress.setValue(45);
         dp.setVisible(false);
         setTitle(file+" - JCompile");
         catch(Exception ie)
         dp.setVisible(false);
    output.setText(file+" Total lines : "+t.getLineCount());
    return;
    }//End of run
    }//End of thread     
    // A class simulating Status Bar
    class StatusBar extends JComponent
    public StatusBar()
         super();
         setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
    public void paint(Graphics g)
    super.paint(g);
    }//End of class StatusBar
    }/*End of class Jcom*/

    Hmm well my first reply didn't seem to make it.
    I would recommend Castor if you are talking about supporting XML to save your Java Objects. Castor is a great XML-Java data binding tool that I personally love. You can just write a map between the XML and java elements and it can marshal and unmarshal for you. JAXB (Java API fo XML Binding) can do the same thing but you have to build the classes from a schema you can't just supply a map for it (so you might have to rework your classes). If you mean that you want to edit XML directly in the IDE then you might want to look at the DOM (Document Object Model), its memory intensive though.

  • Please help me! showInputDialog with specific Buttons

    Hi all,
    I'm from Germany and have some trouble with the JOptionPane package.
    Everything works fine, but I have a german operationsystem and i'm writing an 1.4 application in english.
    If I use a Optiondialog i can create my own buttontexts.
    String[] options = { "Yes", "No" };
    int n = JOptionPane.showOptionDialog(StartScreen.frame,
    "Do you really want to quit ?", // Fragetext
    "Are you sure ?", // Titel
    JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, // Icon
    null, options, options[0]);
    if (n == JOptionPane.YES_OPTION) {
    Transfer.closeConnection();
    System.exit(0);
    That works, but here I see the german buttons, how can I choose specific Buttons here?
    String response = (String) JOptionPane.showInputDialog(
              contentpane, // parent
              "Who is your favorite chipmunk?", // message
              "Pick a Chipmunk", // dialog title
              JOptionPane.QUESTION_MESSAGE, // icon type
              null, // no explicit icon
              new String[] {                     // choices
                   "Alvin", "Simon", "Theodore"
              "Alvin"); // default choice
    Hope anyone can help me.
    Thanks

    in your main method :
    Locale.setDefault(Locale.UK);
    Then all default buttons will show in english.

Maybe you are looking for

  • MOVED: Riser Card for K8D Master-FT (Rackmount)

    This topic has been moved to Server/workstation. Riser Card for K8D Master-FT (Rackmount)

  • How to migrate OLE-Containers from 6i to 9i

    Hello, We have an application developed in Client-Server that uses ole-containers to store documents(.doc,.xls,.gif, and others) in a long raw field. Our problem is that in forms 9i the ole-container component has been removed. How can we replace thi

  • How to build database driven mobile apps with dreamweaver and phonegap?

    Hi all, I'm searching the easiest way to implement a simple database in my app. I can build application with php/mysql in seconds with dreamweaver. But how can I do something similar with dreamweaver cs5.5 and phonegap for mobile apps? I would like t

  • Aperture is not compatible with Apple TV

    Apple Support has confirmed that the preview function in Aperture is not compatible with Apple TV.  Don't buy Aperture if you want the same resolution on Apple TV!  Stick with iPhoto!!

  • Help with reuse_uk dataserv-recycling

    Would like to know if anyone has had issues with receiving payment from them as I sent my G5 on the 2nd of March and still not had money transferred into my bank. They hardly reply to emails and when they do they just say same thing, that it takes 21