Results 1 to 10 of 10

Thread: GUI problem

  1. #1
    kanmi is offline Member
    Join Date
    Nov 2010
    Posts
    7
    Rep Power
    0

    Default GUI problem

    pls help
    this code is working in commmand dos but how can i display the result in GUI

    import java.util.Scanner;
    public class arbitrary
    {
    public static void main (String [] args)
    { double count=0;
    for (count = -1; count<=2;count=count+0.1)
    { System.out.println(count);}}}

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,305
    Rep Power
    20

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,305
    Rep Power
    20

    Default

    Don't double post
    pls help

    db

  4. #4
    kanmi is offline Member
    Join Date
    Nov 2010
    Posts
    7
    Rep Power
    0

    Default listbox and textbox not working with numbers

    using textbox and lisbox to display integer number is givin error what can i use

  5. #5
    kanmi is offline Member
    Join Date
    Nov 2010
    Posts
    7
    Rep Power
    0

    Default THE TEXTBOX IS ONLY DISPLAYING THE LAST NUMBER for the result.how can i see other num

    THE TEXTBOX IS ONLY DISPLAYING THE LAST NUMBER for the result.how can i see other numbers. thanks
    //MAIN CLASS:

    import javax.swing.JFrame;
    public class arbitrarymain
    {
    public static void main (String args [])
    {
    arbitrary arbitrary1 = new arbitrary();
    arbitrary1.setSize(400,120);
    arbitrary1.setVisible(true);
    }}


    //SUB CLASS:
    import java.awt.FlowLayout;
    import javax.swing.JFrame;
    import javax.swing.JTextField;
    import javax swing.JLabel;

    public class arbitrary extends JFrame
    {
    private JTextField textfield1;
    private JLabel label1;
    double count;
    public arbitrary()
    {
    super("ARBITRARY");
    {
    setLayout(new FlowLayout());
    textField1=new JTextField(10);
    label1 = new JLabel("result");
    add(label1);
    add(textfield1);


    for(count=-1;count<=2;count=count+0.1)
    {
    textfield1.setText(" "+count);}}}}

  6. #6
    javaman1 is offline Member
    Join Date
    Sep 2010
    Posts
    56
    Rep Power
    0

    Default

    Look at your code closely. You are resetting the data in the text field every time you iterate the for loop. You have to create multiple text fields or put all of the text into a JPanel with JLabels. And please enclose your code in [code*] and [/code*] tages without the asterisks.

    AB
    Last edited by javaman1; 11-17-2010 at 08:14 PM.

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

    Default

    You can put all the text in a single JTextField, but you have to extract the String already in the JTextField with getText(), append new information to it, and then set the JTextField text with the setText(String text) method.

  8. #8
    kanmi is offline Member
    Join Date
    Nov 2010
    Posts
    7
    Rep Power
    0

    Default

    >>>>Look at your code closely. You are resetting the data in the text field every time you iterate the for loop. You have to create multiple text fields or put all of the text into a JPanel with JLabels. And please enclose your code in [code*] and [/code*] tages without the asterisks.

    Javaman1, but we're talking of just only one for (control) while did you say every time you iterate the for loop?
    Also, what did you mean by [code*] and [/code*].Please can you explain this parallel?

  9. #9
    kanmi is offline Member
    Join Date
    Nov 2010
    Posts
    7
    Rep Power
    0

    Default

    >>>You can put all the text in a single JTextField, but you have to extract the String already in the JTextField with getText(), append new information to it, and then set the JTextField text with the setText(String text) method.

    fubarable, we are dealing with integers/double not string or is there any corellation?
    Any way we've try to amends changes but no show!

  10. #10
    kanmi is offline Member
    Join Date
    Nov 2010
    Posts
    7
    Rep Power
    0

    Default

    It seems this has no solution or is there?
    Pls for any other suggestion from any one, can you kindly write the code out.

    db:Thank you for your post but we can't find it there.Promise not to double post, i did it out of curiosity thanks.

Posting Permissions

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