Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,210,671 members, 8,009,619 topics. Date: Friday, 22 November 2024 at 12:57 AM |
Nairaland Forum / Science/Technology / Programming / Java Programming For Dummies (41068 Views)
Programming For Dummies. / Vb.net For Dummies: / Vb.net For Dummies: (2) (3) (4)
(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (Reply) (Go Down)
Re: Java Programming For Dummies by sbucareer(f): 10:17pm On Mar 28, 2006 |
Skima, give me April ending that is when I will finish my contract at where I am working now I will be in London at the end of the April I will send you all the software and even more goodies I have for you for the delay. Please bear with me. Here is how it would look like when you run it now. Watch out the above code as I keep updating it. No need to waste space by reposting it again.
|
Re: Java Programming For Dummies by sbucareer(f): 11:56pm On Mar 28, 2006 |
Now I have managed to layout the Java containers in using few Layout Managers. You can tweak the code to see if it behave differently. That is the only way to learn by messing the code up and trying to debug it yourself. Anyway I am done with the LagosRadioView.java class. Not that the UI is very good but at least we can carry on with the tutorial. You can modify it and come up with a good UI that is better than mine. I challenge you! I will be concentrating on the LagosRadioController.java where the action is. This class will capture all the button events and process them i.e. increase volume, decrease volume and change the frequency. Because we have registered the buttons and textArea component in LagosRadioView class using addActionListener and addDocumentListener we can now write code in the actionPerformed method in LagosRadioController class and update the TextArea by incrementing the value when the + is pressed and decrease it when the - is also pressed by using the three methods insertUpdate, changedUpdate and removeUpdate |
Re: Java Programming For Dummies by sbucareer(f): 8:59am On Mar 29, 2006 |
When you run the LagosRadioController.java, you are offered with two choices, one is to run the java as Application or the other one as an Applet. If you'd choose applet go to the radio package directory and edit RadioLagosController.html to this values highlighted in red below: <html> <head> <title> The LagosRadioController applet </title> </head> <body> <h2> Here is the LagosRadioController applet </h2> <hr> <applet code="LagosRadioController.class" width="440" height="500"> </applet> <hr> </body> </html> if you want to put LagosRadioController.html on a different directory i.e c:\LagosRadioController.html and your radio package is in c:\temp\radio\*.java then this is what you do my editing this section of the html code <applet code="temp.radio.LagosRadioController.class" width="440" height="500"> |
Re: Java Programming For Dummies by sbucareer(f): 9:45am On Mar 29, 2006 |
Now for the assignment, I want people that are still interested in this thread and are doing there homework like Skima for example to do the following assignment by the end of next week. Assignment requirements ========================= 1. A UI diagram of proposed LagosTemperature 2. A Layout Management Diagram of LagosTemperature 3. A View class to model the LagosTemperatureView 4. A Controller class to model the LagosTemperatureController When I see a reasonable solutions uploaded here I will continue to the next stage of the tutorial, which is Exception handling and Concurrency in Java using few of the java API like Thread class and the Runnable interface. After that we will go into Sockets class and Networking connections with a case study of writing chat application using our UI skills. Towards the end, we will then look into JDBC, which is to do with relational database and how java provide a bridge to ODBC by using JDBC. We will conclude with a GUI case study on how to write a java application to store and record a call logger system using Access Database as our persistent storage. Good luck. |
Re: Java Programming For Dummies by gbengaijot(m): 11:50am On Mar 29, 2006 |
m |
Re: Java Programming For Dummies by skima(m): 5:13pm On Mar 29, 2006 |
Okay sir. I will do it. I just downloaded this tutorial which i will study offline and then proceed with my assignment. Thanx SBU. |
Re: Java Programming For Dummies by Papa(m): 2:46pm On Apr 04, 2006 |
Ok, I know that this topic is called "Java for dummies right" so here's some problem solving for dummies, Who would love to help? write a program, called RomanNumerals.java, to convert the Roman Numerals representation of a year into its decimal representation. Below is the table of Roman Numerals you recall from High School (For more information on Roman Numerals see http://en.wikipedia.org/wiki/Roman numerals). Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 Your convertor must convert a number in Roman Numerals representation in the range I - MMM to its decimal number representation. Also, you know that your laptop might only be able to handle one execution of your program. You therefore must ensure that your program will continue prompting for a Roman Numeral to convert until you enter 0, which will cause your program to terminate. Example You input the year CCLIX (the year in roman numerals), the program then displays 259 (the year in decimals). You then wish to terminate the program so you enter 0 as the second Roman numeral. Sample Run Enter a Roman Numeral: CCLIX The year in Decimals is: 259 Enter a Roman Numeral: 0 |
Re: Java Programming For Dummies by sbucareer(f): 11:22am On Apr 05, 2006 |
Sorry boys I was sent to Belgium for three days seminar by my company, that is why there was a silent. Anyway I am back. Papa, this is final year students work at university level. At most ending of second year semester at higher education. These newbies needs to understand API,s and general programming language syntax before solving this complex mathematical assignment. Remember most programmers are not mathematicians and would find this analytical problem challenging. It does not make them incompetent or less intelligent. Just as a web designer can produce a complex web page presentation without a mathematic skill to a graphic designer who has very strong mathematical skill and still produce the same quality of presentation view. Point is, the assignment is too hard for them now. After getting the nitty-gritty of programming then, the brave onces can attempt this solution. Remember before you start this papa assignment, you need to have solved the mathematical equivalent solution. You need to use pen and paper and try to convert decimal to Roman numeral and vise-versa. Papa if you want to help them, provide a mathematical solution to the problem and leave them with the task of writing the programming equivalent code. |
Re: Java Programming For Dummies by Papa(m): 5:05pm On Apr 05, 2006 |
sbucareer, Maybe I should put it this way, it's a challenge to me as well, is there a way you can assist me? I want to challenge my mind. I will be asking you many questions like this often. That's how I challenge my programming skills; and when it gets too tough, I'll come to people like you for help. |
Re: Java Programming For Dummies by romeo(m): 10:04pm On Apr 05, 2006 |
romeo it's time to learn with fellow naija bros, great work mate!!! |
Re: Java Programming For Dummies by sbucareer(f): 9:49am On Apr 06, 2006 |
Oky, let take a case study of converting numbers to words Sometimes we need to write numbers in words. For example, to fill out a cheque or a cash transfer. We need to design a function convert6 that takes an integer n drawn from a given range, say greater than zero and less than one million, and returns a list of characters corresponding to the usual English formulation of the whole number n. For Example: ? convert6 459213 four hundred and fifty-nine thousand two hundred and thirteen. The first question you ask yourself is how do I start this complex mathematical solution? Well, wee need to understand it mathematical paradigm first before going into programming it. To solve this start by solving the smallest task by employing a technique that I was taught at university by Mr Clive Hayton a senior lecturer at School of Information Systems and Mathematic, called Divide and conquer Divide the tasks into smaller solvable units and add them up to form a big complex solution called conquer. Here, Start by solving the problem for all input < 10 Extend your design to solve the problem for all input < 100 Extend your design to solve the problem for all input < 1000 Extend your design to solve the problem for all input < 10000 Example convert6 3 three convert6 11 eleven convert6 30 thirty convert6 97 ninety-seven convert6 125 one hundred and twenty-five convert6 1000 one thousand convert6 286000 two hundred and eighty-six thousand convert6 260006 two hundred and sixty thousand and six convert6 is a function, i.e. f:x --> x + 2 which means the function f takes an input x and produces an output x + 2. In the above convert6 take an input say n where n is integer and produce English word equivalent. Example if n is applied to to function convert6 as an input the resultant would be Three, where n = 3. |
Re: Java Programming For Dummies by sbucareer(f): 10:05am On Apr 06, 2006 |
Now that we have seen how to divide complex task into smaller units we will go on to solve the problem. The function units returns the English name for the one digit numbers. units :: Int --> String convert1 = units Example units 1 = "one" units 2 = "two" units 3 = "three" units 4 = "four" units 5 = "five" units 6 = "six" units 7 = "seven" units 8 = "eight" units 9 = "nine" The function tens returns the English name for those two digit numbers which are multiples of ten. tens :: Int --> String tens 1 = "ten" tens 2 = "twenty" tens 3 = "thirty" tens 4 = "forty" tens 5 = "fifty" tens 6 = "sixty" tens 7 = "seventy" tens 8 = "eighty" tens 9 = "ninety" Similarly, the function teens returns the English name for the numbers in range eleven to nineteen. teens :: Int --> String teens 1 = "eleven" teens 2 = "twelve" teens 3 = "thirteen" teens 4 = "fourteen" teens 5 = "fifteen" teens 6 = "sixteen" teens 7 = "seventeen" teens 8 = "eighteen" teens 9 = "nineteen" |
Re: Java Programming For Dummies by sbucareer(f): 10:23am On Apr 06, 2006 |
The function convert2 returns the English name of any number n in the range 0 < n < 100. For example: convert2 31 returns thirty-one convert2 :: Int -> String digit2 :: Int -> (Int, Int) convert2 n = combine2 (digit2 n) digit2 n = (n div 10, n mod 10) In the above example we realise that n from 0 < n < 10 and uses mod a mathematical operator that checks if dividing n/2 will produce a remender. here, The definition of combine2 is: combine2 :: (Int, Int) -> String combine2 (t,u) | t == 0 = units u | u == 0 = tens t | t == 1 = teens u | otherwise = tens t ++ "-" ++ units u The function convert3 returns the English name of any number n in the range 0 < n < 1000. For example: ? convert3 102 one hundred and two convert3 :: Int -> String digit3 :: Int -> (Int, Int) convert3 n = combine3 (digit3 n) digit3 n = (n div 100, n mod 100) The definition of combine3 is: combine3 :: (Int, Int) -> String combine3 (h,t) | h == 0 = convert2 t | t == 0 = units h ++ " hundred" | otherwise = units h ++ " hundred and" ++ convert2 t The function convert6 returns the English name of any number n in the range 0 < n < 1,000,000. For example: convert6 308000 three hundred and eight thousand convert6 :: Int -> String digit6 :: Int -> (Int, Int) Convert6 n = combine6 (digit6 n) digit6 n = (n div 1000, n mod combine6 :: (Int, Int) -> String combine6 (m, h) | m == 0 = convert3 h | h == 0 = convert3 m ++ " thousand" | otherwise = (convert3 m) ++ " thousand" ++ link h ++ convert3 h link h | h < 100 = " and " | otherwise = " " 1000) |
Re: Java Programming For Dummies by sbucareer(f): 10:49am On Apr 06, 2006 |
From the above example you can deduce your own solution to papa assignment. The assignment is similar to this one if not the same, just convert the English word to Romans Numerals For people using Java store your Roman Numerals in a Collection framework like HashMap to store your Roman Numerals i.e. String [] romansNumerals= {"I", "II", "II", "IV", "V", "VI", "VII", "VIII", "IX", "X", "L", "C", "M", ""}, Use for loop to add it into a collection framework like HashMap API. HashMasp units = new HashMap(); for( int index = 0; index < romanNumerals.lenght(); index++ ){ units.put(romanNumerals[index], romanNumerals[index]); }//End for loop , In your functions i.e convert1, convert2, convert3, etc, that is where you will use your units object above. good luck, people. |
Re: Java Programming For Dummies by sbucareer(f): 12:42pm On Apr 07, 2006 |
What has happened to all my students, especially Skima, are you upset with me regarding the DVD? I have promised to DHL it to you on 14-04-06 come rain or sun. Gbenga, where are you? Nairaland where is everybody? Do you want me to stop the thread? It would be a shame. I need the assignment latest by weekend. Just show what you have done. Even if you have only done the diagrams, we will work together to build your LagosTemperature class. |
Re: Java Programming For Dummies by gbengaijot(m): 1:25pm On Apr 07, 2006 |
SBU, i am struggling on my knees to get on, i am very busy, am right behind. on temperature classsess. trying to draw the diagram. i sent u an email sometimes ago didnt knw if you get it or not. |
Re: Java Programming For Dummies by sbucareer(f): 1:34pm On Apr 07, 2006 |
Gbenga, you know I live in London and I know how the system works. Believe me Gbenga, you do NOT work anymore harder than I do. Still I have time to response to all my online and virtual news group and forum messages. The thing is that, I know we are all busy especially when you live in developed world, time is NEVER your friend. I understand your undertakings, but!! you still can find time and do some work. It is for your interest assuming you seriously want to learn Java. I work 18hrs a day, Monday to Friday, weekend I do teaching for 12hrs and yes I go to church on Sunday. You know Nigerian Churches in the UK, if they have not cast that demon out of people they will not finish the service. I do this every week, month, year for the past 6 years now. Tell me if you are more busier than me? |
Re: Java Programming For Dummies by gbengaijot(m): 2:20pm On Apr 07, 2006 |
. |
Re: Java Programming For Dummies by skima(m): 10:42pm On Apr 08, 2006 |
@SBU, i have designed it on paper i only need to get it into coding. I promise this monday (10), i have to suspend all other projects to get it done. I will submit it. @upset no no no no, i understand u. There still more for me to gain than getting upset by that. afterall am carrying on with the resources i have with me. I read the thread but i didnt see that comment u made. I only saw the number calculation |
Re: Java Programming For Dummies by skima(m): 12:02pm On Apr 10, 2006 |
My assignment:
|
Re: Java Programming For Dummies by skima(m): 12:03pm On Apr 10, 2006 |
second
|
Re: Java Programming For Dummies by sbucareer(f): 1:05pm On Apr 10, 2006 |
Wow!!! Excellent, Skima you are a guru, when I was learning I was not this good. Good work. I am very much impressed with your Visual diagram and Layout Management diagram. I would be looking forward to seeing the code behind this beautiful UI. Well done Skima. You choice of BorderLayout and Border Managers is wise. The diagram depicted what your UI was telling. Goooooood work, Skima. Change the JLable in the NORTH panel from JLabel to Image. i.e. Image:icon Use this example Image displayImage; displayImage = Toolkit.getDefaultToolkit().getImage("skima.jpg" JPanel panel = new JPanel(); panel.setLayout (new BorderLayout() ); panel.add ( BorderLayout.NORTH, displayImage ); Use this example |
Re: Java Programming For Dummies by Warray: 9:21pm On Apr 16, 2006 |
Hey SBU, I have just joined this website and thats because I just got to know about it, I mean, I dont know how to commend u on what u are doing, U are doing far more than a great job, I mean, this is what we pay so much money to learn and we still dont get it. I know I am real late on these your tutorials but I am in a JAVA class right now and I aint learning a DANG thing, I added u on my MSN so I can ask u for help if u are willing to offer. I really need to get with the JAVA programming. I can understand a few of what u are teaching but its slightly different from what I am being taught, I want to keep in touch and ask u for help from time to time if its all good, |
Re: Java Programming For Dummies by skima(m): 7:58pm On Apr 17, 2006 |
How about those books/software today is 17/04/2006 I have a problem with my assignment. This is the code below /** * @(#) LagosTemperatureView.java */ package temperature; import javax.swing.*; import javax.swing.event.DocumentListener; import java.net.URL; import javax.swing.ImageIcon; import java.awt.BorderLayout; import java.awt.Component; import java.awt.GridLayout; import java.awt.FlowLayout; import java.awt.event.ActionListener; /** * @author Skima * */ public class LagosTemperatureView { private ActionListener listener; private DocumentListener documentListener; private ImageIcon Image1; private JPanel rootPanel; private JPanel rootPanelTop; private JPanel rootPanelMiddle; private JPanel rootPanelDown; private JTextField firstBox; private JTextField secondBox; private JButton firstPlus; private JButton secondPlus; private JButton firstMinus; private JButton secondMinus; private JLabel labelIcon; public LagosTemperatureView(ActionListener listener, DocumentListener documentListener){ Image1 =createImageIcon("images/temp_app.gif" JLabel celsius=new JLabel("Celsius" JLabel farheneit=new JLabel("Farheneit" JLabel lagTemp=new JLabel("Lagos Temperature is Hot" this.listener = listener; this.documentListener = documentListener; //this.setLayout(new BorderLayout()); //lets divide the root panel for easy placement. rootPanel = new JPanel(); //we are making it grid layout and setting rootPanel.setLayout (new GridLayout(5,1,2,2) ); rootPanelTop =new JPanel(); rootPanelMiddle=new JPanel(); rootPanelDown=new JPanel(); rootPanelTop.setLayout(new FlowLayout()); rootPanelMiddle.setLayout(new GridLayout(2,4,2,2)); rootPanelDown.setLayout(new FlowLayout()); labelIcon.setIcon(Image1); labelIcon.setText("" rootPanelTop.add(labelIcon); rootPanel.add(rootPanelTop); rootPanelMiddle.add(firstBox); rootPanelMiddle.add(firstPlus); rootPanelMiddle.add(firstMinus); rootPanelMiddle.add(celsius); rootPanelMiddle.add(secondBox); rootPanelMiddle.add(secondPlus); rootPanelMiddle.add(secondMinus); rootPanelMiddle.add(farheneit); rootPanel.add(rootPanelMiddle); rootPanelDown.add(lagTemp); rootPanel.add(rootPanelDown); } protected static ImageIcon createImageIcon(String path) { java.net.URL imageURL = LagosTemperatureView.class.getResource(path); if (imageURL == null) { System.err.println("Resource not found: " + path); return null; } else { return new ImageIcon(imageURL); } } public static void main(String arg[]){ JFrame frame=new JFrame("Lagos Temperature" JFrame.setDefaultLookAndFeelDecorated(true); LagosTemperatureView cont=new LagosTemperatureView( ); frame.getContentPane().add(cont); frame.pack(); frame.setLocation(400,100); frame.setSize(400,500); frame.setVisible(true); } } |
Re: Java Programming For Dummies by skima(m): 12:32pm On Apr 18, 2006 |
/** *@(#)LagosTemperatureController.java */ package temperature; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import javax.swing.event.DocumentListener; import javax.swing.event.DocumentEvent; import javax.swing.JFrame; import LagosTemperatureView; /** * @author Skima * */ public class LagosTemperatureController extends JFrame implements ActionListener, DocumentListener { private LagosTemperatureView lagosTemp; public LagosTemperatureController(){ lagosTemp=new LagosTemperatureView(this,this); } public void actionPerformed(ActionEvent e){ } public void changedUpdate (DocumentEvent ev ){ }//End changedUpdate public void insertUpdate (DocumentEvent ev){ }//End insertUpdate public void removeUpdate (DocumentEvent ev ){ }//End removeUpdate public static void main(String arg[]){ JFrame frame=new JFrame("Lagos Temperature" JFrame.setDefaultLookAndFeelDecorated(true); LagosTemperatureController cont=new LagosTemperatureController(); frame.getContentPane().add(cont); frame.pack(); frame.setLocation(400,100); frame.setSize(400,500); frame.setVisible(true); } } |
Re: Java Programming For Dummies by skima(m): 12:38pm On Apr 18, 2006 |
The above code could not compile. |
Re: Java Programming For Dummies by demmy(m): 6:52pm On Apr 18, 2006 |
public void actionPerformed(ActionEvent e) shouldn't that be
|
Re: Java Programming For Dummies by skima(m): 7:08pm On Apr 18, 2006 |
I will try it out and get back to u. Thanks |
Re: Java Programming For Dummies by tju38: 12:16pm On Apr 19, 2006 |
sbucareer, why are you making these guys use Netbeans? Making them use Textpad is just plain evil. Netbeans is a pile of poo (no disrespect to SUN Microsystems, but they are not very good at building commercial software). If your IDE is not IDEA (IntelliJ) or Eclipse, you're causing yourself unneccessary pain. Also, for those of you intending on "making money" out of some programming career, standard Java (J2SE) will not do you much good. What you need to do is learn the industry tools and APIs. For a site built with the full J2EE stack check out http://www.naijamovies.co.uk/site/naijamovies.jsp Peace
|
Re: Java Programming For Dummies by tju38: 12:18pm On Apr 19, 2006 |
What is the point in learning Java Swing? nobody uses it |
Re: Java Programming For Dummies by charlisco(m): 1:12pm On May 01, 2006 |
Please someone should tell me a good websit that teaches everything i need to know about visual basic, i want to download it and brows it offline since my internet connection does not come regularly |
Re: Java Programming For Dummies by pfowighz(m): 5:42pm On Jun 08, 2006 |
And THis was a REALLY nice Thread, whatever happened!!! Anyway, SBuCareer, whether you come back or not, YOU 'VE DONE A GREAT JOB FOR STARTING!!! KEEP IT UP, MA MAN OF STATURE!!! But hoping you guys wud come back OK Cheers!!! |
(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (Reply)
Artificial Intelligence And Machine Learning Group / Facebook Is Suing Me For This / Java Vs PHP: Which Has The Brightest Future?
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 76 |