Results 1 to 20 of 36
- 05-25-2010, 02:34 PM #1
Member
- Join Date
- May 2010
- Posts
- 20
- Rep Power
- 0
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
- 05-25-2010, 02:40 PM #2
1) How to Use CardLayout (The Java™ Tutorials > Creating a GUI With JFC/Swing > Laying Out Components Within a Container)
2) How to Use Buttons, Check Boxes, and Radio Buttons (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)
3) Lesson: Basic I/O (The Java™ Tutorials > Essential Classes)Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
The Ubiquitous Newbie Tips
- 05-25-2010, 03:35 PM #3
Member
- Join Date
- May 2010
- Posts
- 20
- Rep Power
- 0
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 :-?
- 05-25-2010, 04:11 PM #4
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
- 05-25-2010, 05:18 PM #5
Member
- Join Date
- May 2010
- Posts
- 20
- Rep Power
- 0
: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.
- 05-25-2010, 09:33 PM #6
Senior Member
- Join Date
- Mar 2009
- Location
- USA
- Posts
- 127
- Rep Power
- 0
Use inner frame....if you want to dont want different frame to pop up upon activating the event listener.
- 05-26-2010, 06:48 AM #7
Member
- Join Date
- May 2010
- Posts
- 20
- Rep Power
- 0
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
- 05-27-2010, 05:38 AM #8
Member
- Join Date
- May 2010
- Posts
- 20
- Rep Power
- 0
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 ?
- 05-27-2010, 01:14 PM #9
: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
- 05-28-2010, 08:49 AM #10
Member
- Join Date
- May 2010
- Posts
- 20
- Rep Power
- 0
- 05-28-2010, 09:28 AM #11
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
- 05-28-2010, 09:33 AM #12
Member
- Join Date
- May 2010
- Posts
- 20
- Rep Power
- 0
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 ?
- 05-28-2010, 09:51 AM #13
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
- 05-28-2010, 09:56 AM #14
Member
- Join Date
- May 2010
- Posts
- 20
- Rep Power
- 0
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
- 05-28-2010, 10:07 AM #15
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
- 05-28-2010, 10:18 AM #16
Member
- Join Date
- May 2010
- Posts
- 20
- Rep Power
- 0
ah, ok. Let's see what i can do. ^^
if im really stuck, i will trouble you again (_ _")
- 05-28-2010, 10:25 AM #17
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
- 05-28-2010, 10:26 AM #18
Member
- Join Date
- May 2010
- Posts
- 20
- Rep Power
- 0
thanks a lot. i will try all possibilities :)
- 05-29-2010, 01:19 PM #19
Member
- Join Date
- May 2010
- Posts
- 20
- Rep Power
- 0
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,2147So, how do i separate the info from output to get the clientID and address ? and where do i store them ?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(); } }
I tried to use String.split() but didn't work out well :confused:
- 05-30-2010, 08:13 PM #20
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
Similar Threads
-
How to make a Jframe un-focusable when another Jframe is active?
By Robert_85 in forum Advanced JavaReplies: 4Last Post: 04-22-2009, 11:02 PM -
To get the current active window`s path using Windows API
By jihadrh in forum Advanced JavaReplies: 8Last Post: 12-01-2008, 02:07 PM -
Close Active Window (?)
By dcnorman07 in forum New To JavaReplies: 2Last Post: 10-03-2008, 05:55 PM -
Changing Active Window
By jmHoekst in forum New To JavaReplies: 1Last Post: 06-14-2008, 12:21 AM -
How to close an open JFrame window from a jsp page?
By kasisaiganesh in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 05-27-2008, 06:29 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks