<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Latest topics for the forum "GUI Development"]]></title>
		<link>http://forums.hotjoe.com/forums/show/14.page</link>
		<description><![CDATA[The newest discussed topics in the forum "GUI Development"]]></description>
		<generator>JForum - http://www.jforum.net</generator>
			<item>
				<title>Event Handling</title>
				<description><![CDATA[ Hi<br /> <br /> I have to do a mortgage program using graphical user interface. The user can input any amount for the principal of the loan and then have three options for a payment plan. The program should display the mortgage payment then list the loan balance and interest paid for each payment over the life of the loan.<br /> <br /> I did the code but there is an event error and I cannot seem to understand why the error is there. The code is attached below. Any assistance would be appreciated.<br /> <br /> <br /> [code]<br /> <br /> import java.text.*;<br /> import java.awt.*;<br /> import java.io.*;<br /> import java.awt.event.*;<br /> import java.lang.Math.*;<br /> import javax.swing.*;<br /> <br /> public class MortgageCalcOptions extends JFrame implements ActionListener{<br /> <br /> 	<br />     //Declare variables & loan array and initialize with values<br />     //Declares the various button, text fields and labels for the calculator.<br />     <br /> 	JButton calculate, clear;       //Declares the calculate and clear data buttons.<br /> 	JTextField tmortgamt, tmortgpmt;           //Declares the text field for the mortgage amount.<br />         JLabel lmortgamt, lmortgage, lmortgpmt, lmortgdetails;     //Declares the label boxes for mortgage amount and mortgage details.<br />         JRadioButton select7, select15, select30;       //Declares the radio buttons to make term and interest rate selections<br />         JScrollPane backpanel;       //List of monthly payments and interest paid per month<br /> <br /> 	<br /> 	java.text.DecimalFormat dec = new java.text.DecimalFormat(",###.00");       //Decimal format<br />         <br />         <br />         int[] mortgtrm = {7, 15, 30};   //Initialises the array for the three different years.<br /> 	double[] mortgir = {5.35, 5.5, 5.75};   //Initialises the array for the three different interest rates.    <br />         double mortgamt = Double.parseDouble(tmortgamt.getText());<br /> <br /> <br />               <br />        //Sets constraints on the lay out of the interface of the calculator.<br />         <br />           public MortgageCalcOptions() {<br /> 			setLayout(new GridBagLayout());<br /> 			GridBagConstraints c = new GridBagConstraints();<br />     <br />         //Creating, formatting and position and orientation of each component on the calculator interface. <br />         //Set the size of the buttons, labels and text fields.<br /> 		<br />                         lmortgamt = new JLabel("Amount   ");<br />                         c.fill = GridBagConstraints.HORIZONTAL;<br />                         c.gridx = 0;<br />                         c.gridy = 0;<br />                         c.gridwidth = 1;<br />                         add(lmortgamt, c);<br />                         <br />                         tmortgamt = new JTextField(15);<br />                         c.fill = GridBagConstraints.HORIZONTAL;<br />                         c.gridx = 1;<br />                         c.gridy = 0;<br />                         c.gridwidth = 3;<br />                         add(tmortgamt, c);<br />                         <br />                         lmortgpmt = new JLabel("Payment   ");<br />                         c.fill = GridBagConstraints.HORIZONTAL;<br />                         c.gridx = 0;<br />                         c.gridy = 3;<br />                         c.gridwidth = 1;<br />                         add(lmortgpmt, c);<br />                         <br />                         tmortgpmt = new JTextField(15);<br />                         c.fill = GridBagConstraints.HORIZONTAL;<br />                         c.gridx = 1;<br />                         c.gridy = 3;<br />                         c.gridwidth = 3;<br />                         add(tmortgpmt, c);<br />                         <br />                         lmortgage = new JLabel("Mortgage Details    ");<br />                         c.fill = GridBagConstraints.HORIZONTAL;<br />                         c.gridx = 0;<br />                         c.gridy = 4;<br />                         c.gridwidth = 1;<br />                         add(lmortgage, c);<br />             <br />                         lmortgdetails = new JLabel("");<br />                         c.fill = GridBagConstraints.HORIZONTAL;<br />                         c.gridx = 0;<br />                         c.gridy = 5;<br />                         c.gridwidth = 1;<br />                         add(lmortgdetails, c);<br />                         <br />                         calculate = new JButton("Calculate");                        <br />                         c.fill = GridBagConstraints.HORIZONTAL;<br />                         c.gridx = 1;<br />                         c.gridy = 6;<br />                         c.gridwidth = 1;<br />                         add(calculate, c);<br />                         <br />                         clear = new JButton("Clear Data");                        <br />                         c.fill = GridBagConstraints.HORIZONTAL;<br />                         c.gridx = 2;<br />                         c.gridy = 6;<br />                         c.gridwidth = 1;<br />                         add(clear, c);<br />             <br />                         backpanel = new javax.swing.JScrollPane();<br />                         backpanel.setPreferredSize(new Dimension(300, 400));<br />                         backpanel.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);<br />                         backpanel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));<br /> 		<br />                         select7 = new JRadioButton("7 Years at 5.35%", false);<br />                         select7.setActionCommand("sel7");<br /> 		<br />                         select15 = new JRadioButton("15 Years at 5.50%", false);<br />                         select15.setActionCommand("sel15");<br /> 		<br />                         select30 = new JRadioButton("30 Years at 5.75%", false);<br />                         select30.setActionCommand("sel30");<br /> <br /> 		<br />                         ButtonGroup group = new ButtonGroup();      //Create button group<br />                         group.add(select7);<br />                         group.add(select15);<br />                         group.add(select30);<br /> <br /> 		<br />         //Creates the event of the buttons calculate and clear data to perform.<br />         //The calculate button will calculate the mortgage payment and the clear data button will.<br />         //allow the user to clear the fields and enter new data.<br />                         <br />                         event a = new event();<br />                         calculate.addActionListener(a); <br />                         clear.addActionListener(a);<br />                         <br />                   }<br /> <br /> 	public void actionPerformed(ActionEvent a) { <br /> <br />                        <br />                 for (int i = 0; i &lt; mortgir.length; i++)<br /> {<br />                 // Formula to calculate one month's mortgage payment<br />                 double mortgpmt = (mortgamt * (mortgir[i]/12/100)) / (1-(Math.pow(1/(1+(mortgir[i]/12/100)),(mortgtrm[i]*12))));<br /> <br />                 // Formula to calculate the total amount paid over life of the loan<br />                 double tottobepd = (mortgtrm[i]*12) * mortgpmt;<br />          <br />                 // Formula to calculate the total interest paid over life of the loan<br />                 double totinttobepd = tottobepd - mortgamt;<br />         <br />                 //Declares and builds additional variables for caluclations<br />                 double mortgbal = mortgamt;<br />                 double balance = tottobepd;<br />                 double intbalance = totinttobepd;<br />                 double mortpdsofar = 0.0;<br />                 double intpaidsofar = 0.0;<br />                 double noofpayments = 0;<br />                 double intpdthismth;<br />         <br />        <br />         //When the calculate button is pressed the payment is calculated and shown in the payment field according to the mortgage plan.<br />         //Also when the clear data button is pressed all fields are set to null.<br /> 		<br />         String arg = event.getActionCommand();<br />         String op = a.getActionCommand();<br />         <br />              <br /> 		if(op.equals("Clear Data")) {<br /> 			tmortgamt.setText(null);<br /> 			tmortgpmt.setText(null);<br /> 			}<br /> <br />                 else if (op.equals("Calculate")) {<br />                 <br />                         if (arg == "sel7"){<br />                             double mortgamt = Double.parseDouble(tmortgamt.getText());<br />                             mortgpmt = (mortgamt * (mortgir[i]/12/100)) / (1-(Math.pow(1/(1+(mortgir[i]/12/100)),(mortgtrm[i]*12))));				<br />                             tmortgpmt.setText(""+ dec.format(mortgpmt));<br />                             lmortgdetails = new JLabel("Payment Number\tLoan Balance\t\tInterest");<br />                             <br />                             //This will start the loop statement and declares formula for loan balance and interest paid<br />                                 while (balance &gt; 0.0){<br /> <br /> 		}	<br />                                 intpdthismth = mortgbal * (mortgir[i]/12/100);<br />                                 mortgbal = mortgbal - (mortgpmt - intpdthismth);<br />                                 mortpdsofar = mortpdsofar + (mortgpmt - intpdthismth);<br />                                 intbalance = intbalance - intpdthismth;<br />                                 intpaidsofar = intpaidsofar + intpdthismth;<br />                                 balance = balance - mortgpmt;<br />                                 noofpayments = noofpayments + 1;<br />                    <br />                                 //Displays the loan balance and interest paid<br />                                 lmortgdetails = new JLabel(noofpayments+"\t\t"+"$" + dec.format(balance)+"\t\t"+"$" + dec.format(intpdthismth));<br />                     <br />                     }<br /> <br />                         if (arg == "sel15"){<br />                             double mortgamt = Double.parseDouble(tmortgamt.getText());<br />                             mortgpmt = (mortgamt * (mortgir[i]/12/100)) / (1-(Math.pow(1/(1+(mortgir[i]/12/100)),(mortgtrm[i]*12))));	<br />                             tmortgpmt.setText(""+ dec.format(mortgpmt));<br />                             lmortgdetails = new JLabel("Payment Number\tLoan Balance\t\tInterest");<br />                             <br />                             //This will start the loop statement and declares formula for loan balance and interest paid<br />                                 while (balance &gt; 0.0){<br /> <br /> 		}	<br />                                 intpdthismth = mortgbal * (mortgir[i]/12/100);<br />                                 mortgbal = mortgbal - (mortgpmt - intpdthismth);<br />                                 mortpdsofar = mortpdsofar + (mortgpmt - intpdthismth);<br />                                 intbalance = intbalance - intpdthismth;<br />                                 intpaidsofar = intpaidsofar + intpdthismth;<br />                                 balance = balance - mortgpmt;<br />                                 noofpayments = noofpayments + 1;<br />                    <br />                                 //Displays the loan balance and interest paid<br />                                 lmortgdetails = new JLabel(noofpayments+"\t\t"+"$" + dec.format(balance)+"\t\t"+"$" + dec.format(intpdthismth));<br /> 			<br />                     }<br />                    <br />                         if (arg == "sel30"){<br />                             double mortgamt = Double.parseDouble(tmortgamt.getText());<br />                             mortgpmt = (mortgamt * (mortgir[i]/12/100)) / (1-(Math.pow(1/(1+(mortgir[i]/12/100)),(mortgtrm[i]*12))));<br />                             tmortgpmt.setText(""+ dec.format(tmortgpmt));<br />                             lmortgdetails = new JLabel("Payment Number\tLoan Balance\t\tInterest");<br />                             <br />                             //This will start the loop statement and declares formula for loan balance and interest paid<br />                                 while (balance &gt; 0.0){<br /> <br /> 		}	<br />                                 intpdthismth = mortgbal * (mortgir[i]/12/100);<br />                                 mortgbal = mortgbal - (mortgpmt - intpdthismth);<br />                                 mortpdsofar = mortpdsofar + (mortgpmt - intpdthismth);<br />                                 intbalance = intbalance - intpdthismth;<br />                                 intpaidsofar = intpaidsofar + intpdthismth;<br />                                 balance = balance - mortgpmt;<br />                                 noofpayments = noofpayments + 1;<br />                    <br />                                 //Displays the loan balance and interest paid<br />                                 lmortgdetails = new JLabel(noofpayments+"\t\t"+"$" + dec.format(balance)+"\t\t"+"$" + dec.format(intpdthismth));<br /> <br />                     }<br />                 <br />                 }<br />             }<br />         }<br />         <br />         <br /> public static void main(String args[]) {<br />       <br />    //Sets the size of the calculator interface window, as well as set a lable for it.<br />    //And allows the user to close the window if so desired.<br />            <br />            <br />            MortgageCalcOptions gui = new MortgageCalcOptions();<br />            gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);<br />            gui.setVisible(true);<br />            gui.setSize(480,600);<br />            gui.setTitle("Mortgage Calculator");<br /> 		<br /> 	}<br /> }<br /> <br /> <br /> [/code]]]></description>
				<guid isPermaLink="true">http://forums.hotjoe.com/posts/preList/3215/4501.page</guid>
				<link>http://forums.hotjoe.com/posts/preList/3215/4501.page</link>
				<pubDate><![CDATA[Fri, 27 Jan 2012 19:34:21]]> GMT</pubDate>
				<author><![CDATA[ dakotasw]]></author>
			</item>
			<item>
				<title>Creating a slang translator</title>
				<description><![CDATA[ Hi,<br /> <br />   I recently had a friends son ( that is learning java on his own) ask me to create a simple sample urban slang translator, and since its been a few years since Ive messed around with java I am running into a problem.  If my memory serves me correct I remember spending hours on a project only to realize all the problems I had were something silly.   Anyhow,  It seems I have gotten close except that my main problem is a big one, I cant seem to get the results returned.  Since he only wants to screw around with turning an application into an app saving me some hours or days would be greatly appreciated. Im sure there is an easier way, but since I've came this far now I am the curious one. Here is where I'm at thus far.<br /> <br /> import java.util.Scanner;<br /> import java.awt.*;<br /> import java.util.*;<br /> <br /> public class Slang<br /> {<br />         public static void main(String[] args)<br />         {<br />             String[][] translateList = {{"a long time", "a minute"},<br />                                         {"opinion", "two cents" },<br />                                             {"dance", "two step"},<br />                                             {"attractive", "all that"},<br />                                             {"leave", "audi"},<br />                                             {"yes", "awe yeah"},<br />                                             {"no", "awe naw"},<br />                                            };<br />                 Scanner scan = new Scanner(System.in);<br />                 System.out.println ( "convert it to slang" );<br />                 String sentence = scan.nextLine();<br />                 String[] input = sentence.split("\\s");<br /> <br />                 for (int x=0; x&lt;input.length; x++)&gt;<br />                 {<br />                     for (int y = 0; y &lt; translateList.length; y++)<br />                         if (input[x].equalsIgnoreCase(translateList[y][0]))<br />                             System.out.println("True");<br />         }<br /> 	}<br /> }]]></description>
				<guid isPermaLink="true">http://forums.hotjoe.com/posts/preList/2871/4145.page</guid>
				<link>http://forums.hotjoe.com/posts/preList/2871/4145.page</link>
				<pubDate><![CDATA[Wed, 27 Jul 2011 17:48:47]]> GMT</pubDate>
				<author><![CDATA[ TFG]]></author>
			</item>
			<item>
				<title>Not a question - for posterity - JComboBox does not drop in large JDialog</title>
				<description><![CDATA[ I've been going nuts over this for several days.  I found the solution without Google's aid (grumble, grumble).  Seems to me like it's worthwhile to record this for posterity.  And although I haven't posted here many times, I think this is a good site, so I figured maybe I could drive some traffic here if is so happens that someone else has the same problem I did.  [b]EDIT[/b] I also posted this here -&gt; [url]http://forums.devshed.com/java-help-9/not-a-question-for-posterity-jcombobox-does-not-drop-in-large-jdialog-822739.html[/url]<br /> <br /> I had the problem where a JComboBox used as a simple drop down (no edit functionality) in a custom dialog would not, um, drop.  It started out only manifesting in Windows.  Then after a bit of thrashing where I eventually replicated it in Linux, it seemed as if it only happened in certain look and feels.  [b]Finally[/b] I narrowed it down to the fact that the drop down would only drop if the bottom of drop down would go below the bottom edge of the window.  The LNF part was driven by the fact that some LNFs are more compact than others, and so hence sometimes items in the drop down would cause the edge to exceed the window size limit.<br /> <br /> Anyway, here's a sample program.  This does [b]not[/b] work properly.  Do [i]not[/i] use this!<br /> [code]<br /> import java.awt.*;<br /> import java.awt.event.*;<br /> import javax.swing.*;<br /> import javax.swing.UIManager.*;<br /> <br /> public class DialogTest implements Runnable, ActionListener {<br />     private JDialog dialog;<br />     private static final String[] items = {"Item1", "Item2", "Item3", "Item4", "Item5", "Item6", "Item7"};<br /> <br />     public DialogTest(String lnf) {<br />         for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {<br />             if (info.getName().equals(lnf)) {<br />                 try {<br />                     UIManager.setLookAndFeel(info.getClassName());<br />                     break;<br />                 } catch (Exception e) {<br />                     e.printStackTrace();<br />                 }<br />             }<br />         }<br />         dialog = new JDialog();<br />         dialog.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);<br />         dialog.setResizable(true);<br />         JButton ok = new JButton("Ok");<br />         ok.addActionListener(this);<br />         JRootPane root = dialog.getRootPane();<br />         root.setDefaultButton(ok);<br /> <br />         root.setLayout(new FlowLayout());<br />         root.add(new JLabel("Try resizing the dialog to see the problem  "));<br />         root.add(new JComboBox(items));<br />         root.add(ok);<br />         dialog.pack();<br />     }<br /> <br />     public void run() {<br />         dialog.setVisible(true);<br />     }<br /> <br />     public void actionPerformed(ActionEvent e) {<br />         System.exit(0);<br />     }<br /> <br />     public static void main(String[] args) {<br />         Runnable r;<br />         if(args.length == 0) {<br />             System.out.println("Try supplying one of these LNFs to see if there's a difference:");<br />             for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {<br />                 System.out.println(info.getName());<br />             }<br />             r = new DialogTest(null);<br />         } else {<br />             r = new DialogTest(args[0]);<br />         }<br />         Thread t = new Thread(r);<br />         t.start();<br />     }<br /> }<br /> [/code]<br /> <br /> The problem?  I was adding content directly to the root pane.  The corrected code which works looks like this:<br /> [code]<br /> import java.awt.*;<br /> import java.awt.event.*;<br /> import javax.swing.*;<br /> import javax.swing.UIManager.*;<br /> <br /> public class DialogTest implements Runnable, ActionListener {<br />     private JDialog dialog;<br />     private static final String[] items = {"Item1", "Item2", "Item3", "Item4", "Item5", "Item6", "Item7"};<br /> <br />     public DialogTest(String lnf) {<br />         for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {<br />             if (info.getName().equals(lnf)) {<br />                 try {<br />                     UIManager.setLookAndFeel(info.getClassName());<br />                     break;<br />                 } catch (Exception e) {<br />                     e.printStackTrace();<br />                 }<br />             }<br />         }<br />         dialog = new JDialog();<br />         dialog.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);<br />         dialog.setResizable(true);<br />         JButton ok = new JButton("Ok");<br />         ok.addActionListener(this);<br />         JRootPane root = dialog.getRootPane();<br />         root.setDefaultButton(ok);<br />         <br />         /** DO NOT DO THIS<br />         root.setLayout(new FlowLayout());<br />         root.add(new JLabel("Try resizing the dialog to see the problem  "));<br />         root.add(new JComboBox(items));<br />         root.add(ok);<br />         **/<br />         //INSTEAD, DO THIS<br />         Container container = dialog.getContentPane();<br />         container.setLayout(new FlowLayout());<br />         container.add(new JLabel("Try resizing the dialog - the problem is gone  "));<br />         container.add(new JComboBox(items));<br />         container.add(ok);<br />         dialog.pack();<br />     }<br /> <br /> <br />     public void run() {<br />         dialog.setVisible(true);<br />     }<br /> <br />     public void actionPerformed(ActionEvent e) {<br />         System.exit(0);<br />     }<br /> <br />     public static void main(String[] args) {<br />         Runnable r;<br />         if(args.length == 0) {<br />             System.out.println("Try supplying one of these LNFs to see if there's a difference:");<br />             for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {<br />                 System.out.println(info.getName());<br />             }<br />             r = new DialogTest(null);<br />         } else {<br />             r = new DialogTest(args[0]);<br />         }<br />         Thread t = new Thread(r);<br />         t.start();<br />     }<br /> }<br /> [/code]<br /> ]]></description>
				<guid isPermaLink="true">http://forums.hotjoe.com/posts/preList/1913/4059.page</guid>
				<link>http://forums.hotjoe.com/posts/preList/1913/4059.page</link>
				<pubDate><![CDATA[Wed, 8 Jun 2011 11:09:04]]> GMT</pubDate>
				<author><![CDATA[ mrider]]></author>
			</item>
			<item>
				<title>Help adding GUI interface to a program</title>
				<description><![CDATA[ I am a college student who is taking Intro to Java Programming.  Unfortunately the professor isn't too helpful and our book sucks...  I've got a simple program that will take your first and last name and generate a username and password from it and now I need to take that program and and a GUI to it.  I think I've got it almost complete but I've got a few errors in eclipse that I can't seem to fix.  Hopefully someone here can tell me if I'm on the right track and maybe even what I can do to get rid of the errors. I've attached both the original program and the gui version I am working on.<br /> <br /> Thanks for any insight/assistance you can provide!<br /> <br /> <br /> <br /> ]]></description>
				<guid isPermaLink="true">http://forums.hotjoe.com/posts/preList/1906/4045.page</guid>
				<link>http://forums.hotjoe.com/posts/preList/1906/4045.page</link>
				<pubDate><![CDATA[Mon, 2 May 2011 19:26:28]]> GMT</pubDate>
				<author><![CDATA[ poisonpanik]]></author>
			</item>
			<item>
				<title>How do i make an image solid?</title>
				<description><![CDATA[ How can I make an image solid? For example,  I am making a game in Java. My basic character movement is working fine. However, i need to add a block (draw an image using paintComponent (Graphics g ) method ). I dont want my character moved character to go through it. How can I set a perimeters so that it wont go through the block? Can someone please provide me with some guidance? Thank you so much]]></description>
				<guid isPermaLink="true">http://forums.hotjoe.com/posts/preList/1894/4017.page</guid>
				<link>http://forums.hotjoe.com/posts/preList/1894/4017.page</link>
				<pubDate><![CDATA[Sun, 10 Apr 2011 09:24:08]]> GMT</pubDate>
				<author><![CDATA[ Skylar]]></author>
			</item>
			<item>
				<title>Basic Character movement using a JPEG and JPanel</title>
				<description><![CDATA[ So far for my GUI, I have inserted a picture onto a JPanel using the paintComponent ( Graphics g ) method. <br /> <br /> I have been trying to figure it out on google and youtube for days. <br /> <br /> Pretty much i need to update my paintComponent ( Graphics g ) method everytime user pressed, but I am not quite certain how to. I also need to know when to use the setVisible ( true ) method to show the JFrame. <br /> <br /> I would apreciate if someone can give me a little background info and code example.<br /> <br /> Thank you so much]]></description>
				<guid isPermaLink="true">http://forums.hotjoe.com/posts/preList/1893/4016.page</guid>
				<link>http://forums.hotjoe.com/posts/preList/1893/4016.page</link>
				<pubDate><![CDATA[Thu, 31 Mar 2011 18:13:46]]> GMT</pubDate>
				<author><![CDATA[ Skylar]]></author>
			</item>
			<item>
				<title>Help needed adding a Graphic to GUI</title>
				<description><![CDATA[ HI all, <br /> I am working on a GUI program and I need help adding a graphic representation to it, like a chart.<br /> <br /> Here is my code:<br /> [code]<br /> /* Ike<br />    Write the program in Java (with a graphical user interface) so that it will<br />    allow the user to select which way they want to calculate a mortgage: by<br />    input of the amount of the mortgage, the term of the mortgage, and the<br />    interest rate of the mortgage payment or by input of the amount of a<br />    mortgage and then select from a menu of mortgage loans:<br /> <br />    - 7 year at 5.35%<br />    - 15 year at 5.5 %<br />    - 30 year at 5.75%<br /> <br />    In either case, display the mortgage payment amount and then, list the loan<br />    balance and interest paid for each payment over the term of the loan. Allow<br />    the user to loop back and enter a new amount and make a new selection, or quit.<br /> */<br /> <br /> import java.awt.*;<br /> import java.awt.event.*;<br /> import javax.swing.*;<br /> import java.text.NumberFormat;<br /> <br /> public class Mortgage extends JFrame<br /> {<br /> 	// define window width and height<br /> 	private static final int FRAME_WIDTH = 400;<br /> 	private static final int FRAME_HEIGHT = 400;<br /> <br /> 	// define text fields for amount of the mortgage, term and<br /> 	// interest rate<br /> 	private JTextField amountText;<br /> 	private JTextField termText;<br /> 	private JTextField rateText;<br /> <br /> 	// define buttons to calculate mortgage payment amount and<br /> 	// quit window<br /> 	private JButton calculateButton;<br /> 	private JButton quitButton;<br /> <br /> 	// define text area to display mortgage payment amount followed<br /> 	// by the loan balance and interest paid for each payment over<br /> 	// the term of the loan<br /> 	private JTextArea outputTextArea;<br /> <br /> 	// term (in years) array<br /> 	private int[] terms = {7, 15, 30};<br /> 	// annual interest rate (%) array<br /> 	private double[] rates = {5.35, 5.50, 5.75};<br /> <br /> 	// constructor<br /> 	public Mortgage()<br /> 	{<br /> 		super("Mortgage Payment Calculator");<br /> <br /> 		Container container = getContentPane();<br /> <br /> 		// set the Border Layout<br /> 		container.setLayout(new BorderLayout());<br /> <br />         // create menu<br /> 		JMenuBar menuBar = new JMenuBar();<br /> <br /> 		// Mortgage Loans menu<br /> 		JMenu loanMenu = new JMenu("Mortgage Loans");<br /> 		menuBar.add(loanMenu);<br /> <br /> 		// add menu items<br /> 		JMenuItem term7MenuItem = new JMenuItem("7 year at 5.35%");<br /> 		JMenuItem term15MenuItem = new JMenuItem("15 year at 5.5%");<br /> 		JMenuItem term30MenuItem = new JMenuItem("30 year at 5.75%");<br /> 		JMenuItem quitMenuItem = new JMenuItem("Quit");<br /> <br /> 		loanMenu.add(term7MenuItem);<br /> 		loanMenu.add(term15MenuItem);<br /> 		loanMenu.add(term30MenuItem);<br /> 		loanMenu.addSeparator();<br /> 		loanMenu.add(quitMenuItem);<br /> <br /> 		setJMenuBar(menuBar);<br /> <br /> 		// create labels<br /> 		JLabel label1 = new JLabel("Amount: ");<br /> 		JLabel label2 = new JLabel("Term: ");<br /> 		JLabel label3 = new JLabel("Interest Rate(%): ");<br /> <br /> 		// create text fields<br /> 		amountText = new JTextField(10);<br /> 		termText = new JTextField(10);<br /> 		rateText = new JTextField(10);<br /> <br /> 		// create calculate and quit buttons<br /> 		calculateButton = new JButton("Calculate");<br /> 		quitButton = new JButton("Quit");<br /> <br /> 		// create panel<br /> 		JPanel panel = new JPanel(new GridLayout(4, 2, 5, 5));<br /> <br /> 		panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));<br /> <br /> 		// add labels and text fields<br /> 		panel.add(label1);<br /> 		panel.add(amountText);<br /> 		panel.add(label2);<br /> 		panel.add(termText);<br /> 		panel.add(label3);<br /> 		panel.add(rateText);<br /> 		panel.add(calculateButton);<br /> 		panel.add(quitButton);<br /> <br /> 		// add panel at north<br /> 		container.add(panel, BorderLayout.NORTH);<br /> <br /> 		// create output text area and make it not editable<br /> 		// and set font as "Courier New"<br /> 		outputTextArea = new JTextArea();<br /> 		outputTextArea.setEditable(false);<br /> 		outputTextArea.setFont(new Font("Courier New", Font.PLAIN, 12));<br /> <br /> 		// and output text area at the center<br /> 		JScrollPane scrollPane = new JScrollPane(outputTextArea);<br /> 		scrollPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));<br /> 		container.add(scrollPane, BorderLayout.CENTER);<br /> <br /> 		// 7 years at 5.35% loan menu item click event listener<br /> 		term7MenuItem.addActionListener(new ActionListener()<br /> 		{<br /> 			public void actionPerformed(ActionEvent e)<br /> 			{<br /> 				double amount;<br /> <br /> 				try<br /> 				{<br /> 					amount = Double.parseDouble(amountText.getText());<br /> 				}<br /> 				catch (Exception ex)<br /> 				{<br /> 					JOptionPane.showMessageDialog(null, "Amount must be numeric", "Error", JOptionPane.ERROR_MESSAGE);<br /> 					return;<br /> 				}<br /> <br /> 				if (amount &lt;= 0)<br /> 				{<br /> 					JOptionPane.showMessageDialog(null, "Amount must be positive", "Amount", JOptionPane.ERROR_MESSAGE);<br /> 					return;<br /> 				}<br /> <br /> 				termText.setText(String.format("%d", terms[0]));<br /> 				rateText.setText(String.format("%.2f", rates[0]));<br /> 				displayLoan(amount, terms[0], rates[0]);<br /> 			}<br /> 		});<br /> <br /> 		// 15 years at 5.5% loan menu item click event listener<br /> 		term15MenuItem.addActionListener(new ActionListener()<br /> 		{<br /> 			public void actionPerformed(ActionEvent e)<br /> 			{<br /> 				double amount;<br /> <br /> 				try<br /> 				{<br /> 					amount = Double.parseDouble(amountText.getText());<br /> 				}<br /> 				catch (Exception ex)<br /> 				{<br /> 					JOptionPane.showMessageDialog(null, "Amount must be numeric", "Error", JOptionPane.ERROR_MESSAGE);<br /> 					return;<br /> 				}<br /> <br /> 				if (amount &lt;= 0)<br /> 				{<br /> 					JOptionPane.showMessageDialog(null, "Amount must be positive", "Amount", JOptionPane.ERROR_MESSAGE);<br /> 					return;<br /> 				}<br /> <br /> 				termText.setText(String.format("%d", terms[1]));<br /> 				rateText.setText(String.format("%.2f", rates[1]));<br /> 				displayLoan(amount, terms[1], rates[1]);<br /> 			}<br /> 		});<br /> <br /> 		// 30 years at 5.75% loan menu item click event listener<br /> 		term30MenuItem.addActionListener(new ActionListener()<br /> 		{<br /> 			public void actionPerformed(ActionEvent e)<br /> 			{<br /> 				double amount;<br /> <br /> 				try<br /> 				{<br /> 					amount = Double.parseDouble(amountText.getText());<br /> 				}<br /> 				catch (Exception ex)<br /> 				{<br /> 					JOptionPane.showMessageDialog(null, "Amount must be numeric", "Error", JOptionPane.ERROR_MESSAGE);<br /> 					return;<br /> 				}<br /> <br /> 				if (amount &lt;= 0)<br /> 				{<br /> 					JOptionPane.showMessageDialog(null, "Amount must be positive", "Amount", JOptionPane.ERROR_MESSAGE);<br /> 					return;<br /> 				}<br /> <br /> 				termText.setText(String.format("%d", terms[2]));<br /> 				rateText.setText(String.format("%.2f", rates[2]));<br /> 				displayLoan(amount, terms[2], rates[2]);<br /> 			}<br /> 		});<br /> <br /> 		// quit menu item click event listener<br /> 		quitMenuItem.addActionListener(new ActionListener()<br /> 		{<br /> 			public void actionPerformed(ActionEvent e)<br /> 			{<br /> 				if (JOptionPane.showConfirmDialog(null, "Do you really want to quit?", "Quit", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)<br /> 				{<br /> 					System.exit(0);<br /> 				}<br /> 			}<br /> 		});<br /> <br /> 		// quit button click event listener<br /> 		quitButton.addActionListener(new ActionListener()<br /> 		{<br /> 			public void actionPerformed(ActionEvent e)<br /> 			{<br /> 				if (JOptionPane.showConfirmDialog(null, "Do you really want to quit?", "Quit", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)<br /> 				{<br /> 					System.exit(0);<br /> 				}<br /> 			}<br /> 		});<br /> <br /> 		addWindowListener(new WindowAdapter()<br /> 		{<br /> 			public void windowClosing(WindowEvent e)<br /> 			{<br /> 				if (JOptionPane.showConfirmDialog(null, "Do you really want to quit?", "Quit", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)<br /> 				{<br /> 					System.exit(0);<br /> 				}<br /> 			}<br /> 		});<br /> <br /> 		// calculate button click event listener<br /> 		calculateButton.addActionListener(new ActionListener()<br /> 		{<br /> 			public void actionPerformed(ActionEvent e)<br /> 			{<br /> 				double amount; // loan amount<br /> 				int term;      // number of years<br /> 				double rate;   // annual interest rate in percentage<br /> <br /> 				try<br /> 				{<br /> 					amount = Double.parseDouble(amountText.getText());<br /> 				}<br /> 				catch (Exception ex)<br /> 				{<br /> 					JOptionPane.showMessageDialog(null, "Amount must be numeric", "Error", JOptionPane.ERROR_MESSAGE);<br /> 					return;<br /> 				}<br /> <br /> 				if (amount &lt;= 0)<br /> 				{<br /> 					JOptionPane.showMessageDialog(null, "Amount must be positive", "Amount", JOptionPane.ERROR_MESSAGE);<br /> 					return;<br /> 				}<br /> <br /> 				try<br /> 				{<br /> 					term = Integer.parseInt(termText.getText());<br /> 				}<br /> 				catch (Exception ex)<br /> 				{<br /> 					JOptionPane.showMessageDialog(null, "Term must be integer", "Error", JOptionPane.ERROR_MESSAGE);<br /> 					return;<br /> 				}<br /> <br /> 				if (term &lt;= 0)<br /> 				{<br /> 					JOptionPane.showMessageDialog(null, "Term must be positive", "Amount", JOptionPane.ERROR_MESSAGE);<br /> 					return;<br /> 				}<br /> <br /> 				try<br /> 				{<br /> 					rate = Double.parseDouble(rateText.getText());<br /> 				}<br /> 				catch (Exception ex)<br /> 				{<br /> 					JOptionPane.showMessageDialog(null, "Interest rate must be numeric", "Error", JOptionPane.ERROR_MESSAGE);<br /> 					return;<br /> 				}<br /> <br /> 				if (rate &lt;= 0)<br /> 				{<br /> 					JOptionPane.showMessageDialog(null, "Interest rate must be positive", "Amount", JOptionPane.ERROR_MESSAGE);<br /> 					return;<br /> 				}<br /> <br /> 				displayLoan(amount, term, rate);<br /> 			}<br /> 		});<br /> 	}<br /> <br /> 	// Display the mortgage payment amount followed by the loan balance and<br /> 	// interest paid for each payment over the term of the loan.<br /> 	public void displayLoan(double amount, int term, double rate)<br /> 	{<br /> 		int months;               // total months<br /> 		double monthlyRate;       // monthly interest rate<br /> 		double monthlyPayment;    // monthly mortgage payment amount<br /> 		NumberFormat nf = NumberFormat.getCurrencyInstance();<br /> 		double loanBalance;<br /> 		double interestPaid;<br /> <br /> 		// calculate total months<br /> 		months = term * 12;<br /> 		// calculate monthly interest rate<br /> 		monthlyRate = rate / 1200;<br /> 		// calculate monthly mortgate payment amount<br /> 		monthlyPayment = (amount * monthlyRate) / (1.0 - (Math.pow(1.0 + monthlyRate, -months)));<br /> 		// set mortgage payment amount in output text area<br /> 		outputTextArea.setText(String.format("Monthly payment amount: %s\n\n", nf.format(monthlyPayment)));<br /> <br /> 		// append header for Month, Loan Balance, and Interest Paid<br /> 		outputTextArea.append(String.format("%10s %20s %20s\n", "Month", "Loan Balance", "Interest Paid"));<br /> 		outputTextArea.append(String.format("%10s %20s %20s\n", "-----", "------------", "-------------"));<br /> <br /> 		// for each month, display Month, Loan Balance, and Interest Paid<br /> 		loanBalance = amount;<br /> <br /> 		for (int month = 1; month &lt;= months; month++)<br /> 		{<br /> 			// calculate monthly interest paid<br /> 			interestPaid = loanBalance * monthlyRate;<br /> 			// calculate loan Balance<br /> 			loanBalance = loanBalance - monthlyPayment + interestPaid;<br /> <br /> 			outputTextArea.append(String.format("%10d %20s %20s\n", month,<br /> 				nf.format(loanBalance), nf.format(interestPaid)));<br /> 		}<br /> 	}<br /> <br /> 	public static void main(String args[])<br /> 	{<br /> 		// create Mortgage class object<br /> 		Mortgage mortgage = new Mortgage();<br /> <br /> 		// set size of window<br /> 		mortgage.setSize(FRAME_WIDTH, FRAME_HEIGHT);<br /> 		// make window exit when closed<br /> 		mortgage.setDefaultCloseOperation(EXIT_ON_CLOSE);<br /> 		// make location of window at center of screen<br /> 		mortgage.setLocationRelativeTo(null);<br /> 		// make window not resizable<br /> 		mortgage.setResizable(false);<br /> 		// make window visible<br /> 		mortgage.setVisible(true);<br /> 	}<br /> }<br /> [/code]<br /> What I need to know is where in my code would I add a graphic and what code would I use to add it.<br /> <br /> Thanks in advance for all help.<br /> <br /> IKE]]></description>
				<guid isPermaLink="true">http://forums.hotjoe.com/posts/preList/1312/3424.page</guid>
				<link>http://forums.hotjoe.com/posts/preList/1312/3424.page</link>
				<pubDate><![CDATA[Thu, 10 Mar 2011 20:00:19]]> GMT</pubDate>
				<author><![CDATA[ coytoy]]></author>
			</item>
			<item>
				<title>Figured it out thanks. Please delete.</title>
				<description><![CDATA[ Figured it out thanks. Please delete.]]></description>
				<guid isPermaLink="true">http://forums.hotjoe.com/posts/preList/867/3094.page</guid>
				<link>http://forums.hotjoe.com/posts/preList/867/3094.page</link>
				<pubDate><![CDATA[Fri, 11 Feb 2011 06:38:08]]> GMT</pubDate>
				<author><![CDATA[ cc11rocks]]></author>
			</item>
			<item>
				<title>Eclipse</title>
				<description><![CDATA[ Hi friends,<br /> <br /> I have done the course J2SE 3 years ago. Now I need to make a project in JAVA using Eclipse, but all has been washed out form my mind till now. Have anyone any knowledge about eclipse. How to run projects in it?<br /> <br /> Thanks in advance.]]></description>
				<guid isPermaLink="true">http://forums.hotjoe.com/posts/preList/841/3046.page</guid>
				<link>http://forums.hotjoe.com/posts/preList/841/3046.page</link>
				<pubDate><![CDATA[Thu, 23 Dec 2010 06:23:35]]> GMT</pubDate>
				<author><![CDATA[ seonikita]]></author>
			</item>
			<item>
				<title>Login Help</title>
				<description><![CDATA[ Hey there, I'm very new to Java and I'm busy making a login frame for a little school project we're doing.<br /> Everything's working perfectly except I can't  get my two panels to fit next to each other seamlessly.<br /> [IMG]http://i614.photobucket.com/albums/tt229/leaf_twig/LoginGUI.jpg[/IMG]<br /> <br /> I want it to look like this:<br /> [IMG]http://i614.photobucket.com/albums/tt229/leaf_twig/LoginGUIFix.jpg[/IMG]<br /> <br /> I'd prefer a simple solution if possible, I'm also using NetBeans so if there's a way to fix this there it would greatly be appreciated :mrgreen: ]]></description>
				<guid isPermaLink="true">http://forums.hotjoe.com/posts/preList/791/2941.page</guid>
				<link>http://forums.hotjoe.com/posts/preList/791/2941.page</link>
				<pubDate><![CDATA[Sat, 16 Oct 2010 10:46:51]]> GMT</pubDate>
				<author><![CDATA[ SouLEDGE]]></author>
			</item>
			<item>
				<title>Creation of a curved surface as an airfoil using java AWT</title>
				<description><![CDATA[ I am trying to create an airfoil. An airfoil is nothing but the crossection of the wing of an airplane or a turbine blade. I am very new to AWT in java but i have tried to write a code which generates the coordinates and draws a curve using those points. the code is given below<br /> <br /> [QUOTE]<br /> import java.awt.*;<br /> import java.awt.event.*;<br /> import java.awt.geom.*;<br /> import java.awt.image.BufferedImage;<br /> import javax.swing.*;<br /> import javax.swing.event.MouseInputAdapter;<br /> <br /> <br /> public class DrawCurve extends JPanel implements ActionListener {<br /> ButtonManager buttonManager;<br /> Path2D.Double path;<br /> Point2D.Double[] points;<br /> Line2D.Double[] connectors;<br /> boolean showConnections= false;<br /> boolean removePoint= false;<br /> boolean firstTime= true;<br /> final double Factor = 50.0D;<br /> <br /> <br /> DrawCurve() {<br /> <br /> 	float maxcamber,position,thickness;<br /> 	int datapts;<br />         double x1,y1;<br />         maxcamber=0.08F;position=5.0F;thickness=0.12F;datapts=25;<br />         int i=1;<br />         double yt[]=new double [100];<br />         double yc[]=new double [100];<br /> <br />         double xu[]=new double [100];<br />         double yu[]=new double [100];<br />         double xl[]=new double [100];<br />         double yl[]=new double [100];<br />         double x[]=new double [100];<br /> 	<br />         for(i=1;i&lt;=datapts;i++)<br />         {<br /> 	<br /> 	x1=((3.141562/180)*(i-1)*(90/(datapts-1)));<br /> 	x[i]=(1-Math.cos(x1));<br /> 	yt[i]=(thickness/0.2)*((0.2969*Math.pow(x[i],0.5))-(0.126*x[i])-(0.3516*Math.pow(x[i],2))+(0.2843*Math.pow(x[i],3))-(0.1015*Math.pow(x[i],4)));<br />         if(x[i]&lt;(position/10))<br /> 	{<br />             yc[i]=(maxcamber/(Math.pow((position/10),2))*((2*(position/10)*x[i])-(Math.pow(x[i],2))));<br /> 	}<br /> 	else<br /> 	{<br />             yc[i]=(maxcamber/(Math.pow(1-(position/10),2)))*((1-(2*(position/10)))+(2*(position/10)*x[i])-Math.pow(x[i],2));<br /> 	}<br /> 	<br />         xu[i]=x[i]-yt[i]*(Math.sin(Math.atan((yc[i+1]-yc[i])/(x[i+1]-x[i]))));<br />         yu[i]=yc[i]+yt[i]*(Math.cos(Math.atan((yc[i+1]-yc[i])/(x[i+1]-x[i]))));<br />         xl[i]=x[i]+yt[i]*(Math.sin(Math.atan((yc[i+1]-yc[i])/(x[i+1]-x[i]))));<br />         yl[i]=yc[i]-yt[i]*(Math.cos(Math.atan((yc[i+1]-yc[i]/(x[i+1]-x[i])))));<br />        // System.out.println("x  :"+x  [i]);<br /> 	//System.out.println("yt :"+yt  [i]);<br /> 	//System.out.println("yc :"+yc  [i]);<br /> 	System.out.println("xu :"+xu  [i]);<br /> 	System.out.println("yu :"+yu  [i]);<br /> 	System.out.println("xl :"+xl  [i]);<br /> 	System.out.println("yl :"+yl  [i]);<br /> 	System.out.println("   ");<br />         <br /> <br /> /*double[][] cds= { {0,0},{0.00378,0.01779},{0.02536,0.03931}, {0.06478,0.06320},{0.12172,0.08733},<br />                   {0.19533,0.10908},{0.2, 8417,12564},{0.38625,0.13435},{0.49906,0.13293},<br />                   {0.61979,0.11971},{0.74551,0.09361},{0.87332,0.05412 },{1.0036,0.00121} };*/<br /> <br /> double[][] cds= {{xu[i],yu[i]},{xl[i],yl[i]}};<br /> System.out.println("cds :"+cds[i][i]);<br /> <br /> points = new Point2D.Double[cds.length];<br /> <br /> for(int j = 0; j &lt; cds.length; j++) {  // NOTE 1 based?  -1 stops short here also<br />    points[j] = new Point2D.Double(Factor * cds[j][0] + Factor, Factor * cds[j][1] + Factor);<br /> }<br /> }//for loop end<br /> /*Path2D.Double*/ path = new Path2D.Double();<br /> System.out.println("1path bnds=" + path.getBounds());<br /> }<br /> <br /> <br /> <br /> public void actionPerformed(ActionEvent e) {<br /> System.out.println("aP e=" + e);<br /> String ac = e.getActionCommand();<br /> if(ac.equals("add")) {<br /> connectors = new Line2D.Double[points.length-1];<br /> showConnections = true;<br /> repaint();<br /> }<br /> if(ac.equals("cancel")) {<br /> showConnections = false;<br /> removePoint = false;<br /> repaint();<br /> }<br /> if(ac.equals("remove")) {<br /> removePoint = true;<br /> }<br /> }<br /> <br /> public void addPoint(Point2D.Double p, int index) {<br /> int size = points.length;<br /> Point2D.Double[] temp = new Point2D.Double[size+1];<br /> System.arraycopy(points, 0, temp, 0, index);<br /> temp[index] = p;<br /> System.arraycopy(points, index, temp, index+1, size-index);<br /> points = temp;<br /> buttonManager.reset();<br /> showConnections = false;<br /> setPath();<br /> repaint();<br /> }<br /> <br /> public void removePoint(Point2D.Double p) {<br /> int size = points.length;<br /> Point2D.Double[] temp = new Point2D.Double[size-1];<br /> for(int j = 0, k = 0; j &lt; size; j++) {<br /> if(points[j] == p)<br /> continue;<br /> temp[k++] = points[j];<br /> }<br /> points = temp;<br /> buttonManager.reset();<br /> removePoint = false;<br /> setPath();<br /> repaint();<br /> }<br /> <br /> public void setPoint(Point2D.Double p,double x,double y) {<br /> p.setLocation(x, y);<br /> setPath();<br /> repaint();<br /> }<br /> <br /> @Override<br /> protected void paintComponent(Graphics g) {<br />    super.paintComponent(g);<br />    System.out.println("pC path bnds=" + path.getBounds()); //pC path bnds=java.awt.Rectangle[x=0,y=0,width=0,height=0]<br />    Graphics2D g2 = (Graphics2D)g;<br />    Path2D.Double path = new Path2D.Double();<br />    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,<br />    RenderingHints.VALUE_ANTIALIAS_ON);<br />    g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,<br />    RenderingHints.VALUE_STROKE_PURE);<br />    if(firstTime) {<br />       firstTime = false;<br />       setPath();<br />    }<br />    g2.setPaint(Color.green.darker());<br /> <br />    g2.draw(path);        //&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; ????<br /> <br />    g2.setPaint(Color.red);<br />    for(int j = 0; j &lt; points.length; j++) {<br />       mark(g2, points[j]);<br />    }<br />    // For adding a point.<br />    if(showConnections) {<br />       g2.setPaint(Color.yellow);<br />       for(int j = 0; j &lt; points.length-1; j++) {<br />          connectors[j] = new Line2D.Double(points[j], points[j+1]);<br />          g2.draw(connectors[j]);<br />       }<br />    }<br /> } // end paintComponent()<br /> <br /> /**<br /> * P(t) = B(n,0)*P0 + B(n,1)*P1 + ... + B(n,n)*Pn<br /> * 0 &lt;= t &lt;= 1<br /> *<br /> * B(n,m) = mth coefficient of nth degree Bernstein polynomial<br /> * = C(n,m) * t^(m) * (1 - t)^(n-m)<br /> * C(n,m) = Combinations of n things, taken m at a time<br /> * = n! / (m! * (n-m)!)<br /> */<br /> private void setPath() {<br /> System.out.println("2path bnds=" + path.getBounds());<br /> path.reset();<br /> int n = points.length;<br /> int w = getWidth();<br /> for(int j = 0; j &lt;= w; j++) {<br />    double t = (double)j/w; // [0 &lt;= t &lt;= 1.0]<br />    double x = 0;<br />    double y = 0;<br />    for(int k = 1; k &lt; n; k++) {<br /> //      System.out.println("k=" + k + " points[k]=" + points[k]);    //k=0 points[k]=null<br />       x += B(n-1,k,t)*points[k].x;<br />       y += B(n-1,k,t)*points[k].y;<br />    }<br />    if(j &gt; 0)<br />    path.lineTo(x,y);<br />    else<br />    path.moveTo(x,y);<br />    }<br /> } // end setPath()<br /> <br /> private double B(int n, int m, double t) {<br />    return C(n,m) * Math.pow(t, m) * Math.pow(1.0 - t, n-m);<br /> }<br /> <br /> private double C(int n, int m) {<br />    return factorial(n) / (factorial(m)*factorial(n-m));<br /> }<br /> <br /> private double factorial(int n) {<br />    return (n &gt; 1) ? n*factorial(n-1) : 1;<br /> }<br /> <br /> private void mark(Graphics2D g2, Point2D.Double p) {<br />    g2.fill(new Ellipse2D.Double(p.x-2, p.y-2, 4, 4));<br /> }<br /> <br /> private JPanel getButtonPanel() {<br /> buttonManager = new ButtonManager();<br /> String[] ids = { "add", "cancel", "remove" };<br /> JPanel panel = new JPanel();<br /> for(int j = 0; j &lt; ids.length; j++) {<br /> JButton button = new JButton(ids[j]);<br /> button.setEnabled(j != 1);<br /> buttonManager.add(button);<br /> button.setActionCommand(ids[j]);<br /> button.addActionListener(this);<br /> panel.add(button);<br /> }<br /> return panel;<br /> }<br /> //----------------------------------------------------------------<br /> public static void main(String[] args) {<br /> DrawCurve test = new DrawCurve();<br /> PointMover mover = new PointMover(test);<br /> test.addMouseListener(mover);<br /> test.addMouseMotionListener(mover);<br /> JFrame f = new JFrame();<br /> f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);<br /> f.add(test);<br /> f.add(test.getButtonPanel(), "Last");<br /> f.setSize(500,500);<br /> f.setLocation(200,200);<br /> f.setVisible(true);<br /> }<br /> //-------------------------------------------------------<br /> static class PointMover extends MouseInputAdapter {<br /> DrawCurve component;<br /> Point2D.Double selectedPoint;<br /> Cursor cursor;<br /> Cursor defaultCursor = Cursor.getDefaultCursor();<br /> Point2D.Double offset = new Point2D.Double();<br /> boolean dragging = false;<br /> final int PROX_DIST = 5;<br /> <br /> PointMover(DrawCurve cf) {<br /> component = cf;<br /> BufferedImage image = getImage();<br /> Point hotspot = new Point(17,17);<br /> cursor = Toolkit.getDefaultToolkit().createCustomCursor(image, hotspot, null);<br /> }<br /> <br /> public void mousePressed(MouseEvent e) {<br /> if(selectedPoint != null) {<br /> if(component.removePoint) { // remove<br /> component.removePoint(selectedPoint);<br /> } else { // drag<br /> offset.x = e.getX() - selectedPoint.x;<br /> offset.y = e.getY() - selectedPoint.y;<br /> dragging = true;<br /> }<br /> } else if(component.showConnections) { // add<br /> Point p = e.getPoint();<br /> Line2D.Double[] lines = component.connectors;<br /> for(int j = 0; j &lt; lines.length; j++) {<br /> if(lines[j].ptSegDist(p) &lt; PROX_DIST) {<br /> component.addPoint(p, j+1);<br /> break;<br /> }<br /> }<br /> }<br /> }<br /> <br /> public void mouseReleased(MouseEvent e) {<br /> dragging = false;<br /> }<br /> <br /> public void mouseDragged(MouseEvent e) {<br /> if(dragging) {<br /> double x = e.getX() - offset.x;<br /> double y = e.getY() - offset.y;<br /> component.setPoint(selectedPoint, x, y);<br /> }<br /> }<br /> <br /> /** For point selection. */<br /> public void mouseMoved(MouseEvent e) {<br /> Point p = e.getPoint();<br /> Point2D.Double[] pts = component.points;<br /> boolean hovering = false;<br /> for(int j = 0; j &lt; pts.length; j++) {<br /> if(pts[j].distance(p) &lt; PROX_DIST) {<br /> hovering = true;<br /> if(selectedPoint != pts[j]) {<br /> selectedPoint = pts[j];<br /> component.setCursor(cursor);<br /> break;<br /> }<br /> }<br /> }<br /> <br /> if(!hovering && selectedPoint != null) {<br /> selectedPoint = null;<br /> component.setCursor(defaultCursor);<br /> }<br /> }<br /> <br /> private BufferedImage getImage() {<br /> int w = 27, h = 27,<br /> type = BufferedImage.TYPE_INT_ARGB_PRE;<br /> BufferedImage image = new BufferedImage(w, h, type);<br /> Graphics2D g2 = image.createGraphics();<br /> g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,<br /> RenderingHints.VALUE_ANTIALIAS_ON);<br /> g2.setPaint(new Color(0x333333));<br /> g2.draw(new Line2D.Double(w/2, 0, w/2, 8)); // n<br /> g2.draw(new Line2D.Double(0, h/2, 8, h/2)); // w<br /> g2.draw(new Line2D.Double(w/2, h-8, w/2, h)); // s<br /> g2.draw(new Line2D.Double(w-8, h/2, w, h/2)); // e<br /> g2.dispose();<br /> return image;<br /> }<br /> }<br /> <br /> //----------------------------------------<br /> class ButtonManager implements ActionListener {<br /> JButton[] buttons = new JButton[0];<br /> <br /> public void actionPerformed(ActionEvent e) {<br /> String ac = e.getActionCommand();<br /> if(ac.equals("add")) {<br /> getButton("remove").setEnabled(false);<br /> enable(true);<br /> } else if(ac.equals("remove")) {<br /> getButton("add").setEnabled(false);<br /> enable(true);<br /> } else {<br /> <br /> reset();<br /> }<br /> }<br /> <br /> public void reset() {<br /> getButton("add").setEnabled(true);<br /> <br /> getButton("remove").setEnabled(true);<br /> enable(false);<br /> }<br /> <br /> private void enable(boolean enable) {<br /> getButton("cancel").setEnabled(enable);<br /> }<br /> <br /> public void add(JButton button) {<br /> button.addActionListener(this);<br /> int size = buttons.length;<br /> JButton[] temp = new JButton[size+1];<br /> System.arraycopy(buttons, 0, temp, 0, size);<br /> temp[size] = button;<br /> buttons = temp;<br /> }<br /> <br /> private JButton getButton(String target) {<br /> for(int j = 0; j &lt; buttons.length; j++) {<br /> if(buttons[j].getActionCommand().equals(target))<br /> return buttons[j];<br /> }<br /> return null;<br /> }<br /> }<br /> } // end class <br /> [/QUOTE]<br /> <br /> i am getting an error with one statement but when i ignore it the applet is displayed but with only 2 points.<br /> <br /> I tried to manually specify the coordinates as double datatype then i get the curve<br /> <br /> Can some on help me out with this. ...... Please if u can help me out with this]]></description>
				<guid isPermaLink="true">http://forums.hotjoe.com/posts/preList/784/2927.page</guid>
				<link>http://forums.hotjoe.com/posts/preList/784/2927.page</link>
				<pubDate><![CDATA[Tue, 21 Sep 2010 10:08:59]]> GMT</pubDate>
				<author><![CDATA[ murdplacid]]></author>
			</item>
			<item>
				<title>Problems With Image Display</title>
				<description><![CDATA[ Hi all.<br /> I'm trying to create an Image slide show.<br /> for those of you who knows "Objects First" book, I'm using the "Image Viewer" project there.<br /> <br /> I've created a JPanel then...<br /> <br /> So, I've created a new frame, and place an "Image Panel" object which is a Class from the book<br /> "public class ImagePanel extends JComponent"<br />  <br /> The class basically set up a place to put a Buffered Image object.<br /> <br /> The I've Added it to the JPanel andall is ok.<br /> <br /> The problem starts when I'm trying to add photos to the Panel..<br /> because I'm using pack(), the Window's changing it's size to the size of the new photo, but the picture is not displayed..<br /> <br /> here is the code.. I hope I managed to explain myself...<br /> <br /> Oh, also "ImageFileManager" is a class which checks if the file is a photo.<br /> <br /> <br /> [code]<br />   private static JFileChooser fileChooser = new JFileChooser(System.getProperty("user.dir"));<br />     private JFrame SlideShowFrame;<br />      private ImagePanel SlideShowImagePanel;<br />     int slideShowTime = 4;<br /> <br /> private void initializeSlideShow() {<br />                          <br />                 fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);<br />                 int returnVal = fileChooser.showOpenDialog(frame);<br /> <br />                 if(returnVal != JFileChooser.APPROVE_OPTION)<br />                     return;  <br />                 File[] fileList = fileChooser.getSelectedFile().listFiles();<br />                 makeSlideShow(fileList);<br />         <br />     <br />     }<br />     private void makeSlideShow(File[] fileList)<br />     {<br />         String fileName;<br />         OFImage currentSlideImage;<br />         makeSlideShowFrame();<br />         <br />         for (int i = 0; i &lt; fileList.length; i++)  {<br />                 currentSlideImage = ImageFileManager.loadImage(fileList[i]);<br />                 if (currentSlideImage != null) {<br />                     SlideShowImagePanel.setImage(currentSlideImage);<br />                     SlideShowFrame.pack();<br />                     try {Thread.sleep(slideShowTime * 1000); } catch (Exception e) {}<br />                 }<br /> <br />             }<br />         }<br />   private void  makeSlideShowFrame()<br />   {<br />       SlideShowFrame = new JFrame("Slide Show");<br />         JPanel contentPane = (JPanel)SlideShowFrame.getContentPane();<br />         contentPane.setBorder(new EmptyBorder(6, 6, 6, 6));<br /> <br />         contentPane.setLayout(new BorderLayout(6, 6));<br />         <br />         SlideShowImagePanel = new ImagePanel();<br />         SlideShowImagePanel.setBorder(new EtchedBorder());<br />         contentPane.add(SlideShowImagePanel, BorderLayout.CENTER);<br />        SlideShowFrame.pack();<br />         <br />         // place the frame at the center of the screen and show<br />         Dimension d = Toolkit.getDefaultToolkit().getScreenSize();<br />         SlideShowFrame.setLocation(d.width/2 - frame.getWidth()/2, d.height/2 - frame.getHeight()/2);<br />          SlideShowFrame.setVisible(true);<br />       <br />       <br />     }<br /> [/code]<br /> <br /> If someone is willing to take a look and tell me what's wrong I will appreciate it so much.<br /> <br /> thanks,<br /> <br /> Giora.]]></description>
				<guid isPermaLink="true">http://forums.hotjoe.com/posts/preList/758/2760.page</guid>
				<link>http://forums.hotjoe.com/posts/preList/758/2760.page</link>
				<pubDate><![CDATA[Thu, 24 Jun 2010 08:20:07]]> GMT</pubDate>
				<author><![CDATA[ gioravered]]></author>
			</item>
			<item>
				<title>Bilinear Interpolation Scaling help</title>
				<description><![CDATA[ Hi,<br /> <br /> I'm trying to program a class for a project, that reads a picture as BufferedImage, and resize it using Bilinear Interpolation  (Using the mathematical formulas, not the methods included in java). I almost sure that the Bilinear Interpolation part of the method is done, but after many thinking, searching and losing hope, I just can't figure out how to apply the scaling part to the method.<br /> <br /> Here's the method:<br /> <br /> [code]<br /> public static BufferedImage resize(BufferedImage image, int w2, int h2)<br /> {<br />  <br /> BufferedImage outputImage = new BufferedImage( w2, h2, BufferedImage.TYPE_INT_RGB );<br />  <br /> // Ratio between original picture and resized picture <br /> float x_ratio = ((float) (image.getWidth()-1))/w2 ; <br /> float y_ratio = ((float) (image.getHeight()-1))/h2;<br />  <br /> // Four pixels a,b,c,d int a, b, c, d, i, j, color; <br /> float alpha, beta, xabRed, xabGreen, xabBlue, xcdRed, xcdGreen, xcdBlue, xfinalRed, xfinalGreen, xfinalBlue; <br /> <br /> <br /> for (int x = 0; x &lt; image.getHeight()-1; x++) <br />    for( int y = 0; y &lt; image.getWidth()-1; y++){ <br /> <br /> //Find the color values of the 4 pixels around the desired point to interpolate <br />    a = image.getRGB(x, y); <br />    b = image.getRGB(x, y + 1); <br />    c = image.getRGB(x + 1, y); <br />    d = image.getRGB(x + 1, y + 1); <br /> <br />    i = (int) (x_ratio * x); <br />    j = (int) (y_ratio * y); <br /> <br />    alpha = (x_ratio * x) - i; <br />    beta = (y_ratio * y) - j; <br /> <br /> // a,b represents 2 of the 4 points for interpolation <br />    xabRed = alpha * ((b &gt;&gt; 16)&0xff) + (1 - alpha) * ((a &gt;&gt; 16)&0xff); <br />    xabGreen = alpha * ((b &gt;&gt; 8)&0xff) + (1 - alpha) * ((a &gt;&gt; 8)&0xff); <br />    xabBlue = alpha * (b &0xff) + (1 - alpha) * (a &0xff); <br /> <br /> // c,d represents 2 of the 4 points for interpolation <br />    xcdRed = alpha * ((d &gt;&gt; 16)&0xff) + (1 - alpha) * ((c &gt;&gt; 16)&0xff); <br />    xcdGreen = alpha * ((d &gt;&gt; 8)&0xff) + (1 - alpha) * ((c &gt;&gt; 8)&0xff); <br />    xcdBlue = alpha * (d &0xff) + (1 - alpha) * (c &0xff); <br /> <br /> // Desired point <br />    xfinalRed = beta * xcdRed + (1 - beta) * xabRed; <br />    xfinalGreen = beta * xcdGreen + (1 - beta) * xabGreen;      xfinalBlue = beta * xcdBlue + (1 - beta) * xabBlue; <br /> <br /> // Prints the RGB values, for bound confirmation    System.out.println((int) xfinalRed + " " + (int) xfinalGreen + " " + (int) xfinalBlue); <br /> <br /> // Sets the new color value for the pixel <br />    color = new Color((int)xfinalRed, (int)xfinalGreen, (int)xfinalBlue).getRGB(); <br /> <br /> // Set the pixel <br />    outputImage.setRGB(x, y, color); <br /> }<br />  return outputImage; <br /> }<br /> [/code] <br /> <br /> <br /> Thanks in advance]]></description>
				<guid isPermaLink="true">http://forums.hotjoe.com/posts/preList/752/2747.page</guid>
				<link>http://forums.hotjoe.com/posts/preList/752/2747.page</link>
				<pubDate><![CDATA[Mon, 14 Jun 2010 16:42:20]]> GMT</pubDate>
				<author><![CDATA[ Xpectro]]></author>
			</item>
			<item>
				<title>digital diary in java using gUI AND streams</title>
				<description><![CDATA[ digital diary in java using gUI AND streams]]></description>
				<guid isPermaLink="true">http://forums.hotjoe.com/posts/preList/745/2730.page</guid>
				<link>http://forums.hotjoe.com/posts/preList/745/2730.page</link>
				<pubDate><![CDATA[Sat, 15 May 2010 03:19:05]]> GMT</pubDate>
				<author><![CDATA[ my_humps007]]></author>
			</item>
			<item>
				<title>Database data won't fill up my JComboBox</title>
				<description><![CDATA[ I know this might seem like a simple query problem [and it probably is but not for me ].<br /> <br /> The problem is the following that using the DISTINCT method in the query does not remove the double data. I tried using DISTINCT only on gemeente, but then the data does not show up in my ComboBox.<br /> <br /> The point is is that I remove the double data from the gemeente column, which contains a bunch of towns and their postal codes. Then I need to list those towns in a ComboBox but applying DISTINCT to gemeente only works as a query in SQL, but then I do not see the data in my combobox.<br /> <br /> [code]<br /> public Vector&lt;jstageGemeente&gt; getjStageGemeente() {<br /> <br />         Statement stmt = null;<br />         ResultSet rs = null;<br />         jstageGemeente gemeente = null;<br />         Vector &lt;jstageGemeente&gt; resultaat = new Vector&lt;jstageGemeente&gt;();<br /> <br />         try {<br />             stmt = connection.createStatement();<br />             rs = stmt.executeQuery("SELECT DISTINCT id, postcode, gemeente FROM jstageGemeente ORDER BY gemeente");<br /> <br />             while (rs.next()) {<br />                 gemeente = new jstageGemeente();<br />                 gemeente.setId(rs.getInt(1));<br />                 gemeente.setPostcode(rs.getInt(2));<br />                 gemeente.setGemeente(rs.getString(3));<br />                 resultaat.add(gemeente);<br />             }<br />         }[/code]<br /> <br /> StudentFrame that loads the data into the combobox<br /> <br /> [code]<br /> public class StudentFrame extends JFrame implements ActionListener {<br /> <br />     private Container content;<br />     private JPanel topLeft, topRight, bottomLeft, bottomRight;<br />     private JComboBox gemeentenBox, sectorBox, soortBox;<br />     private JTextField aantalVeld;<br />     private JButton zoekenButton;<br /> <br />     private DAjstageLogin daLogin = null;<br />     private DAjstageBedrijf daBedrijf = null;<br />     private DAjstageGemeente daGemeente = null;<br />     private DAjstageKeuze daKeuze = null;<br />     private DAjstageSector daSector = null;<br />     private DAjstageSoort daSoort = null;<br />     private DAjstageStudent daStudent = null;<br />     private DAjstageOpdracht daOpdracht = null;<br /> <br />     public StudentFrame(DAjstageBedrijf daBedrijf, DAjstageKeuze daKeuze, DAjstageGemeente daGemeente, DAjstageSector daSector, DAjstageOpdracht daOpdracht, DAjstageSoort daSoort, DAjstageStudent daStudent, DAjstageLogin daLogin)<br />                     throws Exception {<br /> <br />         this.daGemeente = daGemeente;<br />         this.daSector = daSector;<br />         this.daOpdracht = daOpdracht;<br />         this.daStudent = daStudent;<br />         this.daKeuze = daKeuze;<br />         this.daLogin = daLogin;<br />         this.daSoort = daSoort;<br /> <br />         this.setLocation(150,150);<br />         setTitle("Welkom");<br />         setSize(1000,750);<br />         opbouwScherm();<br />         addWindowListener(new VensterHandler());<br />         setVisible(true);<br />         this.setResizable(false);<br /> <br />     }<br /> <br /> <br />     public void opbouwScherm(){<br />         content = getContentPane();<br />         content.setLayout(null);<br /> <br />         JComboBox gemeentenBox = new JComboBox(daGemeente.getjStageGemeente());<br />         gemeentenBox.insertItemAt("geen voorkeur", 0);<br />         JComboBox sectorBox = new JComboBox(daSector.getjStageSector());<br />         sectorBox.insertItemAt("geen voorkeur", 0);<br />         JComboBox soortBox = new JComboBox(daSoort.getjStageSoort());<br />         soortBox.insertItemAt("geen voorkeur", 0);<br />         JTextField aantalVeld = new JTextField();<br />         JButton zoekenButton = new JButton("Zoek");<br />         JLabel gemeentenLabel = new JLabel("Locatie bedrijf:");<br />         JLabel aantalLabel = new JLabel("Werkzame informatici:");<br />         JLabel sectorLabel = new JLabel("Sector stagebedrijf:");<br />         JLabel soortLabel = new JLabel("Soort stage:");<br /> <br />         //comboboxen<br />         gemeentenBox.setBounds(5, 30, 150, 20);<br />         sectorBox.setBounds(160, 30, 325, 20);<br />         soortBox.setBounds(495, 30, 140, 20);<br />         aantalVeld.setBounds(625, 30, 135, 20);<br /> <br />         //labels<br />         gemeentenLabel.setBounds(5,10,120,20);<br />         sectorLabel.setBounds(160,10,120,20);<br />         soortLabel.setBounds(495,10,120,20);<br />         aantalLabel.setBounds(625,10,135,20);<br /> <br />         //buttons<br />         zoekenButton.setBounds(800,30,80,20);<br /> <br />         content.add(gemeentenBox);<br />         content.add(sectorBox);<br />         content.add(soortBox);<br />         content.add(aantalVeld);<br />         content.add(gemeentenLabel);<br />         content.add(sectorLabel);<br />         content.add(soortLabel);<br />         content.add(aantalLabel);<br />         content.add(zoekenButton);<br /> <br />     }[/code]]]></description>
				<guid isPermaLink="true">http://forums.hotjoe.com/posts/preList/744/2729.page</guid>
				<link>http://forums.hotjoe.com/posts/preList/744/2729.page</link>
				<pubDate><![CDATA[Wed, 12 May 2010 14:23:28]]> GMT</pubDate>
				<author><![CDATA[ Subhero]]></author>
			</item>
	</channel>
</rss>
