Results 1 to 1 of 1
  1. #1
    erroreport is offline Dumbest Member
    Join Date
    Oct 2012
    Location
    Land of the Cows
    Posts
    1
    Rep Power
    0

    Default Using BlueJ Terminal Window and JFrame simultaneously

    Hello,
    I am an extreme novice at Java and as a school project, I have to design a program in java. Now, although we havent been taught swing, i thought of jazzing it up a bit anyway, however, it is mandatory that a part of the program has to use the terminal window- commands like System.out.print ,scanner etc. Here is my code --

    Java Code:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class gridbag2
    {
      
      public static void main()
      {
          JFrame frame=new JFrame("frame");
          frame.setSize(500,500);
          frame.setVisible(true);
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          JPanel panel=new JPanel(new GridBagLayout());
          frame.add(panel);
          GridBagConstraints c=new GridBagConstraints();
          JLabel Label=new JLabel(" MENU");
          c.gridx=0;
          c.gridy=0;
          panel.add(Label,c);
          JButton button=new JButton(" New Student Data Entry");
          c.gridx=0;
          c.gridy=1;
          
          c.insets = new Insets(10,10,10,10);
          panel.add(button,c);
          JButton button2=new JButton(" View Entire Data List");
          c.gridx=0;
          c.gridy=2;
          panel.add(button2,c);
          JButton button3=new JButton(" Search For Specific Student");
          c.gridx=0;
          c.gridy=3;
          panel.add(button3,c);
          JButton button4=new JButton(" View Pass Name List");
          c.gridx=0;
          c.gridy=4;
          
          panel.add(button4,c);
          JButton button5=new JButton(" View Not Passed Name List");
          c.gridx=0;
          c.gridy=5;
          panel.add(button5,c);
            
          
          JButton button6=new JButton(" Statistical Overview ");
          c.gridx=0;
          c.gridy=6;
          panel.add(button6,c);
            
          
          JButton button7=new JButton(" Delete Database Contents ");
          c.gridx=0;
          c.gridy=7;
          panel.add(button7,c);
            
         
          JButton button8=new JButton(" EXIT");
          c.gridx=0;
          c.gridy=8;
          panel.add(button8,c);
         
          frame.getContentPane().add(panel,BorderLayout.CENTER);
          
          
          button.addActionListener(new ActionListener() {
     
                public void actionPerformed(ActionEvent e)
                {
                    //Execute when button is pressed
                      brain ob= new brain();
                  ob.main();
                }
            });      
     
          
        }
    
    }
    The PROBLEM - ob.main() - calls a method which allows the user to enter certain values in the terminal window of BlueJ using the scanner class. However this does not happen. Although the terminal window opens, after that Blue J simply hangs.
    So the question - Is it not possible to run JFrame and work in the terminal window at the same time? And, if it is possible, then can you please fix my code? (btw. i know setSize() isn't a good method)

    Any Help Would Heartily Appreciated ;
    Thanking You.
    Erroreport.
    Last edited by erroreport; 10-23-2012 at 09:48 AM.

Similar Threads

  1. Reparent X11 window on a JFrame or a JPanel?
    By paranoia25 in forum Advanced Java
    Replies: 3
    Last Post: 08-06-2012, 10:43 AM
  2. Only one Jframe window will be opened at time
    By Zamioculcas in forum New To Java
    Replies: 4
    Last Post: 05-29-2011, 01:08 PM
  3. Java - Error in terminal window
    By cvillejin in forum New To Java
    Replies: 3
    Last Post: 04-01-2011, 08:03 PM
  4. JFrame(window) not displaying at all
    By mojisolaowoeye in forum AWT / Swing
    Replies: 1
    Last Post: 07-02-2010, 01:03 PM
  5. Replies: 5
    Last Post: 05-25-2009, 09:03 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
  •