Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: need help with this new problem

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    19
    My Mood
    Fine
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default need help with this new problem

    actually i hav been posting a question about JTextField which no buddy hav yet understood...
    but i now i have image about my problem
    actually i want my display to be this (don't car about JFrame size) :-
    Capture.jpg
    but instead this is what comes up instead :-
    Capture.jpg
    here is the code (didn't mentioned the imported packages here ) :-
    public class TextField1 extends JApplet implements ActionListener 
       {
        JTextField Input;
        public JFrame Panel = new JFrame("A. God");
        JTextField sonar;
        public JButton button1 = new JButton("Enter");
        LayoutManager Layout;
        public TextField1 () {
        Panel.setSize(500,500);
     
        sonar = new JTextField();
        sonar.setLocation(0, 40);
        sonar.setSize(100, 30);
     
        Panel.add (sonar);
        Input = new JTextField ("", 20); 
     
        Layout = new FlowLayout ();
     
        sonar.setEditable (false);
        Input.setBackground (Color.white);
        Input.addActionListener (this);
        Panel.setLayout (Layout);
     
     
        Panel.add (Input); Panel.add(button1);
     
        Panel.setVisible(true);
        }
        public void actionPerformed (ActionEvent e) {
         sonar.setText (Input.getText());
         Input.setText("");
         if (e.getSource() == button1)
           {
               sonar.setText (Input.getText());
               Input.setText("");          
       }
        }
       }

    Plz help
    Regards
    Last edited by n00b; November 3rd, 2011 at 07:10 AM.


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: need help with this new problem

    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Oct 2011
    Posts
    19
    My Mood
    Fine
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: need help with this new problem

    I already know that but i want a chatbox-like layout which is not there please can ugive me the code for it please

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: need help with this new problem

    Quote Originally Posted by n00b View Post
    I already know that but i want a chatbox-like layout which is not there please can ugive me the code for it please
    That's not how this works. Asking for code, especially without bothering to use correct spelling or grammar, is extremely rude. Don't do it again.

    The layouts aren't going to be called "chatbox-like" or anything like that. They're simpler and more modular, and you have to use them in the correct combination to achieve your goal. You have to get into the habit of seeing components as a collection of JPanels laid out in certain layouts .

    For starters, your layout looks like a horizontal BoxLayout inside the NORTH section of a BorderLayout.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    Junior Member
    Join Date
    Oct 2011
    Posts
    19
    My Mood
    Fine
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: need help with this new problem

    Oops sorry about it , will remember it
    Thank you for the help

Similar Threads

  1. Replies: 3
    Last Post: January 5th, 2012, 01:44 AM