Page 1 of 2 12 LastLast
Results 1 to 20 of 36
  1. #1
    Jkiller295 is offline Member
    Join Date
    May 2010
    Posts
    20
    Rep Power
    0

    Default How do i open JFrame in the same active window

    Hello, I'm new to java and I'm having a project for school. Required to do design a waste collecting system which take in weight and print invoice to text file.

    So my 1st question is:
    How do I open JFrame, one after another, in the same active window ?
    for example
    this is the startup page

    then, when click on New Collection, it will appear this frame

    in the same window.
    This must be applied for the rest.

    2nd question:
    How can I display the data from button onto textfield ?

    3rd question:
    From the data in textfield, how can I export to a text document ?

    Thanks for all the helps in advanced

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    6

  3. #3
    Jkiller295 is offline Member
    Join Date
    May 2010
    Posts
    20
    Rep Power
    0

    Default

    Hey PhHein, thanks for replying.
    but i have a problem with q2, the link u gave does not mention about textfield.
    for example, when i click add Generic bin, a small frame appear with number buttons, i will click to choose the weight, then it will be displayed in the textfield in screenshot 2.

    and another thing, can i use a JLabel as a button ? because in the project demonstration, the 2 buttons Cancel and Confirm has 2 different colors :-?

  4. #4
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    6

    Default

    I don't really get you. I don't see any screenshots. Imageshack is blocked by the firewall.
    TextFields:
    How to Use Text Fields (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)

    Uhm, you can set the colors of a JButton. What's wrong with that?
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  5. #5
    Jkiller295 is offline Member
    Join Date
    May 2010
    Posts
    20
    Rep Power
    0

    Default

    :confused::confused: i will scan the project doc and post here tmr so u can understand clearly what i'm saying, since my english is very bad, it's quite difficult to explain something complex.

  6. #6
    Aseem is offline Senior Member
    Join Date
    Mar 2009
    Location
    USA
    Posts
    127
    Rep Power
    0

    Default

    Use inner frame....if you want to dont want different frame to pop up upon activating the event listener.

  7. #7
    Jkiller295 is offline Member
    Join Date
    May 2010
    Posts
    20
    Rep Power
    0

    Default

    what's the difference between cardlayout and inner frame ??
    project_java.zip - File Shared from Box.net - Free Online File Storage
    here is the project, i scanned with my old scanner, so quite blur :P
    please give me the guide logic so i won't beat around the bush :P
    thanks

  8. #8
    Jkiller295 is offline Member
    Join Date
    May 2010
    Posts
    20
    Rep Power
    0

    Default

    Guys, i have a JTextArea with dimension 289x92
    how do i make the scrollbar appears when the textarea is full, in order to see the lowest text ?

  9. #9
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    6

    Default

    :mad: And how does that help JKiller? Why are you trying to hijack this thread? Start a new thread and follow the link in my signature.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  10. #10
    Jkiller295 is offline Member
    Join Date
    May 2010
    Posts
    20
    Rep Power
    0

    Default

    Quote Originally Posted by Jkiller295 View Post
    Guys, i have a JTextArea with dimension 289x92
    how do i make the scrollbar appears when the textarea is full, in order to see the lowest text ?
    help T_T

  11. #11
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    6

    Default

    Add the JTextArea to a Jscrollpane. Have a look at the tutorials for examples.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  12. #12
    Jkiller295 is offline Member
    Join Date
    May 2010
    Posts
    20
    Rep Power
    0

    Default

    thanks. i made a stupid mistake with the scroll pane, instead of using setBounds for the scroll pane, i used it for the textArea, that's why my scroll pane does not work :(
    now it's fine.
    alright can u help me 1 last thing. my teacher gave us the client address list which is in .csv extension. i need to take in all the address, put them in a comboBox and only the street name is displayed. the client's name will appear according to the address :confused::confused:
    how do i do that ?
    Attached Files Attached Files

  13. #13
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    6

    Default

    There are two csv files. How do they relate? Which one goes into the Combobox?
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  14. #14
    Jkiller295 is offline Member
    Join Date
    May 2010
    Posts
    20
    Rep Power
    0

    Default

    in the Clients.csv file, column A will be the clientID,
    in the Addresses.csv file, column B will use the clientID in Clients.csv file to indicate which address belongs to which clientID. 1 client can have many addresses. For instance, clientID 1 will have 3 addresses:
    12 Bowman St
    56 Alt St
    22 Harwood St

  15. #15
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    6

    Default

    Ah, ok. That's not quite simple. An approach depends on what you want to do later. If that's all there is, create two classes Adress and Client. Read both files and create Client and Address objects and add them to two different Lists. The address List is used to fill a ComboBoxModel. Use a ListCellRenderer to display a reasonable address format, or override the toString() method of Address.
    Add an ItemListener to the Combobox and retrieve the Client data from the client List for the selected Adddess. Done.
    This will take a while for you to get done.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  16. #16
    Jkiller295 is offline Member
    Join Date
    May 2010
    Posts
    20
    Rep Power
    0

    Default

    ah, ok. Let's see what i can do. ^^
    if im really stuck, i will trouble you again (_ _")

  17. #17
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    6

    Default

    Good luck. BTW: for the clients a Map might be better than a List.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  18. #18
    Jkiller295 is offline Member
    Join Date
    May 2010
    Posts
    20
    Rep Power
    0

    Default

    thanks a lot. i will try all possibilities :)

  19. #19
    Jkiller295 is offline Member
    Join Date
    May 2010
    Posts
    20
    Rep Power
    0

    Default

    i need help again :)
    This is what i did to read the data from client.csv file.
    It works, but gave me the output like
    1,1,12,Bowman St,Seven Hills,2147
    2,1,56,Alt St,Seven Hills,2147
    3,2,88,Barnstaple Rd,Seven Hills,2147
    4,2,21,Bay St,Seven Hills,2147
    5,3,36,Bay St,Seven Hills,2147
    PHP Code:
    import java.io.*;
    public class Client
    {
    	public static void main(String []args) throws IOException
    	{
    		FileReader fr = new FileReader("Addresses.csv");
    		BufferedReader br = new BufferedReader(fr);
    		while(true)
    		{
    			String line = br.readLine();
    			if(line == null)break;
    			System.out.println(line);
    		}
    		br.close();
    	}
    }
    So, how do i separate the info from output to get the clientID and address ? and where do i store them ?
    I tried to use String.split() but didn't work out well :confused:

  20. #20
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    6

    Default

    What part of: "create two classes Adress and Client" didn't you understand? String.split() works fine. Post what you've tried with split()
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 4
    Last Post: 04-22-2009, 11:02 PM
  2. Replies: 8
    Last Post: 12-01-2008, 02:07 PM
  3. Close Active Window (?)
    By dcnorman07 in forum New To Java
    Replies: 2
    Last Post: 10-03-2008, 05:55 PM
  4. Changing Active Window
    By jmHoekst in forum New To Java
    Replies: 1
    Last Post: 06-14-2008, 12:21 AM
  5. How to close an open JFrame window from a jsp page?
    By kasisaiganesh in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 05-27-2008, 06:29 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
  •