JComboBox setSelectedIndex not displaying correct value

Hi,
Not sure if this is a bug or implementation issue.
When trying to use the setSelectedItem(int) method of JComboBox, what's being displayed in the panel is not the same item that is selected when you open the dropdown.
If you run the example code below a few times in a row you'll see that it eventually displays something other than "Item 2". However, if you open the combobox it will always display the correct value. So, just on a whim I surrounded the setSelectedIndex(int) call with the SwingUtilities.invokeLater method and it all started to work. I was able to run it 6 times in a row and always displayed the correct value. Whereas without it usually by the 3rd run, I'd see the issue.
So, my question is - Should I be putting all setSelectedXXX() methods in SwingUtilities.invokeLater methods? We originally found this issue in our JApplets. I made the code below so I could post it, but essentially it's the same thing. We do use Javascript to call back into the JApplet to set the indexes. I'm guessing I DO need to since we're dealing with different Threads and Swing?
Thanks,
- Tim
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
* To change this template, choose Tools | Templates
* and open the template in the editor.
* @author tmulle
public class Test {
    public static void main(String[] args) {
        // Create the Frame
        JFrame f = new JFrame();
        final JComboBox combo = new JComboBox();
        // Add some items to the combo
        for (int x = 0; x < 20; x++) {
            combo.addItem("Item " + x);
        // Create a scrollpane
        JScrollPane pane = new JScrollPane(combo);
        f.getContentPane().add(pane);
        f.setSize(300, 200);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        // Tester thread
        Thread t = new Thread(new Runnable() {
            public void run() {
                try {
                    Thread.sleep(5000);
                } catch (InterruptedException ex) {
                    Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex);
                // Uncomment this and things seem to work consistently
//                SwingUtilities.invokeLater(new Runnable() {
//                    public void run() {
//                        combo.setSelectedIndex(2);
                // Comment this out when uncommenting above
                // This is supposed to select the 2 index in the list
                // However, run running the example multiple times you'll see
                // that it sometimes displays something other than the correct
                // value. But the correct items is selected in the dropdown
                combo.setSelectedIndex(2);
        // Start the thread
        t.start();
        // Show the frame
        f.setVisible(true);
}

You do need to set the selected index from the EDT, as shown in the code you commented out. Or, the SwingWorker class is very useful for simplifying your threading code.
Also, if I may, I think Darryl is suggesting you also create the gui components in the EDT as well. People often use this construct in the main method since the main method is run in a separate thread from the EDT, just like the threads you create. It is technically not safe to make Swing calls from the main() method.
public static void main(String args[])
        SwingUtilities.invokeLater(new Runnable()
            public void run()
                createAndShow();
}Edited by: mpmarrone on Apr 27, 2010 1:08 PM

Similar Messages

  • Dynamic Select List not displaying correct value

    Hi there!
    I have a page with a dynamic repeat region.
    As I press one record I get up all the details based on id on an edit page.
    The problem is that the info that is inserted via a Select List is not displaying correct on edit page.
    All the other values are correct, also the values in the repeat region on index page,
    but the value from the Select List on edit page is just displaying the initially selected item.
    Have tried using SELECT DISTINCT in the SQL statement, but no luck.
    Any other ideas?
    Cut and paste from form:
    <select name="Vegtype" class="ProvDet" id="Vegtype" title="<%=(rsAs.Fields.Item("VegType").Value)%>">
                        <option value="Ev" selected="selected">Ev</option>
                        <option value="Fv">Fv</option>
                        <option value="Rv">Rv</option>
                        <option value="Kv">Kv</option>
                      </select>
    Recordset
    <%
    Dim rsAs
    Dim rsAs_cmd
    Dim rsAs_numRows
    Set rsAs_cmd = Server.CreateObject ("ADODB.Command")
    rsAs_cmd.ActiveConnection = MM_LabCon_STRING
    rsAs_cmd.CommandText = "SELECT DISTINCT DatoM, DatoR, DatoU, Distr, FagFelt, Felt, IntNr, Km, KontrNr, Kontrollor, Masse, MasseBK, Punkt, Resept, TestID, UserID, VegHp, VegNavn, VegNr, VegType FROM tblTest WHERE TestID = ?"
    rsAs_cmd.Prepared = true
    rsAs_cmd.Parameters.Append rsAs_cmd.CreateParameter("param1", 5, 1, -1, rsAs__MMColParam) ' adDouble
    Set rsAs = rsAs_cmd.Execute
    rsAs_numRows = 0
    %>
    Regards,
    Christian
    DWCS5 | .Asp | MS Access

    Ok, here goes the top down approach...
    In the HTML header of my page, i have this reference to a js file containing the javascript - <script src="#WORKSPACE_IMAGES#108.js" type="text/javascript"></script>
    Then in an HTML Region I have the following code to create the divs that will be shown and hidden - <div id="divREGION" class="divs">Select region to get list of countries.</div>
    <div id="divCOUNTRY" class="divs">Select country to get list of cities.</div>
    <div id="divCITY" class="divs">Select city and then press "Get Employees". </div>
    Note that these divs contain static content. You may be able to create dynamic content for these divs by creating dynamic query regions and putting div tags around the region (i havent tried this, it may require template modification).
    The select boxes have this code in the "HTML form elements attributes" - onFocus="javascript:showHideDiv(this,true)" onBlur="javascript:showHideDiv(this,false)"
    This onFocus and onBlur call the showHideDiv() function, passing in the object reference of the select box and a true/false to show/hide the related div.
    The actual javascript function that is contained in the 108.js file is:
    function showHideDiv(objThis, inBool){
         var divid = "div" + objThis.id.substring(3);
         if (inBool) {
         ShowDiv(divid);
         else {
    HideDiv(divid);
    That function in turn calls either the ShowDiv() or HideDiv() functions, depending on the true or false, passing in the ID of the div to be changed...
    function ShowDiv(divid){
         eval('document.all'+ '["' + divid + '"]' + '.style' +'.display = "inline"');
    function HideDiv(divid){
         eval('document.all'+ '["' + divid + '"]' + '.style' +'.display = "none"');
    Hope this helps.

  • Pivot table not displaying the values correctly

    Hi,
    I have created a pivot table in which i am using 2 tables. I pulled columns from table A and one column from table B in the measures section to get the grand total. All the rows are comming fine but, its not returning any values for tableB's column(if i pull it into measures).
    If the column stays under rows section, the report is comming out fine.
    I need the total to be displayed in the report.
    Can some body help me with this.
    Thanks

    Hi David,
    i have set the column's aggregation to sum, and it is comming out correctly in the grand total, how ever, i have some of the coulmns which i am taking the %
    col3= (col2/col1)*100
    col1- aggregation set as Sum, col2 and col3 is set as default
    The values for col3 are comming finr in report , where as it is not returning correct value for garnd total row.
    ex: row w--- col1 col2 col3
    row1-----6630 1130 17.04
    row2 6114 994 16.26
    total 23317 3739 56.40(should be 16.2..)
    For col3 it is calculating like this(3739-total of col2/ 6630 -first row of col1 *100)
    Instead of taking total , it is taking the first row.
    I tried different aggregations, but was still unable to get the correct value. Can you please let me know if i am missing anything.
    Can we define custom aggregations.
    Thanks
    Gayatri
    Edited by: user12589255 on Aug 3, 2011 2:55 PM

  • Boolean values are not displaying correct

    hi ..
    i have created a application which has one report .. in report field
    there's boolean field (true or false) when i run my application
    it will show the correct results...
    but when host the application in IIS7 then the result will not
    show correct value .. it is showing only true...
    if there's a value false also it is showing true only...
    what to do.... ?

    hi..
    I have developed an web application
    i am using SAP crystal report 13 for VS2010
    and i have hosted that application in iis 7
    It is been developed in c#.net ..
    OR
    i have one solution ...
    can we create a formula so that if the value is
    0 then it should show false and if the value is
    1 it should show true... in formula field...

  • Date can not display correctly in excel from .jsp

    Hi,
    I create a .jsp report to export the data to excel. the report run OK, except the date field can not display correctly.
    for example in database :start date ='01-oct-2003'
    in the except it displays to 02/06/02.
    It seem all the date field can not be control in the report, and control by somthing else
    Doese anyone come accross this problem?
    Thanks

    Hi Rong,
    Are you using the following demonstration to build your JSP?
    http://otn.oracle.com/products/reports/htdocs/getstart/demonstrations/index.html
    (Output to Excel with Oracle9i Report)
    I tried to do the same, and inserted a database date field in the JSP using Reports. I found the following:
    While making the template inside Excel, if I make sure that the format of the date cells is "Date" - some particular date format, the date field values from Reports does not get exported correctly.
    However, if you make sure that inside the template, the format of the date cells is not date, but "General", then the date field values are correctly exported to Excel.
    Pl try it and let us know.
    Navneet.

  • Report does not display correctly when exported to adobe

    Post Author: mgisonda
    CA Forum: Crystal Reports
    Hopefully someone can help me. I am currently running Crystal Reports profession version 10. I have applied service pack 1 and recently service pack 6. I am having a problem with the display of a report within adobe. My report is a bit complex. It is a 8.5x11 one page landscape report. It is set up in a grid format with multiple lines and boxes drawn on it. Here is the report information: Report Definition----
    Number of Database Fields:   144     Number of On-Demand Formulas:   40     UFLs in use:   None     Page N of M Used:   No     File Format Schema:   10.2.0    I created the report using CR developer. I use the report within a web project. The user requests the report and it returns to the user, an adobe file of the report. However, this is where I am having trouble. On my local development machine, the report displays fine. In CR developer, the report displays fine. When I export the report to Adobe from the CR Developer, it exports fine. BUT when I run the report from my web site, the adobe file that is returned is broken up over 42 pages. What seems to be actually happening is the return adobe file seems to think that the page size is 2in X 4in.. Where it got that, I don't know.The server running IIS is a windows server 2003. It has adobe 8.0 reader on it. I also have Crystal 10 Server Distribution loaded on it. And I have loaded CR10 Service pack 6 on that as well. Below is the web code that is used to display the report:Imports CrystalDecisions.Shared'Imports CrystalDecisions.CrystalReportsImports CrystalDecisions.CrystalReports.EngineImports CrystalDecisions.CrystalReports.Engine.ReportClassPublic Class PrintInspectionLayout    Inherits System.Web.UI.Page   Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load        Dim mNotInSpringDesign As String        Dim mPartType As String        mNotInSpringDesign = Request.QueryString("NotInSpringDesign")        If mNotInSpringDesign = "TRUE" Then            mStockCode = Request.QueryString("StockCode")            lblNotInSpringDesign.Text = "Stock Code #: " & mStockCode & " does not exist in Spring Design."            lblNotInSpringDesign.Visible = True            Response.Write("<br><br><br><br><br><font color='blue'><center><a href='SpringDesignWildCardSearch.aspx'>Go To Search Page</a></center></font>")        Else            mStockCode = Request.QueryString("StockCode")            Dim pList As ParameterValues = New ParameterValues            Dim paramName, paramValue As String            Dim pV As ParameterDiscreteValue = New ParameterDiscreteValue            Dim Report As ReportDocument= New ReportDocument            Dim expOpts As ExportOptions = New ExportOptions            Dim pdfRtfWordFormatOpts As PdfRtfWordFormatOptions = expOpts.CreatePdfRtfWordFormatOptions            Dim expFormatOpts As ExportFormatOptions = expOpts.ExportFormatOptions            expOpts.ExportFormatType = ExportFormatType.PortableDocFormat            mPartType = Request.QueryString("PartType")            'SELECT THE INSPECTION LAYOUT TYPE TO PRINT            Select Case mPartType                Case Is = "C"                    Report.Load(MapPath("./Reports/CompressionLayout.rpt"))                    'Report.Load(MapPath("./Reports/PCAR.rpt"))                Case Is = "E"                    Report.Load(MapPath("./Reports/ExtensionLayout.rpt"))                Case Is = "T"                    Report.Load(MapPath("./Reports/TorsionLayout.rpt"))                Case Is = "W"                    Report.Load(MapPath("./Reports/WasherLayout.rpt"))                Case Is = "F"                    Report.Load(MapPath("./Reports/FreeFormLayout.rpt"))                Case Else            End Select            pV.Value = mStockCode            pList.Add(pV)            Report.DataDefinition.ParameterFields("StockCode").ApplyCurrentValues(pList)            Response.ClearContent()            Response.ClearHeaders()            Response.ContentType = "Application/pdf"            Report.ExportToHttpResponse(expOpts, Response, False, "")            Report.Close()        End If    End Sub    Any ideas as to the solution? Why is it not displaying correctly? I have spent two days researching every FAQ  to try to find an answer, but to no avail. Please any help would be greatly appreciated. ThanksMike   

    Hi Paul
    You're more likely to get an answer to this if you post in the UNIX forum.
    By the looks of it, you may have a problem with your fonts.

  • Entity Descriptions are not displayed correctly in Combo box dropdown list

    In Web Analysis, Entity Descriptions are not displayed correctly in Combo box dropdown list when entity descriptions from HFM contains a dot(.)
    Example:
    'Entity A. LTD' becomes 'LTD'
    'Entity B Inc.' becomes blank
    It seems that everything before the dot is not displayed when opening the combobox.
    It looks like it is acting like the option to show short description for entities in HR where the parent-child relation is not shown. This behaviour I don't expect for descriptions. And in my opinion is not an option in Web Analysis.
    Does anybody knows the sollution or have seen this issue before?

    Hi,
    This is a known issue with combo box list of values.
    Please follow this workaround:
    - Remove ComboboxLOV on Deptno
    - Create an updateable transient attribute(Say Dname) of type String
    - Define combobox lov with following values:
    List Data Source: DeptView1
    List Attribute: Dname
    List Return Values:
    Dname - Dname
    Deptno - Deptno
    UI Hints: Display Attribute - Dname
    - Edit Dname(transient attribute) and provide following groovy expression
    oracle.jbo.Key key = new oracle.jbo.Key(Deptno);
    return DeptView1.findByKey(key, 1)[0].getAttribute("Dname");- Now, you are done and observe that Dname combo box lov shows Description even on selection and change in this combo box sets the Deptno value
    Sireesha

  • RegionRenderer encodeAll The region component with id: pt1:r1 has detected a page fragment with multiple root components. Fragments with more than one root component may not display correctly in a region and may have a negative impact on performance.

    Hi,
    I am using JDEV 11.1.2.1.0
    I am getting the following error :-
    <RegionRenderer> <encodeAll> The region component with id: pt1:r1 has detected a page fragment with multiple root components. Fragments with more than one root component may not display correctly in a region and may have a negative impact on performance. It is recommended that you restructure the page fragment to have a single root component.
    Piece of code is for region is:-
       <f:facet name="second">
                                                <af:panelStretchLayout id="pa1"
                                                                       binding="#{backingBeanScope.Assign.pa1}">
                                                    <f:facet name="center">
                                                        <af:region value="#{bindings.tfdAssignGraph1.regionModel}" id="r1"
                                                                   binding="#{backingBeanScope.Assign.r1}"/>
                                                    </f:facet>
                                                </af:panelStretchLayout>
                                            </f:facet>
    How do I resolve it ?
    Thanks,

    Hi,
    I see at least 3 errors
    1. <RegionRenderer> <encodeAll> The region component with id: pt1:r1 has detected a page fragment with multiple root components.
    the page fragment should only have a single component under the jsp:root tag. If you see more than one, wrap them in e.g. an af:panelGroupLayout or af:group component
    2. SAPFunction.jspx/.xml" has an invalid character ".".
    check the document (you can open it in JDeveloper if the customization was a seeded one. Seems that editing this file smething has gone bad
    3. The expression "#{bindings..regionModel}" (that was specified for the RegionModel "value" attribute of the region component with id "pePanel") evaluated to null.
    "pageeditorpanel" does seem to be missing in the PageDef file of the page holding the region
    Frank

  • Why exchange rate is not displayed correctly when I create the PO in SRM?

    Hi Gurus,
    Yesterday I insert a new row at OB08 tx. at backend system (R/3) for exchange rate of May 17,2010, the value was 10.00. Then I run the BBP_GET_EXRATE program to replicate the info to SRM.
    But when I created a purchase order (PO) the value was 12.24 for exchange rate (this value 12.24 is the value for the previous day May 16, 2010).
    Today morning (May 18, 2010), I inserted another row at R/3 and replicated to SRM, the new value for May 18 was 11. I create another PO and the value was 10 for exchange rate (the value for yesterday).
    But when the PO is transmitted to R/3, the exchange rate is the correct.
    My question is: Why exchange rate is not displayed correctly when I create the PO in SRM? Exists an aspect of memory in SRM that it has to be refreshed? Why SRM is getting the exchange rate for yesterday? Is an issue for time zone?

    Hi Muthu,
    I'm in Extended classic.
    I already discovered what is happening. At the time of being creating the purchase order (PO), it takes the exchange rate of the delivery date of the shopping cart (SC). But when the order is authorized and tries to transmit it to R/3, it takes the exchange rate of the date of creation of the PO.
    Two checks of budget exist:
    1.- When creating PO (exchange rate date of delivery date of the SC's item)
    2.- When authorized and tries to transmit it to R/3 (exchange rate date of creation date of the PO)
    If exchange rate of delivery date of the SC is lower than exchange rate date of creation of the PO, there are cases in which it is marking budget error.
    Now my question is: It is a standard behavior? (to take different exchange rate)

  • Query not displaying correct data

    hi all
    my query is not displaying correct data.
    in data target secondary sales is showing 1.800 value but in query it is showing
    2.00.my requirement is my query shuld show 1.800 value. i also tried to change decimal points but not changes has happend.plz let me knw what is the problem
    thanks in advance
    shalini gupta

    With which u r reconciling the data.
    With R3 or Cube.
    I think check ur key figure, have u taken the key figure 'with TAX' one or with out tax one??
    Regards,
    Manoj.

  • Color gradients not displaying correctly

    I'm having an issue with my color gradients in type and objects not displaying correctly in the content viewer. For the last app I created, I made sure the colors were RGB and that seemed to fix it. With the current app I'm working on, that dosen't seem to fix the issue. Actually, when I test in the viewer on my iPad, it shows the correct gradient in the split second that it's loading the update but then once it's loaded, it goes to a gray white gradient (the correct gradient is from a yellow to a gray; attached a pict for referrence).
    Anyone know why this is happening? Thanks in advance!
    UPDATE: It seems to view fine if I preview the page via the foilo overlay but when I preview the folio, that's when it's no viewing correctly.

    The Color Picker is unreliable for choosing colors based on what you see because it is not color managed while Color panel and Swatches are.
    In your image, the color that you see in the Color Picker is how your monitor displays R=0 G=255 B=0. The color that you see in the Color Panel represents the same values in the file but the color management sends different values to the video card and thus to the monitor to display a color with appearance in the color space selected for the document. In your image this is a CMYK color space which you can check from the Show popup menu at the bottom left of the document window. To check the different values the video card is using, make a screen capture, save the image, open it in Illustrator and measure the color with the eyedropper. The color translation from the values in the file to the video card allows simulation of color spaces other than your monitor's. This simulation is accurate if you have a monitor profile installed in your system that correctly describes how your monitor displays colors. Such profile is created by using a color measuring device and profiling software. If your monitor profile (color space) installed in the system is the same as the color space of the document then there will be no translation (simulation) which in effects shuts down the color management - then the colors in the Color Picker will be the same as in the document. Many people do not bother to get an accurate profile of their monitor and use a generic sRGB profile for that. In such case working in RGB color mode using the sRGB color space (default in the Color Settings) will give the same colors in the Color Picker and the document. This usually is a sign of using a monitor that incorrectly displays colors.

  • Google fonts not displaying correctly since updating to Firefox 31.0

    Since updating to Firefox 31.0, the vast majority of Google / web fonts are not displaying correctly, including icons that are being replaced with random characters. When I view the Google web fonts page, only a few display correctly, the rest just default to a sans-serif font.
    - I've tried running in safe mode with no add-ons enabled.
    - I've tried disabling all add-ons then re-enabling one by one.
    - I've checked the tickbox in the font settings for 'Allow pages to use their own fonts' is ticked
    Any help appreciated, it's got quite frustrating now.
    Thanks, Greg

    You can do a font test to see if you can identify corrupted font(s).
    *http://browserspy.dk/fonts-flash.php?detail=1
    You can try different default fonts and temporarily disable website fonts to test the selected default font.
    *Tools > Options > Content : Fonts & Colors > Advanced
    *[ ] "Allow pages to choose their own fonts, instead of my selections above"
    You can check for problems with preferences.
    You can check the <b>gfx.downloadable_fonts.enabled</b> pref on the <b>about:config</b> page and make sure that it is set to true (if necessary double-click the line to toggle its value).
    Delete a possible user.js file and numbered prefs-##.js files and rename (or delete) the prefs.js file to reset all prefs to the default value including prefs set via user.js and prefs that are no longer supported in the current Firefox release.
    *http://kb.mozillazine.org/Preferences_not_saved
    *http://kb.mozillazine.org/Resetting_preferences
    Create a new profile as a test to check if your current profile is causing the problem.
    See "Creating a profile":
    *https://support.mozilla.org/kb/profile-manager-create-and-remove-firefox-profiles
    *http://kb.mozillazine.org/Standard_diagnostic_-_Firefox#Profile_issues
    If the new profile works then you can transfer files from a previously used profile to the new profile, but be cautious not to copy corrupted files to avoid carrying over problems.
    *http://kb.mozillazine.org/Transferring_data_to_a_new_profile_-_Firefox
    Boot the computer in Windows Safe mode with network support (press F8 on the boot screen) as a test to see if that helps.
    *http://www.bleepingcomputer.com/tutorials/how-to-start-windows-in-safe-mode/

  • Date not displaying correctly

    Hi,
    we have an issue where date is not displaying correctly in report. it shows 1/1/1990. even in universe it shows the same value 1/1/1990. but if i run query at DB level it shows the correct date. Reporting Database is Sybase.
    we are on Bi 4.0 SP 6.
    Any Ideas.
    Thanks,
    Yogesh.

    HI Farzana,
    Finally,i have narrowed down the issue. So here it is,Initially we were seeing date as 1/1/1900 in webi rich, IDT and BI LaunchPad. so than we have made changes to sybase. prm file in following location
    ........\dataAccess\connectionServer\sybase\extensions\legacy
    in prm file the input date parameter is as below
    <Parameter Name="USER_INPUT_DATE_FORMAT">'mm/dd/yyyy hh:m:s am/pm'</Parameter>
    we changed it to
    <Parameter Name="USER_INPUT_DATE_FORMAT">'mm/dd/yyyy hh:mm:ss A'</Parameter>
    and than  we see correct date in IDT and Webi rich but not in BI LaunchPad. the connection we were using in universe is ODBC. so i have created a new connection using sybase CTL client and now i see correct dates in BI LaunchPad also. So i am not sure if i need to make changes to prm file in /dataAccess\connectionServer\odbc\extensions location for the report to show correct values using ODBC.
    Any Idea.
    Thanks,
    Kumar.

  • Abstract classes and methods with dollar.decimal not displaying correctly

    Hi, I'm working on a homework assignment and need a little help. I have two classes, 1 abstract class, 1 extends class and 1 program file. When I run the program file, it executes properly, but the stored values are not displaying correctly. I'm trying to get them to display in the dollar format, but it's leaving off the last 0. Can someone please offer some assistance. Here's what I did.
    File 1
    public abstract class Customer//Using the abstract class for the customer info
    private String name;//customer name
    private String acctNo;//customer account number
    private int branchNumber;//The bank branch number
    //The constructor accepts as arguments the name, acctNo, and branchNumber
    public Customer(String n, String acct, int b)
        name = n;
        acctNo = acct;
        branchNumber = b;
    //toString method
    public String toString()
    String str;
        str = "Name: " + name + "\nAccount Number: " + acctNo + "\nBranch Number: " + branchNumber;
        return str;
    //Using the abstract method for the getCurrentBalance class
    public abstract double getCurrentBalance();
    }file 2
    public class AccountTrans extends Customer //
        private final double
        MONTHLY_DEPOSITS = 100,
        COMPANY_MATCH = 10,
        MONTHLY_INTEREST = 1;
        private double monthlyDeposit,
        coMatch,
        monthlyInt;
        //The constructor accepts as arguments the name, acctNo, and branchNumber
        public AccountTrans(String n, String acct, int b)
            super(n, acct, b);
        //The setMonthlyDeposit accepts the value for the monthly deposit amount
        public void setMonthlyDeposit(double deposit)
            monthlyDeposit = deposit;
        //The setCompanyMatch accepts the value for the monthly company match amount
        public void setCompanyMatch(double match)
            coMatch = match;
        //The setMonthlyInterest accepts the value for the monthly interest amount
        public void setMonthlyInterest(double interest)
            monthlyInt = interest;
        //toString method
        public String toString()
            String str;
            str = super.toString() +
            "\nAccount Type: Hybrid Retirement" +
            "\nDeposits: $" + monthlyDeposit +
            "\nCompany Match: $" + coMatch +
            "\nInterest: $" + monthlyInt;
            return str;
        //Using the getter method for the customer.java fields
        public double getCurrentBalance()
            double currentBalance;
            currentBalance = (monthlyDeposit + coMatch + monthlyInt) * (2);
            return currentBalance;
    }File 3
        public static void main(String[] args)
    //Creates the AccountTrans object       
            AccountTrans acctTrans = new AccountTrans("Jane Smith", "A123ZW", 435);
            //Created to store the values for the MonthlyDeposit,
            //CompanyMatch, MonthlyInterest
            acctTrans.setMonthlyDeposit(100);
            acctTrans.setCompanyMatch(10);
            acctTrans.setMonthlyInterest(5);
            DecimalFormat dollar = new DecimalFormat("#,##0.00");
            //This will display the customer's data
            System.out.println(acctTrans);
            //This will display the current balance times 2 since the current
            //month is February.
            System.out.println("Your current balance is $"
                    + dollar.format(acctTrans.getCurrentBalance()));
        }

    Get a hair cut!
    h1. The Ubiquitous Newbie Tips
    * DON'T SHOUT!!!
    * Homework dumps will be flamed mercilessly. [Feelin' lucky, punk? Well, do ya'?|http://www.youtube.com/watch?v=1-0BVT4cqGY]
    * Have a quick scan through the [Forum FAQ's|http://wikis.sun.com/display/SunForums/Forums.sun.com+FAQ].
    h5. Ask a good question
    * Don't forget to actually ask a question. No, The subject line doesn't count.
    * Don't even talk to me until you've:
        (a) [googled it|http://www.google.com.au/] and
        (b) had a squizzy at the [Java Cheat Sheet|http://mindprod.com/jgloss/jcheat.html] and
        (c) looked it up in [Sun's Java Tutorials|http://java.sun.com/docs/books/tutorial/] and
        (d) read the relevant section of the [API Docs|http://java.sun.com/javase/6/docs/api/index-files/index-1.html] and maybe even
        (e) referred to the JLS for "advanced" questions.
    * [Good questions|http://www.catb.org/~esr/faqs/smart-questions.html#intro] get better Answers. It's a fact. Trust me on this one.
        - Lots of regulars on these forums simply don't read badly written questions. It's just too frustrating.
          - FFS spare us the SMS and L33t speak! Pull your pants up, and get a hair cut!
        - Often you discover your own mistake whilst forming a "Good question".
        - Often you discover that you where trying to answer "[the wrong question|http://blog.aisleten.com/2008/11/20/youre-asking-the-wrong-question/]".
        - Many of the regulars on these forums will bend over backwards to help with a "Good question",
          especially to a nuggetty problem, because they're interested in the answer.
    * Improve your chances of getting laid tonight by writing an SSCCE
        - For you normal people, That's a: Short Self-Contained Compilable (Correct) Example.
        - Short is sweet: No-one wants to wade through 5000 lines to find your syntax errors!
        - Often you discover your own mistake whilst writing an SSCCE.
        - Often you solve your own problem whilst preparing the SSCCE.
        - Solving your own problem yields a sense of accomplishment, which makes you smarter ;-)
    h5. Formatting Matters
    * Post your code between a pair of &#123;code} tags
        - That is: &#123;code} ... your code goes here ... &#123;code}
        - This makes your code easier to read by preserving whitespace and highlighting java syntax.
        - Copy&paste your source code directly from your editor. The forum editor basically sucks.
        - The forums tabwidth is 8, as per [the java coding conventions|http://java.sun.com/docs/codeconv/].
          - Indents will go jagged if your tabwidth!=8 and you've mixed tabs and spaces.
          - Indentation is essential to following program code.
          - Long lines (say > 132 chars) should be wrapped.
    * Post your error messages between a pair of &#123;code} tags:
        - That is: &#123;code} ... errors here ... &#123;code}
        - OR: &#91;pre]&#123;noformat} ... errors here ... &#123;noformat}&#91;/pre]
        - To make it easier for us to find, Mark the erroneous line(s) in your source-code. For example:
            System.out.println("Your momma!); // <<<< ERROR 1
        - Note that error messages are rendered basically useless if the code has been
          modified AT ALL since the error message was produced.
        - Here's [How to read a stacktrace|http://www.0xcafefeed.com/2004/06/of-thread-dumps-and-stack-traces/].
    * The forum editor has a "Preview" pane. Use it.
        - If you're new around here you'll probably find the "Rich Text" view is easier to use.
        - WARNING: Swapping from "Plain Text" view to "Rich Text" scrambles the markup!
        - To see how a posted "special effect" is done, click reply then click the quote button.
    If you (the newbie) have covered these bases *you deserve, and can therefore expect, GOOD answers!*
    h1. The pledge!
    We the New To Java regulars do hereby pledge to refrain from flaming anybody, no matter how gumbyish the question, if the OP has demonstrably tried to cover these bases. The rest are fair game.

  • Unicode character not displaying correctly

    when i am stroring Unicode Character in Oracle 8 DB .The Stored Character are not displayed correctly . Through sql client seen as '�' .Altough through JSp it displays correct value &#38598; (in japanese)
    My client wants to see through sql also same value . Pls help wat is wrong. More info :
    Oracle is set up in UTF-8 Format.
    Using code as below before inserting in DB
    String temp =product.getDescription();
    String newResult = new String(temp.getBytes("UTF-8"), "UTF-8");

    TryString newResult = new String(temp.getBytes(default),>
    "UTF-8");// "default" is a String of the name of
    default encoding on the part of client
    Sorry there was a slip. Try the following.
    String newResult = new String(temp.getBytes(default));

Maybe you are looking for