Acquisition temps réels

Bonjour à tous,
J'essaye d'acquérir des données issue d'un système en temps réels qui tourne à une période de 10ms. Les données sont envoyés par laison série sur le PC.
J'effectue ma lecture de trame via VISA Read dans une boucle while. Cette boucle tourne à 15ms ce qui implique des retards de données. Auriez vous un moyen d'accélerer cette boucle afin quel soit d'environ 10ms pour ainsi avoir mes acquisition en temps réels.
Je vous joint mon VI.
Merci de votre réponse.
Pièces jointes :
Trame_read_Envoie_Forum_NI.vi ‏24 KB

Bonjour Astely,
Qu'entendez-vous par temps réel?Utilisez-vous le module LabVIEW Real Time?
Si les temps ne peuvent pas être tenu avec ce module, il faudra utiliser le module NI LabVIEW FPGA pour décoder vos trames de manière déterministe.
Cordialement,
Rémi D.
National Instruments France
#adMrkt{text-align: center;font-size:11px; font-weight: bold;} #adMrkt a {text-decoration: none;} #adMrkt a:hover{font-size: 9px;} #adMrkt a span{display: none;} #adMrkt a:hover span{display: block;}
>> Les rencontres techniques de NI - Mesures et acquisition de données : de la théorie à la mise en ...

Similar Messages

  • Acquisition température capteur ds18b20 sous arduino via LabView

    Bonjour,
    cela fait déjà quelques jours que je me casse la tête sans pour autant avoir de solution à mon problème. Je cherche à acquérir la température de plusieurs capteurs ds18b20 via LabView (graphes principalement). J'utilise le toolkit Arduino on LabView mais je n'arrive pas vraiment à bien l'utiliser. Le principe de ce module est bien de permettre de ne pas toucher à une seule ligne de code ? Est-ce que je peux lire toute une chaîne de capteur via LabView ?
    Par ailleurs je suis en train de consulter un exemple de la fonction "thermistor Read" mais je m'aperçoit que l'entrée de cette fonction est analogique, alors que mes capteurs sont digitaux, y a t-il un équivalent de cette fonction qui me correspondrai ?
    Même un petit morceau de code me serait profitable histoire de savoir par où commencer
    Merci d'avance pour vos réponses,
    cordialement,
    Cyril Milon

    Bonjour Lykaa,
    Avez-vous consulté le forum suivant ? : Arduino and Dallas DS1820 (one-wire)
    et posté sur la communauté en question ? : LabVIEW Interface for Arduino
    Voici également un lien qui pourrait vous être utile : How to use the DS18S20 and DS18B20 temperature sensors with Arduino
    Cordialement,
    Jérémy C.
    National Instruments France
    #adMrkt{text-align: center;font-size:11px; font-weight: bold;} #adMrkt a {text-decoration: none;} #adMrkt a:hover{font-size: 9px;} #adMrkt a span{display: none;} #adMrkt a:hover span{display: block;}
    Travaux Pratiques d'initiation à LabVIEW et à la mesure
    Du 2 au 23 octobre, partout en France

  • Mesurer un temps entre deux points sur un graphe déroulant et afficher ce temps sur la face-avant

    mesurer un temps entre deux points A et B et afficher ce temps sur la face-avant.
    Le graphe est déroulant.
    Attachments:
    demande_solut.tif ‏762 KB
    diagramme_philippe.tif ‏571 KB

    Lulu,
    Pardon mon francais. N'es pas tres bon.
    En le version de LabVIEW 6.0 et mas, c'est un feature (?) en les graph ou le temps puet etre afficher en le graphe. Si vous avez C'est version de LabVIEW, ce ne pas de problemme.
    Mai, si vous n'avez pas 6.0+, vous avez le fait de mains. (manually, in english). A ce fait, vous avez calculer le temp avec le taux (vitesse?) d'acquisition de data. C'est temp avec deux points et 1/le taux d'acquisition.
    temp = t (seconds)
    taux d'acquisition = r (hz - samples/second)
    t=1/r
    Apres vous avez le temps, se afficher en le graphe avec le "bundle" pour l'example de "waveform chart". Je n'avez pas du LabVIEW en francais, et je ne se pas le nome de l'example.
    Bon Chance.
    En Englais:
    I think you
    are trying to display the time on a graph/chart of your data. In LabVIEW 6 and higher versions, you can very easily do this with a feature you just turn on (look at the Graph and Chart examples.) If you have an older version, you will have to calculate this. Its quite easy to do. I have included a GIF image of an example of how to do this.
    I know my French is terrible, but I hope this helps.
    Good luck.
    Attachments:
    real_time_chart.gif ‏16 KB

  • Query Filling up Temp DB --Please Help

    Friends,  when I execute this proc it fills up the temp db very quickly.  Could you guys please take a look at the attached script and help me 
    Create PROCEDURE Test
    @loginid INT,
    @companyid INT,
    @streetnumber nvarchar(50) = NULL,
    @streetname nvarchar(50) = NULL,
    @city nvarchar(50) = NULL,
    @zip nvarchar(50) = NULL,
    @lastname nvarchar(50) = NULL,
    @firstname nvarchar(50) = NULL,
    @companyname nvarchar(50) = NULL,
    @builder nvarchar(50) = NULL,
    @lotnumber nvarchar(50) = NULL,
    @subdivision nvarchar(50) = NULL,
    @showaccount bit,
    @showsite bit,
    @activeonly bit = NULL,
    @branchType int,
    @BranchIndex int,
    @prgActive bit = NULL,
    @prgCancel bit = NULL,
    @prgPendingCancel bit = NULL,
    @siteNational bit = NULL,
    @siteResidential bit = NULL,
    @siteCommercial bit = NULL,
    @prgPC bit = NULL,
    @prgTCTB bit = NULL,
    @prgPCTCTB bit = NULL
    AS
    BEGIN
    DECLARE @sql nvarchar(MAX),
    @paramlist nvarchar(4000)
    SELECT @sql =
    N' SET NOCOUNT ON
    CREATE TABLE #temp
    accountid int, siteid int, contactid int,phoneid int,addressid int, haspc bit, hastctb bit, branchid int
    create index tmpaccountid on #temp(accountid)
    create index tmpsiteid on #temp(siteid)
    create index tmpcontactid on #temp(contactid)
    create index tmpphoneid on #temp(phoneid)
    create index tmpaddressid on #temp(addressid)
    create index tmpbranchid on #temp(branchid)
    IF @showaccount=1 BEGIN
    INSERT INTO #temp (accountid,siteid,contactid,phoneid,addressid,branchid)
    SELECT distinct taccount.accountid, isnull(taccountsite.siteid,0), tcontact.contactid,
    tcontactphonenumber.phoneid,taddress.addressid, taccount.billingcenterid
    FROM taddress with (nolock) INNER JOIN
    taccount with (nolock) ON taddress.addressid = taccount.billingaddressid INNER JOIN
    tlogincompanybranch ON taccount.billingcenterid = tlogincompanybranch.branchid INNER JOIN
    tcontact ON taccount.primarycontactid = tcontact.contactid LEFT JOIN
    tcontactphonenumber ON tcontactphonenumber.phoneid = tcontact.primaryphoneid
    LEFT JOIN taccountsite ON taccountsite.accountid = taccount.accountid
    LEFT JOIN tsite ON taccountsite.siteid = tsite.siteid
    if (@builder is not null) or (@lotnumber is not null) or (@subdivision is not null)
    begin
    SELECT @sql = @sql + ' LEFT JOIN tbuilder on tsite.builderid = tbuilder.builderid
    LEFT JOIN tcontact bc ON tbuilder.primarycontactid = bc.contactid '
    end
    if @branchType = 1
    begin
    SELECT @sql = @sql + ' INNER JOIN testimate est ON est.siteid = tsite.siteid
    INNER JOIN tlogincompanybranch svccenterbranch on est.servicecenter=svccenterbranch.branchid and svccenterbranch.loginid = @loginid '
    end
    SELECT @sql = @sql + ' WHERE taccount.companyid = @companyid and tlogincompanybranch.loginid=@loginid '
    if @branchType = 1 and @branchIndex <> 0
    begin
    SELECT @sql = @sql + ' AND est.servicecenter = @branchIndex '
    end
    if @activeonly is not null
    begin
    SELECT @sql = @sql + ' AND taccount.isactive <> 0 '
    end
    if @lastname is not null
    begin
    SELECT @sql = @sql + ' AND upper(tcontact.lastname) LIKE @lastname + ''%'''
    --SELECT @sql = @sql + ' AND upper(tcontact.lastname) LIKE N' + quotename(@lastname + '%', '''')
    end
    if @firstname is not null
    begin
    SELECT @sql = @sql + ' AND upper(tcontact.firstname) LIKE @firstname + ''%'''
    end
    if @companyname is not null
    begin
    SELECT @sql = @sql + ' AND upper(tcontact.businessname) LIKE @companyname + ''%'''
    end
    if @streetnumber is not null
    begin
    SELECT @sql = @sql + ' AND taddress.streetnumber = @streetnumber '
    end
    if @streetname is not null
    begin
    SELECT @sql = @sql + ' AND upper(taddress.streetname) LIKE @streetname + ''%'''
    end
    if @city is not null
    begin
    SELECT @sql = @sql + ' AND upper(taddress.city) LIKE @city + ''%'''
    end
    if @zip is not null
    begin
    SELECT @sql = @sql + ' AND taddress.postalcode LIKE @zip + ''%'''
    end
    if @builder is not null
    begin
    SELECT @sql = @sql + ' AND upper(bc.businessname) LIKE ''%'' + @builder + ''%'''
    end
    if @lotnumber is not null
    begin
    SELECT @sql = @sql + ' AND upper(tsite.lotnumber) LIKE @lotnumber '
    end
    if @subdivision is not null
    begin
    SELECT @sql = @sql + ' AND upper(tsite.subdivision) LIKE @subdivision + ''%'''
    end
    if (@siteNational is not null) or (@siteResidential is not null) or (@siteCommercial is not null)
    begin
    SELECT @sql = @sql + ' AND ( '
    if @siteResidential is not null
    begin
    SELECT @sql = @sql + ' tsite.propertytype = 1 '
    end
    if @siteCommercial is not null
    begin
    if (@siteCommercial is not null) and (@siteResidential is not null)
    begin
    SELECT @sql = @sql + ' OR tsite.propertytype = 2 '
    end
    else
    begin
    SELECT @sql = @sql + ' tsite.propertytype = 2 '
    end
    end
    if @siteNational is not null
    begin
    if (@siteNational is not null) and ((@siteResidential is not null) or (@siteCommercial is not null))
    begin
    SELECT @sql = @sql + ' OR tsite.propertytype = 5 '
    end
    else
    begin
    SELECT @sql = @sql + ' tsite.propertytype = 5 '
    end
    end
    SELECT @sql = @sql + ' ) '
    end
    if @branchType = 2
    begin
    SELECT @sql = @sql + ' AND taccount.billingcenterid = @BranchIndex '
    end
    SELECT @sql = @sql + ' END '
    SELECT @sql = @sql + ' IF @showsite = 1 BEGIN
    INSERT INTO #temp (accountid,siteid,contactid,phoneid,addressid, branchid)
    SELECT distinct taccountsite.accountid,tsite.siteid,tsite.primarycontactid,
    isnull(tcontactphonenumber.phoneid, 0),taddress.addressid,0
    FROM taccountsite INNER JOIN
    taccount a on a.accountid=taccountsite.accountid INNER JOIN
    tlogincompanybranch on a.billingcenterid=tlogincompanybranch.branchid INNER JOIN
    tsite with (nolock) ON taccountsite.siteid = tsite.siteid INNER JOIN
    taddress with (nolock) ON tsite.addressid = taddress.addressid INNER JOIN
    tcontact ON tsite.primarycontactid = tcontact.contactid LEFT JOIN
    tcontactphonenumber ON tcontact.primaryphoneid = tcontactphonenumber.phoneid '
    if @builder is not null
    begin
    SELECT @sql = @sql + ' LEFT JOIN tbuilder ON tsite.builderid = tbuilder.builderid
    LEFT JOIN tcontact bc ON tbuilder.primarycontactid = bc.contactid '
    end
    if @branchType = 1
    begin
    SELECT @sql = @sql + ' INNER JOIN testimate est ON est.siteid = tsite.siteid
    INNER JOIN tlogincompanybranch svccenterbranch on est.servicecenter=svccenterbranch.branchid and svccenterbranch.loginid = @loginid '
    end
    SELECT @sql = @sql + ' WHERE taddress.companyid = @companyid and tlogincompanybranch.loginid=@loginid '
    if @activeonly is not null
    begin
    SELECT @sql = @sql + ' AND a.isactive <> 0 '
    end
    if @lastname is not null
    begin
    SELECT @sql = @sql + ' AND upper(tcontact.lastname) LIKE @lastname + ''%'''
    --SELECT @sql = @sql + ' AND upper(tcontact.lastname) LIKE N' + quotename(@lastname + '%', '''')
    end
    if @branchType = 1 and @branchIndex <> 0
    begin
    SELECT @sql = @sql + ' AND est.servicecenter = @branchIndex '
    end
    if @firstname is not null
    begin
    SELECT @sql = @sql + ' AND upper(tcontact.firstname) LIKE @firstname + ''%'''
    end
    if @companyname is not null
    begin
    SELECT @sql = @sql + ' AND upper(tcontact.businessname) LIKE @companyname + ''%'''
    end
    if @streetnumber is not null
    begin
    SELECT @sql = @sql + ' AND taddress.streetnumber = @streetnumber '
    end
    if @streetname is not null
    begin
    SELECT @sql = @sql + ' AND upper(taddress.streetname) LIKE @streetname + ''%'''
    end
    if @city is not null
    begin
    SELECT @sql = @sql + ' AND upper(taddress.city) LIKE @city + ''%'''
    end
    if @zip is not null
    begin
    SELECT @sql = @sql + ' AND taddress.postalcode LIKE @zip + ''%'''
    end
    if @builder is not null
    begin
    SELECT @sql = @sql + ' AND upper(bc.businessname) LIKE ''%'' + @builder + ''%'''
    end
    if @lotnumber is not null
    begin
    SELECT @sql = @sql + ' AND upper(tsite.lotnumber) LIKE @lotnumber '
    end
    if @subdivision is not null
    begin
    SELECT @sql = @sql + ' AND upper(tsite.subdivision) LIKE @subdivision + ''%'''
    end
    if (@siteNational is not null) or (@siteResidential is not null) or (@siteCommercial is not null)
    begin
    SELECT @sql = @sql + ' AND ( '
    if @siteResidential is not null
    begin
    SELECT @sql = @sql + ' tsite.propertytype = 1 '
    end
    if @siteCommercial is not null
    begin
    if (@siteCommercial is not null) and (@siteResidential is not null)
    begin
    SELECT @sql = @sql + ' OR tsite.propertytype = 2 '
    end
    else
    begin
    SELECT @sql = @sql + ' tsite.propertytype = 2 '
    end
    end
    if @siteNational is not null
    begin
    if (@siteNational is not null) and ((@siteResidential is not null) or (@siteCommercial is not null))
    begin
    SELECT @sql = @sql + ' OR tsite.propertytype = 5 '
    end
    else
    begin
    SELECT @sql = @sql + ' tsite.propertytype = 5 '
    end
    end
    SELECT @sql = @sql + ' ) '
    end
    if @branchType = 2
    begin
    SELECT @sql = @sql + ' AND taccount.billingcenterid = @BranchIndex '
    end
    SELECT @sql = @sql + ' END '
    if (@prgActive is not null) or (@prgCancel is not null) or (@prgPendingCancel is not null)
    begin
    SELECT @sql = @sql + ' delete tmp
    from #temp tmp
    left join testimate e on e.siteid = tmp.siteid
    left join tprogram p on p.estimateid = e.estimateid
    where p.programid IS NULL '
    if @prgActive is null
    begin
    SELECT @sql = @sql + ' OR (p.canceldate is null and p.pendingcanceldate is null) '
    end
    if @prgCancel is null
    begin
    SELECT @sql = @sql + ' OR p.canceldate is not null '
    end
    if @prgPendingCancel is null
    begin
    SELECT @sql = @sql + ' OR p.pendingcanceldate is not null '
    end
    end
    SELECT @sql = @sql + ' ;WITH counts AS
    SELECT
    tmp.accountid,
    pccount = SUM(CASE WHEN ps.reportcategory = 1 THEN 1 ELSE 0 END),
    tctbcount = SUM(CASE WHEN ps.reportcategory = 3 THEN 1 ELSE 0 END)
    FROM
    #temp tmp
    INNER JOIN testimate e ON e.siteid = tmp.siteid
    INNER JOIN tprogram p ON p.estimateid = e.estimateid
    INNER JOIN tprogramsetup ps ON ps.programtypeid = p.programtypeid
    GROUP BY tmp.accountid
    UPDATE #temp
    SET haspc = CASE WHEN c.pccount > 0 THEN 1 ELSE 0 END,
    hastctb = CASE WHEN c.tctbcount > 0 THEN 1 ELSE 0 END
    FROM #temp tmp
    INNER JOIN counts c ON c.accountid = tmp.accountid '
    if (@prgPC is not null) or (@prgTCTB is not null) or (@prgPCTCTB is not null)
    begin
    SELECT @sql = @sql + ' DELETE
    FROM #temp
    WHERE (haspc = 0 AND hastctb = 0) OR (haspc IS NULL OR hastctb IS NULL) '
    if @prgPC is null
    begin
    SELECT @sql = @sql + ' OR (haspc = 1 AND hastctb = 0)'
    end
    if @prgTCTB is null
    begin
    SELECT @sql = @sql + ' OR (haspc = 0 AND hastctb = 1)'
    end
    if @prgPCTCTB is null
    begin
    SELECT @sql = @sql + ' OR (haspc = 1 AND hastctb = 1)'
    end
    end
    SELECT @sql = @sql + ' IF @showaccount=1 AND @showsite = 0 BEGIN
    SELECT DISTINCT taccount.accountnum,taccount.isactive, b.branchname, 0 as siteid, isnull(max(tcontact.firstname),'''') as firstname,isnull(max(tcontact.lastname),'''') as lastname,
    isnull(max(tcontact.businessname),'''') as businessname,max(taddress.streetnumber) as streetnumber,
    max(taddress.predirection) as predirection ,isnull(max(taddress.streetname),'''') as streetname,max(taddress.streetsuffix) as streetsuffix,max(taddress.postdirection) as postdirection,
    isnull(max(taddress.city),'''') as city,isnull(max(taddress.state),'''') as state,max(taddress.postalcode) as postalcode,isnull(taccount.mysearch,'''') as mysearch,taccount.accountid,
    isnull(max(tsite.lotnumber),'''') as lotnumber, haspc=CONVERT(BIT,ISNULL(haspc,0)), hastctb=CONVERT(BIT,ISNULL(hastctb,0))
    FROM #temp INNER JOIN taccount ON #temp.accountid = taccount.accountid
    LEFT JOIN tcontact ON #temp.contactid = tcontact.contactid
    LEFT JOIN taddress ON #temp.addressid = taddress.addressid
    LEFT JOIN taccountsite ON taccountsite.accountid=taccount.accountid
    LEFT JOIN tsite ON (taccountsite.siteid = tsite.siteid and tsite.addressid=taddress.addressid )
    LEFT JOIN tbranch b ON (taccount.billingcenterid = b.branchid)
    if @branchType = 1
    begin
    SELECT @sql = @sql + ' LEFT JOIN testimate est ON est.accountid = taccount.accountid '
    if @BranchIndex <> 0
    begin
    SELECT @sql = @sql + ' AND est.servicecenter = @BranchIndex '
    end
    SELECT @sql = @sql + ' GROUP BY taccount.accountnum, #temp.siteid, tcontact.firstname, tcontact.lastname,
    tcontact.businessname, taddress.streetnumber, taddress.predirection, taddress.streetname, taddress.streetsuffix, taddress.postdirection, taddress.city, taddress.state, taddress.postalcode, taccount.mysearch, taccount.accountid, taccount.isactive, haspc, hastctb, b.branchname
    HAVING count(est.servicecenter) > 0 '
    end
    else
    begin
    if @branchType = 2
    begin
    SELECT @sql = @sql + ' WHERE taccount.billingcenterid = @BranchIndex '
    end
    SELECT @sql = @sql + ' GROUP BY taccount.accountid, taccount.isactive,taccount.accountnum,taccount.mysearch, haspc, hastctb,b.branchname '
    SELECT @sql = @sql + ' ORDER BY taccount.accountnum '
    end
    SELECT @sql = @sql + ' END ELSE BEGIN
    SELECT DISTINCT taccount.accountnum,taccount.isactive, case when billingbranch.branchname is not null and @showaccount = 1 then billingbranch.branchname else isnull(b.branchname,'''') end as branchname, case when #temp.branchid = 0 then #temp.siteid else 0 end as siteid, isnull(tcontact.firstname,'''') as firstname,isnull(tcontact.lastname,'''') as lastname,
    isnull(tcontact.businessname,'''') as businessname,taddress.streetnumber,
    taddress.predirection,isnull(taddress.streetname,'''') as streetname,taddress.streetsuffix,taddress.postdirection,
    isnull(taddress.city,'''') as city,isnull(taddress.state,'''') as state,taddress.postalcode,isnull(taccount.mysearch,'''') as mysearch,taccount.accountid,
    isnull(max(tsite.lotnumber),'''') as lotnumber, haspc=CONVERT(BIT,ISNULL(haspc,0)), hastctb=CONVERT(BIT,ISNULL(hastctb,0))
    FROM #temp INNER JOIN taccount ON #temp.accountid = taccount.accountid
    LEFT JOIN tcontact ON #temp.contactid = tcontact.contactid
    LEFT JOIN taddress ON #temp.addressid = taddress.addressid
    LEFT JOIN taccountsite ON taccountsite.accountid=taccount.accountid
    LEFT JOIN tsite ON (taccountsite.siteid = tsite.siteid and tsite.addressid=taddress.addressid )
    LEFT JOIN testimate est ON est.siteid = tsite.siteid
    LEFT JOIN tbranch b ON (est.servicecenter = b.branchid)
    LEFT JOIN tbranch billingbranch ON (#temp.branchid = billingbranch.branchid)
    if @branchType = 1
    begin
    if @BranchIndex <> 0
    begin
    SELECT @sql = @sql + ' AND est.servicecenter = @BranchIndex '
    end
    SELECT @sql = @sql + ' GROUP BY taccount.accountnum,taccount.isactive, #temp.siteid, tcontact.firstname, tcontact.lastname,tcontact.businessname, taddress.streetnumber,
    taddress.predirection,taddress.streetname, taddress.streetsuffix,taddress.postdirection,taddress.city, taddress.state, taddress.postalcode,taccount.mysearch, taccount.accountid, haspc, hastctb, b.branchname, billingbranch.branchname, #temp.branchid
    HAVING (count(est.servicecenter) > 0 or billingbranch.branchname is not null) '
    end
    else
    begin
    if @branchType = 2
    begin
    SELECT @sql = @sql + ' WHERE taccount.billingcenterid = @BranchIndex '
    end
    SELECT @sql = @sql + ' GROUP BY taccount.accountid, taccount.isactive,taccount.accountnum, tcontact.firstname, tcontact.lastname,
    tcontact.businessname, #temp.siteid,
    taddress.streetnumber, taddress.predirection, taddress.streetname,
    taddress.streetsuffix, taddress.postdirection,taddress.city, taddress.state,
    taddress.postalcode,taddress.postalcodeex,taccount.mysearch, haspc, hastctb, b.branchname, billingbranch.branchname, #temp.branchid '
    end
    SELECT @sql = @sql + ' ORDER BY taccount.accountnum
    END
    DROP TABLE #temp
    SET NOCOUNT OFF '
    SELECT @paramlist = N' @loginid INT,
    @companyid INT,
    @streetnumber nvarchar(100),
    @streetname nvarchar(50),
    @city nvarchar(50),
    @zip nvarchar(50),
    @lastname nvarchar(50),
    @firstname nvarchar(50),
    @companyname nvarchar(50),
    @builder nvarchar(50),
    @lotnumber nvarchar(50),
    @subdivision nvarchar(50),
    @showaccount bit,
    @showsite bit,
    @activeonly bit,
    @branchType int,
    @BranchIndex int,
    @prgActive bit,
    @prgCancel bit,
    @prgPendingCancel bit,
    @siteNational bit,
    @siteResidential bit,
    @siteCommercial bit,
    @prgPC bit,
    @prgTCTB bit,
    @prgPCTCTB bit '
    EXEC sp_executesql @sql, @paramlist,
    @loginid, @companyid, @streetnumber, @streetname, @city, @zip, @lastname, @firstname, @companyname, @builder,
    @lotnumber, @subdivision, @showaccount, @showsite, @activeonly, @branchType, @BranchIndex, @prgActive,
    @prgCancel,@prgPendingCancel, @siteNational, @siteResidential, @siteCommercial, @prgPC, @prgTCTB, @prgPCTCTB
    END

    Does it fill up tempdb, no matter which parameters you provide?
    Narrow down which conditions that cause the procedure to fail. Add a @debug parameter and
    IF @debug = 1
       PRINT @sql
    Take a look at that SQL, and see if it looks OK. Maybe you have an incorrect condition somewhere?
    You can also create a temporary procedure from the generated SQL, and then run it, to see more what is happening.
    If nothing stands out, try reducing the query until tempdb stays in check.
    Since you create temp tables, there are two possible reasons (at least) why tempdb fills up:
    1) You are inserting too much data into the temp tables (for instance because of a poorly written join).
    2) The query generates a worktable which overflows.
    I don't think anyone wants to try to read and understand your dynamic SQL code, but hopefully these tips helps you with the troubleshooting.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Problems with string array, please help!

    I have a String array floor[][], it has 20 rows and columns
    After I do some statement to modify it, I print this array
    out in JTextArea, why the output be like this?
    null* null....
    null null...
    null null...
    How to correct it?

    a turtle graphics applet:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class TG extends JApplet implements ActionListener {
      private int x, y;
      private int pendown, command, movement;
      String direction, output, temp;
      JLabel l1;
      JTextField tf1;
      JTextArea ta1;
      String floor[][] = new String[20][20];;
      public void init()
        x = 0;
        y = 0;
        pendown = 0;
        direction = "r";
        Container c = getContentPane();
        c.setLayout( new FlowLayout() );
           l1 = new JLabel( "Please type a command:" );
           c.add( l1 );
           tf1 = new JTextField(20);
           tf1.addActionListener( this );
           c.add( tf1 );
           ta1 = new JTextArea(20,20);
           ta1.setEditable( false );
           c.add( ta1 );
    public void actionPerformed( ActionEvent e )
           temp = tf1.getText();
           if( temp.length() > 1)
           command = Integer.parseInt(temp.substring(0,1));
           movement = Integer.parseInt(temp.substring(2,temp.length()));
           else
           command = Integer.parseInt(temp);
           switch(command)
                case 1:
                pendown=0;
                break;
                case 2:
                pendown=1;
                break;
                case 3:
                direct("r");
                break;
                case 4:
                direct("l");
                break;
                case 5:
               move(movement);           
                break;
                case 6:
                print();
                break;                                     
      public void direct(String s)
           if(direction == "r" && s =="r")
              direction = "d";
           else if(direction == "r" && s =="l")
              direction = "u";
           else if(direction == "l" && s =="r")
              direction = "u";
           else if(direction == "l" && s =="l")
              direction = "d";
           else if(direction == "u" && s =="r")
              direction = "r";
           else if(direction == "u" && s =="l")
              direction = "l";
           else if(direction == "d" && s =="r")
              direction = "l";
           else if(direction == "d" && s =="l")
              direction = "r";
      public void move(int movement)
           if(pendown == 1)
                if(direction == "u")
                for(int b=0;b<movement;b++)
                     floor[x][y+b] = "*";
                else if(direction == "d")
                for(int b=0;b<movement;b++)
                     floor[x][y-b] = "*";
                else if(direction == "l")
                for(int b=0;b<movement;b++)
                     floor[x-b][y] = "*";
                else if(direction == "r")
                for(int b=0;b<movement;b++)
                     floor[x+b][y] = "*";
            else if(pendown == 0)
                 if(direction == "u")
                for(int b=0;b<movement;b++)
                     floor[x][y+b] = "-";
                else if(direction == "d")
                for(int b=0;b<movement;b++)
                     floor[x][y-b] = "-";
                else if(direction == "l")
                for(int b=0;b<movement;b++)
                     floor[x-b][y] = "-";
                else if(direction == "r")
                for(int b=0;b<movement;b++)
                     floor[x+b][y] = "-";
          public void print()
         for(int row=0;row<20;row++)
           for( int column=0;column<20;column++)
                output += floor[row][column];
                if(column == 19)
                 output+="\n";
            ta1.setText(output);
    }

  • Splitting a string into separate values, but the array length is variable

    We are a cabinet manufacturer.  I'm trying to write a report to show the location of individual hinges on a door.  I have a string that will look something like these examples:
    60, 540
    60, 540, 956
    60, 540, 956, 1340
    It may have 2, 3, 4, or 5 locations.  (Don't think I've ever seen one over 5).
    So I have a formula that says:
    Split({Doors.HingeCenterLines},',')[1]
    This will return 60 - the first figure in my string.
    I need to have all of them separated, but the critical thing is the last measurement.  I need it to be the height of the door minus the last hinge location.  So for an example, if I have a 1400mm tall door, the 4th example string listed above would be generated.  I want my entries to look like this:
    60
    540
    956
    60
    My string always references the hinge relationship to the bottom of the door, but for the top hinge only, I need it to be based on the distance from the top of the door.
    Can anyone help with this?  Thanks in advance!

    Try this code please:
    whileprintingrecords;
    local stringvar array arr := Split({Doors.HingeCenterLines},',');
    local numbervar temp;
    local stringvar fin_string;
    local numbervar i;
    For i := 1 to ubound(arr) do
         If i = ubound(arr) then
              temp := {Door_height} - tonumber(arr[i]);
              fin_string := fin_string + totext(temp,0,"");
         else
              fin_string := fin_string + arr[i] + chr(13);
    fin_string;
    You can then right-click the field > Format Field > Common tab > Check the 'Can Grow' option.
    -Abhilash

  • JTable with JComboBox

    Hi friends,
    I am adding JComboBox in JTable its working properly
    But data is not adding dynamically to JComboBox
    I am Sending my Code plz give me reply
    I am Struggleing from 1 week on wards
    package com.dnt.autopopulation;
    import javax.swing.*;
    import java.awt.*;
    import javax.swing.table.JTableHeader;
    import javax.swing.table.TableColumn;
    import java.awt.event.*;
    import javax.swing.JTable;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.event.TableModelEvent;
    import java.util.ArrayList;
    import java.util.Calendar;
    import java.util.Locale;
    import java.text.SimpleDateFormat;
    import java.util.Vector;
    import javax.swing.border.*;
    import com.dnt.eaip.Connectmagr;
    import com.dnt.eaip.*;
    import com.dnt.util.*;
    import javax.swing.plaf.ButtonUI;
    import com.dnt.admin.EndStartDateCheck;
    import javax.swing.table.TableCellRenderer;
    import javax.swing.table.TableColumnModel;
    public class AutoPopRollBack extends JPanel {
    boolean selection = false;
    public static final int HAND_CURSOR = 12;
    Cursor cursor = new Cursor(HAND_CURSOR);
    int selectedRow = -1;
    ImageIcon headertop1 = new ImageIcon("./images/k2topbar.gif");
    JLabel HeaderLabe = new JLabel(headertop1);
    Border border1 = new EtchedBorder(EtchedBorder.RAISED, Color.white, Color.blue);
    Border border2 = BorderFactory.createBevelBorder(BevelBorder.RAISED,
    new Color(154, 254, 211), new Color(108, 178, 148),
    new Color(37, 60, 50), new Color(53, 87, 72));
    DefaultTableModel dm = new DefaultTableModel();
    Vector searchlist = new Vector();
    Vector rows = new Vector();
    Vector returnList;
    Connectmagr objConnectmagr = new Connectmagr();
    JFrame frame = new JFrame();
    JLabel headlab = new JLabel();
    JCalendarComboBox EndDateTxt;
    JLabel HawbLab = new JLabel();
    JTextField HawbTxt = new JTextField();
    JLabel AgentLab = new JLabel();
    JLabel StartDateLab = new JLabel();
    JCalendarComboBox StartDateTxt;
    JComboBox AgentLBox = new JComboBox();
    JLabel EnddateLab = new JLabel();
    JPanel ReviewJobsPane = new JPanel();
    JButton SearchBtn = new JButton();
    ButtonUI ui = new com.sun.java.swing.plaf.motif.MotifButtonUI();
    ArrayList AgentList = new ArrayList();
    JComboBox DocTypeLBox = new JComboBox();
    JLabel doctypelab = new JLabel();
    JPanel displayPanel = new JPanel();
    ButtonGroup group1;
    JRadioButton rb;
    JTable table;
    public ArrayList jobList = new ArrayList();
    public AutoPopRollBack(JFrame frame, ArrayList agentArrayList) {
    this.frame = frame;
    this.AgentList = agentArrayList;
    try {
    jbInit();
    } catch (Exception e) {
    e.printStackTrace();
    public void jbInit() throws Exception {
    Calendar cal = Calendar.getInstance();
    Locale loc = new Locale("");
    SimpleDateFormat dateformat = new SimpleDateFormat("dd/MM/yyyy");
    EndDateTxt = new JCalendarComboBox(cal, loc, dateformat);
    StartDateTxt = new JCalendarComboBox(cal, loc, dateformat);
    HeaderLabe.setBackground(new Color(250, 233, 216));
    HeaderLabe.setBounds(new Rectangle(0, 0, 830, 33));
    this.setLayout(null);
    this.setBackground(SystemColor.control);
    headlab.setBackground(new Color(250, 233, 216));
    headlab.setFont(new java.awt.Font("Verdana", 1, 12));
    headlab.setForeground(Color.blue);
    headlab.setHorizontalAlignment(SwingConstants.CENTER);
    headlab.setText(" :: Auto Population Rollback");
    headlab.setBounds(new Rectangle(39, 2, 247, 25));
    EndDateTxt.setBounds(new Rectangle(474, 36, 116, 18));
    EndDateTxt.setBackground(Color.white);
    EndDateTxt.setFont(new java.awt.Font("Times New Roman", 1, 10));
    EndDateTxt.setForeground(Color.blue);
    EndDateTxt.setBorder(null);
    HawbLab.setFont(new java.awt.Font("Dialog", 0, 13));
    HawbLab.setForeground(Color.blue);
    HawbLab.setHorizontalAlignment(SwingConstants.RIGHT);
    HawbLab.setText("Job No/Airway Bill No:");
    HawbLab.setBounds(new Rectangle(326, 14, 146, 18));
    HawbTxt.setBounds(new Rectangle(474, 14, 125, 18));
    HawbTxt.setText("");
    HawbTxt.setFont(new java.awt.Font("Times New Roman", 1, 10));
    HawbTxt.setForeground(Color.blue);
    HawbTxt.setBorder(border1);
    AgentLab.setFont(new java.awt.Font("Dialog", 0, 13));
    AgentLab.setForeground(Color.blue);
    AgentLab.setHorizontalAlignment(SwingConstants.RIGHT);
    AgentLab.setText("<html>Agent:<font size=\'4\' color=\"#993333\">*</font></html>");
    AgentLab.setBounds(new Rectangle(31, 14, 97, 18));
    StartDateLab.setFont(new java.awt.Font("Dialog", 0, 13));
    StartDateLab.setForeground(Color.blue);
    StartDateLab.setHorizontalAlignment(SwingConstants.RIGHT);
    StartDateLab.setText("Start Date:");
    StartDateLab.setBounds(new Rectangle(23, 36, 105, 18));
    StartDateTxt.setBounds(new Rectangle(129, 36, 116, 18));
    StartDateTxt.setBackground(Color.white);
    StartDateTxt.setFont(new java.awt.Font("Times New Roman", 1, 10));
    StartDateTxt.setForeground(Color.blue);
    StartDateTxt.setBorder(null);
    AgentLBox.setBackground(Color.white);
    AgentLBox.setFont(new java.awt.Font("Verdana", 0, 13));
    AgentLBox.setForeground(Color.blue);
    AgentLBox.setBounds(new Rectangle(129, 14, 178, 18));
    AgentLBox.setFont(new java.awt.Font("Times New Roman", 1, 10));
    EnddateLab.setFont(new java.awt.Font("Dialog", 0, 13));
    EnddateLab.setForeground(Color.blue);
    EnddateLab.setHorizontalAlignment(SwingConstants.RIGHT);
    EnddateLab.setText("End Date:");
    EnddateLab.setBounds(new Rectangle(391, 36, 81, 18));
    ReviewJobsPane.setBackground(new Color(240, 233, 216));
    ReviewJobsPane.setBorder(BorderFactory.createLineBorder(Color.black));
    ReviewJobsPane.setBounds(new Rectangle(69, 47, 705, 96));
    ReviewJobsPane.setLayout(null);
    SearchBtn.setUI(ui);
    SearchBtn.setCursor(cursor);
    SearchBtn.setBackground(new Color(76, 125, 104));
    SearchBtn.setBounds(new Rectangle(377, 153, 89, 19));
    SearchBtn.setFont(new java.awt.Font("Tahoma", 1, 10));
    SearchBtn.setForeground(Color.white);
    SearchBtn.setBorder(border2);
    SearchBtn.setOpaque(true);
    SearchBtn.setFocusPainted(false);
    SearchBtn.setText("Search");
    SearchBtn.addActionListener(new AutoPopRollBack_SearchBtn_actionAdapter(this));
    for (int i = 0; i < AgentList.size(); i++)
    AgentLBox.addItem( (String) AgentList.get(i));
    DocTypeLBox.setFont(new java.awt.Font("Verdana", 0, 13));
    DocTypeLBox.setForeground(Color.blue);
    DocTypeLBox.setMinimumSize(new Dimension(22, 19));
    DocTypeLBox.setBounds(new Rectangle(129, 58, 179, 18));
    DocTypeLBox.setFont(new java.awt.Font("Times New Roman", 1, 10));
    DocTypeLBox.addItem("New Jobs");
    DocTypeLBox.addItem("Draft jobs");
    DocTypeLBox.addItem("Finished jobs");
    doctypelab.setBounds(new Rectangle(7, 58, 121, 18));
    doctypelab.setText("<html>Document Type:<font size=\'4\' color=\"#993333\">*</font></html>");
    doctypelab.setHorizontalAlignment(SwingConstants.RIGHT);
    doctypelab.setForeground(Color.blue);
    doctypelab.setFont(new java.awt.Font("Dialog", 0, 13));
    displayPanel.setBorder(BorderFactory.createLineBorder(Color.black));
    displayPanel.setBounds(new Rectangle(69, 182, 705, 315));
    this.add(headlab, null);
    this.add(HeaderLabe, null);
    this.add(ReviewJobsPane, null);
    ReviewJobsPane.add(HawbLab, null);
    ReviewJobsPane.add(AgentLab, null);
    ReviewJobsPane.add(AgentLBox, null);
    ReviewJobsPane.add(StartDateLab, null);
    ReviewJobsPane.add(StartDateTxt, null);
    ReviewJobsPane.add(HawbTxt, null);
    ReviewJobsPane.add(EnddateLab, null);
    ReviewJobsPane.add(EndDateTxt, null);
    ReviewJobsPane.add(DocTypeLBox, null);
    ReviewJobsPane.add(doctypelab, null);
    this.add(SearchBtn, null);
    this.add(displayPanel, null);
    //this.add(scrollPaneView, null);
    // scrollPaneView.getViewport().add(displayPanel, null);
    this.setVisible(true);
    void FieldEditable(boolean str) {
    StartDateTxt.setEnabled(str);
    EndDateTxt.setEnabled(str);
    public static void main(String args[]) {
    JFrame frame = new JFrame();
    ArrayList agentlist = new ArrayList();
    agentlist.add(0, "BF0651");
    agentlist.add(1, "PF0010");
    AutoPopRollBack objAutoPopRollBack = new AutoPopRollBack(frame, agentlist);
    frame.getContentPane().add(objAutoPopRollBack);
    frame.setBounds(new Rectangle(0, 0, 820, 593));
    frame.setVisible(true);
    void SearchBtn_actionPerformed(ActionEvent e) {
    displayPanel.setVisible(false);
    Vector data=new Vector();
    rows.removeAllElements();
    boolean flag = true;
    String che = new EndStartDateCheck().crossCheck(StartDateTxt.getCalendar(), EndDateTxt.getCalendar());
    try {
    if(HawbTxt.getText().equalsIgnoreCase("")){
    if (StartDateTxt._spinner.getText().equalsIgnoreCase("")) {
    JOptionPane.showMessageDialog(this, "Please Select Start Date",
    "Warning", JOptionPane.WARNING_MESSAGE);
    flag = false;
    else if (!che.equalsIgnoreCase("")) {
    JOptionPane.showMessageDialog(frame, che, "Message Window", JOptionPane.INFORMATION_MESSAGE);
    flag = false;
    }else{
    FieldEditable(true);
    if (flag) {
    try {
    displayPanel.removeAll();
    } catch (Exception ex) {
    rows.removeAllElements();
    data.removeAllElements();
    SearchBtn.setEnabled(true);
    searchlist.add(0, AgentLBox.getSelectedItem().toString().trim());
    if (!HawbTxt.getText().trim().equalsIgnoreCase(""))
    searchlist.add(1, HawbTxt.getText().toString().trim());
    else
    searchlist.add(1, "");
    searchlist.add(2, new Integer(DocTypeLBox.getSelectedIndex() + 1));
    String startDate = new ConvertDate().convertddMM_To_MMdd(StartDateTxt._spinner.getText());
    String endDate = new ConvertDate().convertddMM_To_MMdd(EndDateTxt._spinner.getText());
    Vector columns = new Vector();
    columns.add(0, "");
    columns.add(1, "JOB No");
    columns.add(2, "Status");
    columns.add(3, "Current Form Type");
    columns.add(4, "New Form Type");
    System.out.println("Before calling Data Base");
    jobList = objConnectmagr.AutoRollBackSearch(searchlist, startDate, endDate, "AutoPopRollBack");
    if (jobList.size() > 0) {
    for (int i = 0; i < jobList.size(); i++) {
    ArrayList temp = new ArrayList();
    temp = (ArrayList) jobList.get(i);
    Vector col = new Vector();
    col.add(0, new Boolean(false));
    col.add(1, temp.get(0).toString().trim());
    col.add(2, temp.get(1).toString().trim());
    col.add(3, temp.get(2).toString().trim());
    Vector tempstr=new Vector();
    String [] tem=temp.get(3).toString().trim().split("\\|");
    tempstr.removeAllElements();
    for(int k=0;k<tem.length;k++)
    tempstr.add(k,tem[k]);
    col.add(4, new JComboBox(tempstr));
    data.add(col);
    dm.setDataVector(data, columns);
    table = new JTable(dm) {
    public void tableChanged(TableModelEvent e) {
    super.tableChanged(e);
    public boolean isCellEditable(int rowIndex, int vColIndex) {
    return true;
    JScrollPane scroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    table.setColumnSelectionAllowed(false);
    table.setRowSelectionAllowed(false);
    table.setCellSelectionEnabled(false);
    table.setBackground(SystemColor.inactiveCaptionText);
    table.setRowHeight(20);
    JTableHeader head = table.getTableHeader();
    head.setSize(850, 75);
    table.setTableHeader(head);
    table.getTableHeader().setFont(new Font("Verdana", Font.BOLD, 11));
    table.getTableHeader().setBackground(new Color(130, 170, 150));
    table.getTableHeader().setForeground(Color.BLUE);
    table.getTableHeader().setReorderingAllowed(false);
    table.getTableHeader().setResizingAllowed(false);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    table.setFont(new java.awt.Font("MS Sans Serif", 0, 13));
    table.setForeground(new Color(125, 25, 0));
    TableColumn col = table.getColumnModel().getColumn(0);
    col.setMinWidth(75);
    col.setMaxWidth(75);
    TableColumn col1 = table.getColumnModel().getColumn(1);
    col1.setMinWidth(150);
    col1.setMaxWidth(150);
    TableColumn col2 = table.getColumnModel().getColumn(2);
    col2.setMinWidth(150);
    col2.setMaxWidth(150);
    TableColumn col3 = table.getColumnModel().getColumn(3);
    col3.setMinWidth(150);
    col3.setMaxWidth(150);
    TableColumn col4 = table.getColumnModel().getColumn(4);
    col4.setMinWidth(160);
    col4.setMaxWidth(160);
    TableColumn tc = table.getColumnModel().getColumn(0);
    tc.setCellEditor(table.getDefaultEditor(Boolean.class));
    tc.setCellRenderer(table.getDefaultRenderer(Boolean.class));
    tc.setHeaderRenderer(new CheckBoxHeader(new MyItemListener()));
    Vector tempstr=new Vector();
    for(int j=0;j<jobList.size();j++){
    ArrayList temlist=(ArrayList)jobList.get(j);
    String [] tem=temlist.get(3).toString().trim().split("\\|");
    tempstr.removeAllElements();
    for(int k=0;k<tem.length;k++)
    tempstr.add(k,tem[k]);
    JComboBox portTypesCombo = new JComboBox(tempstr);
    col4.setCellEditor(new DefaultCellEditor(portTypesCombo));
    col4 = table.getColumnModel().getColumn(4);
    col4.setCellEditor(new MyComboBoxEditor(tempstr));
    // If the cell should appear like a combobox in its
    // non-editing state, also set the combobox renderer
    col4.setCellRenderer(new MyComboBoxRenderer(tempstr));
    System.out.println(tempstr);
    displayPanel.setLayout(new BorderLayout());
    displayPanel.add(table.getTableHeader(), BorderLayout.PAGE_START);
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
    table.setEditingColumn(0);
    int column = 0;
    if (e.getClickCount() == 1) {
    Point p = e.getPoint();
    selectedRow = table.rowAtPoint(p);
    column = table.columnAtPoint(p);
    System.out.println(table.isCellEditable(selectedRow, column));
    if (column != 0) {
    selectedRow = -1;
    returnList = new Vector();
    returnList = (Vector) rows.get(selectedRow);
    else if (column == 0) {
    table.revalidate();
    table.repaint();
    scroll.getViewport().add(table);
    displayPanel.add(scroll, BorderLayout.CENTER);
    displayPanel.setVisible(true);
    else {
    JOptionPane.showMessageDialog(this, "No Data Available");
    } catch (Exception e1) {
    e1.printStackTrace();
    class MyItemListener implements ItemListener {
    public void itemStateChanged(ItemEvent e) {
    Object source = e.getSource();
    if (source instanceof AbstractButton == false)return;
    boolean checked = e.getStateChange() == ItemEvent.SELECTED;
    for (int x = 0, y = table.getRowCount(); x < y; x++) {
    table.setValueAt(new Boolean(checked), x, 0);
    class AutoPopRollBack_SearchBtn_actionAdapter implements java.awt.event.ActionListener {
    AutoPopRollBack adaptee;
    AutoPopRollBack_SearchBtn_actionAdapter(AutoPopRollBack adaptee) {
    this.adaptee = adaptee;
    public void actionPerformed(ActionEvent e) {
    adaptee.SearchBtn_actionPerformed(e);
    class RadioButtonRenderer implements TableCellRenderer {
    public Component getTableCellRendererComponent(JTable table, Object value,
    boolean isSelected, boolean hasFocus, int row, int column) {
    if (value == null)return null;
    return (Component) value;
    class RadioButtonEditor extends DefaultCellEditor implements ItemListener {
    private JRadioButton button;
    public RadioButtonEditor(JCheckBox checkBox) {
    super(checkBox);
    public Component getTableCellEditorComponent(JTable table, Object value,
    boolean isSelected, int row,
    int column) {
    if (value == null)return null;
    button = (JRadioButton) value;
    button.addItemListener(this);
    return (Component) value;
    public Object getCellEditorValue() {
    button.removeItemListener(this);
    return button;
    public void itemStateChanged(ItemEvent e) {
    super.fireEditingStopped();
    class CheckCellRenderer extends JCheckBox implements TableCellRenderer {
    protected static Border m_noFocusBorder;
    public CheckCellRenderer() {
    super();
    m_noFocusBorder = new EmptyBorder(1, 2, 1, 2);
    setOpaque(true);
    setBorder(m_noFocusBorder);
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
    int row, int column) {
    if (value instanceof Boolean) {
    Boolean b = (Boolean) value;
    setSelected(b.booleanValue());
    setBackground(isSelected && !hasFocus ?
    table.getSelectionBackground() : table.getBackground());
    setForeground(isSelected && !hasFocus ?
    table.getSelectionForeground() : table.getForeground());
    setFont(table.getFont());
    setBorder(hasFocus ? UIManager.getBorder(
    "Table.focusCellHighlightBorder") : m_noFocusBorder);
    return this;
    class CheckBoxHeader extends JCheckBox implements TableCellRenderer, MouseListener {
    protected CheckBoxHeader rendererComponent;
    protected int column;
    protected boolean mousePressed = false;
    public CheckBoxHeader(ItemListener itemListener) {
    rendererComponent = this;
    rendererComponent.addItemListener(itemListener);
    public Component getTableCellRendererComponent(
    JTable table, Object value,
    boolean isSelected, boolean hasFocus, int row, int column) {
    if (table != null) {
    JTableHeader header = table.getTableHeader();
    if (header != null) {
    rendererComponent.setForeground(header.getForeground());
    rendererComponent.setBackground(header.getBackground());
    rendererComponent.setFont(new java.awt.Font("Verdana", 1, 10));
    header.addMouseListener(rendererComponent);
    setColumn(column);
    rendererComponent.setText("Select All");
    setBorder(UIManager.getBorder("TableHeader.cellBorder"));
    return rendererComponent;
    protected void setColumn(int column) {
    this.column = column;
    public int getColumn() {
    return column;
    protected void handleClickEvent(MouseEvent e) {
    if (mousePressed) {
    mousePressed = false;
    JTableHeader header = (JTableHeader) (e.getSource());
    JTable tableView = header.getTable();
    TableColumnModel columnModel = tableView.getColumnModel();
    int viewColumn = columnModel.getColumnIndexAtX(e.getX());
    int column = tableView.convertColumnIndexToModel(viewColumn);
    if (viewColumn == this.column && e.getClickCount() == 1 && column != -1) {
    doClick();
    public void mouseClicked(MouseEvent e) {
    handleClickEvent(e);
    ( (JTableHeader) e.getSource()).repaint();
    public void mousePressed(MouseEvent e) {
    mousePressed = true;
    public void mouseReleased(MouseEvent e) {
    public void mouseEntered(MouseEvent e) {
    public void mouseExited(MouseEvent e) {
    class MyComboBoxRenderer extends JComboBox implements TableCellRenderer {
    public MyComboBoxRenderer(Vector items) {
    super(items);
    public Component getTableCellRendererComponent(JTable table, Object value,
    boolean isSelected, boolean hasFocus, int row, int column) {
    if (isSelected) {
    setForeground(table.getSelectionForeground());
    super.setBackground(table.getSelectionBackground());
    else {
    setForeground(table.getForeground());
    setBackground(table.getBackground());
    // Select the current value
    setSelectedItem(value);
    return this;
    class MyComboBoxEditor extends DefaultCellEditor {
    public MyComboBoxEditor(Vector items) {
    super(new JComboBox(items));
    and Bringing data from data base by using this method
    if (i == 0) sqlString = "SELECT * FROM FLIGHTSEARCH WHERE AGENT_CODE='" + agentCode + "' and ISSUEDATE BETWEEN '" + startDate + "' and '" + endDate + "'";
    else sqlString = "SELECT * FROM FLIGHTSEARCH WHERE AGENT_CODE='" + agentCode + "' and JOB_NO='" + JobNo + "%'";
    st = con.createStatement();
    System.out.println("---new jobs search-->" + sqlString);
    rs = st.executeQuery(sqlString);
    while (rs.next()) {
    retVector = new ArrayList();
    retVector.add(0, rs.getString("JOBNO"));
    retVector.add(1, "New Job");
    retVector.add(2, rs.getString("DOC_TYPE"));
    String temp="";
    if(retVector.get(2).toString().trim().equalsIgnoreCase("K1")){
    temp="K8I|K8T";
    }else if(retVector.get(2).toString().trim().equalsIgnoreCase("K2")){
    temp="K8E";
    }else if(retVector.get(2).toString().trim().equalsIgnoreCase("K8I")){
    // temp="K1|K8T";
    }else if(retVector.get(2).toString().trim().equalsIgnoreCase("K8T")){
    temp="K1|K8I";
    }else if(retVector.get(2).toString().trim().equalsIgnoreCase("K8E")){
    temp="K2";
    retVector.add(3,temp);
    retVector.add(3, rs.getString("AGENT_CODE"));
    retVectorlist.add(retVector);
    i am sending data To ComboBox like this
    if(retVector.get(2).toString().trim().equalsIgnoreCase("K1")){
    K8I and K8T
    if K2 adding k8E and for other types as mentioned above
    But for ComboBoxes it is showing same Items not changing
    Please any body can help to me
    Thanks and Regards
    Ravichandra

    If you want further help post a Short, Self Contained, Compilable and Executable, Example Program ([url http://homepage1.nifty.com/algafield/sscce.html]SSCCE) that demonstrates the problem.
    And don't forget to use [url http://forum.java.sun.com/help.jspa?sec=formatting]code formatting when posting code.

  • I need a solution to restrict the acccess by using only one role....

    ///obs_login_html.jsp//
    <%@ page import="org.ticker.*"%>
    <%@ page language="java"
    contentType="text/html; charset=UTF-8"
    session="true"
    import="com.hp.ov.ui.client.common.util.TimeZoneUtils,
    com.hp.ov.obs.rep.IRepositoryObject,
    com.hp.ifc.rep.AppTimeZoneInfo"
    %>
    <%
    readMsg msg=new readMsg();
    String strMessage=msg.sendMsg();
    %>
    <%!
    final static String portalTitle = "K-C Self Help Site";
    final static String portalTitle1 = " ***If you are ITS or use the full client, do not use this portal***";
    final static String resourceBundle = "login";
    final static String login = "Login";
    final static String prompt = "Please enter your user name and password";
    final static String userName = "User name:";
    final static String password = "Password:";
    final static String timeZone = "Timezone:";
    final static String userDefaultTZ = "User Default";
    private String getLocalizedString(HttpServletRequest request, String name, String text)
    com.hp.ov.portal.util.OVResourceBundle bundle = com.hp.ov.portal.util.OVResourceBundle.getBundle(request, name, true);
    return bundle.getString(text);
    %>
    <jsp:useBean id="error_msg" scope="session"
    class="com.hp.ov.portal.security.LoginErrorMsg" />
    <html>
    <head>
    <title><%=getLocalizedString(request,resourceBundle,portalTitle)%> - <%=getLocalizedString(request,resourceBundle,portalTitle)%> - <%=getLocalizedString(request,resourceBundle,login)%></title>
    <link rel='stylesheet' type='text/css' href='/OvSipDocs/Skins/Chrome/Chrome.css' />
    <script language="JavaScript" type="text/javascript">
    <!--
    function nsubmit() {
    document.pwform.J_PASSWORD.focus();
    return false;
    function pwsubmit() {
    document.pwform.J_USERNAME.value = document.nform.J_USERNAME.value;
    return true;
    //-->
    </script>
    </head>
    <body bgcolor="white" text="black" onload='document.nform.J_USERNAME.focus()'>
    <table cellpadding="0" cellspacing="0" border="0" width="100%">
    <tr bgcolor="darkblue">
    <td>
         <font color="white">
         <b> <%=getLocalizedString(request,resourceBundle,portalTitle)%></b>
         </font>
         </td>
    </tr>
    </table>
    <br>
    <table cellpadding="0" cellspacing="0" border="0" width="55%">
    <tr bgcolor="white">
    <td>
         <font color="red" size="4">
         <b> <%=getLocalizedString(request,resourceBundle,portalTitle1)%></b>
         </font>
         </td>
    </tr>
    </table>
    <br>
    <br>
    <br>
    <table border='0' cellspacing='0' cellpadding='0' class='paneltable' width='45%'>
    <tr>
    <td class='paneltopleftround'><img src='/OvSipDocs/C/images/framework/clear.gif' width='24' height='10'/></td>
    <td class='paneltopround'><img src='/OvSipDocs/C/images/framework/clear.gif' height='10'/></td>
    <td class='paneltoprightround'><img src='/OvSipDocs/C/images/framework/clear.gif' width='24' height='10'/></td>
    </tr>
    <tr>
    <td class='panelleft'> </td>
    <td class='panel'>
    <table>
    <tr >
    <td nowrap>
    <font color='black'>
    <%
    String message = error_msg.getErrorMsg();
    if (message != null) {
    out.println("<h2>" message "</h2>");
    %>
    <h2><%=getLocalizedString(request,resourceBundle,prompt)%></h2>
    </font>
    </td>
    </tr>
    <tr >
    <td>
    <form name="nform" action="<%=request.getContextPath()%>/" onsubmit="return nsubmit()" method="post">
    <table>
    <tr>
    <td><%=getLocalizedString(request,resourceBundle,userName)%></td>
    <td><input type="text" name="J_USERNAME" size="30"/></td></tr>
    <script language="JavaScript" type="text/javascript">
    <!--
    document.write('<\/form><form name="pwform" action="<%=request.getContextPath()%>/" onSubmit="return pwsubmit()" method="post">')
    //-->
    </script>
    <input type="hidden" name="J_USERNAME" value="" />
    <tr>
    <td><%=getLocalizedString(request,resourceBundle,password)%></td>
    <td><input type="password" name="J_PASSWORD" size="30"/></td>
    </tr>
    <%
    AppTimeZoneInfo tzis[] = TimeZoneUtils.getTimeZones();
    if (tzis != null) {
    %>
    <tr>
    <td><%=getLocalizedString(request,resourceBundle,timeZone)%></td>
    <td>
    <select name="Timezone">
    <option selected="true" value=""><%=userDefaultTZ%></option>
    <%
    for (int i = 0; i < tzis.length; i++) {
    AppTimeZoneInfo tzi = (AppTimeZoneInfo) tzis;
    if (tzi.getAdd()) {
    //if (tzi.enabled()) { //588 does no support enabled for timezones
    String timeZoneShortName = tzi.getShortName();
    String timeZoneInfo = TimeZoneUtils.buildTextTimeZone(tzi, false);
    %>
    <option value="<%=timeZoneShortName%>"><%=timeZoneInfo%></option>
    <%
    %>
    </select>
    </td>
    </tr>
    <%
    %>
    <tr>
    <td><input type="submit" value="<%=getLocalizedString(request,resourceBundle,login)%>"/></td>
    </tr>
    </table>
    </form>
    </td>
    </tr>
    </table>
    </td>
    <td class='panelright'> </td>
    </tr>
    <tr>
    <td class='panelbottomleft'><img src='/OvSipDocs/C/images/framework/clear.gif' width='24' height='17'/></td>
    <td class='panelbottom'> </td>
    <td class='panelbottomright'><img src='/OvSipDocs/C/images/framework/clear.gif' width='24' height='17'/></td>
    </tr>
    </table>
    <table>
    <tr bgcolor="darkblue">
         <font color=white face="Verdana">
    <script language="JavaScript1.2">
    //Response.Write("hello")
    </script>
    <script language="JavaScript1.2">
    //Specify the marquee's width (in pixels)
    screenSize = screen.availWidth;
    var marqueewidth = screenSize + "px"
    //Specify the marquee's height
    var marqueeheight="25px"
    //Specify the marquee's marquee speed (larger is faster 1-10)
    //var marqueespeed=2
    var marqueespeed=4
    //configure background color:
    var marqueebgcolor="rgb(0,128,192)"
    //Pause marquee onMousever (0=no. 1=yes)?
    var pauseit=1
    myMesg='<NOBR>****Welcome to K-C Self-Service HelpDesk Site****All K-C ITS users are requested to use HP Service Desk 4.5 Desktop Client Application to create / manage tickets****</NOBR>';
    var marqueecontent=myMesg
    marqueespeed=(document.all)? marqueespeed : Math.max(1, marqueespeed-1) //slow speed down by 1 for NS
    var copyspeed=marqueespeed
    var pausespeed=(pauseit==0)? copyspeed: 0
    var iedom=document.all||document.getElementById
    if (iedom)
    document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100px;left:-9000px">'+marqueecontent+'</span>')
    var actualwidth=''
    var cross_marquee, ns_marquee
    function populate(){
    if (iedom){
    cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
    cross_marquee.style.left=parseInt(marqueewidth)+8+"px"
    cross_marquee.innerHTML=marqueecontent
    actualwidth=document.all? temp.offsetWidth : document.getElementById("temp").offsetWidth
    else if (document.layers){
    ns_marquee=document.ns_marquee.document.ns_marquee2
    ns_marquee.left=parseInt(marqueewidth)+8
    ns_marquee.document.write(marqueecontent)
    ns_marquee.document.close()
    actualwidth=ns_marquee.document.width
    lefttime=setInterval("scrollmarquee()",20)
    window.onload=populate
    function scrollmarquee(){
    if (iedom){
    if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
    cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed+"px"
    else
    cross_marquee.style.left=parseInt(marqueewidth)+8+"px"
    else if (document.layers){
    if (ns_marquee.left>(actualwidth*(-1)+8))
    ns_marquee.left-=copyspeed
    else
    ns_marquee.left=parseInt(marqueewidth)+8
    if (iedom||document.layers){
    with (document){
    document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
    if (iedom){
    write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
    write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
    write('<div id="iemarquee" style="position:absolute;left:0px;top:0px"></div>')
    write('</div></div>')
    else if (document.layers){
    write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
    write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
    write('</ilayer>')
    document.write('</td></table>')
    </script>
    </font>
    </tr>
    </table>
    </body>
    </html>
    //obs_login_html_jsp.java//
    package org.apache.jsp;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.servlet.jsp.*;
    import org.apache.jasper.runtime.*;
    import org.ticker.*;
    import com.hp.ov.ui.client.common.util.TimeZoneUtils;
    import com.hp.ov.obs.rep.IRepositoryObject;
    import com.hp.ifc.rep.AppTimeZoneInfo;
    public class obs_login_html_jsp extends HttpJspBase {
    final static String portalTitle = "K-C Self-Service HelpDesk";
    final static String portalTitle1 = " ***If it is an URGENT call, please call the Service Desk ***";
    final static String portalTitle2 = " ***If you are ITS or use the full client, do not use this portal ***";
    final static String resourceBundle = "login";
    final static String login = "Login";
    final static String prompt = "Please enter your user name and password";
    final static String userName = "User name:";
    final static String password = "Password:";
    final static String timeZone = "Timezone:";
    final static String userDefaultTZ = "User Default";
    private String getLocalizedString(HttpServletRequest request, String name, String text)
    com.hp.ov.portal.util.OVResourceBundle bundle = com.hp.ov.portal.util.OVResourceBundle.getBundle(request, name, true);
    return bundle.getString(text);
    private static java.util.Vector jspxincludes;
    public java.util.List getIncludes() {
    return jspxincludes;
    public void _jspService(HttpServletRequest request, HttpServletResponse response)
    throws java.io.IOException, ServletException {
    JspFactory _jspxFactory = null;
    javax.servlet.jsp.PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter jspxout = null;
    try {
    _jspxFactory = JspFactory.getDefaultFactory();
    response.setContentType("text/html; charset=UTF-8");
    pageContext = _jspxFactory.getPageContext(this, request, response,
                   null, true, 8192, true);
    application = pageContext.getServletContext();
    config = pageContext.getServletConfig();
    session = pageContext.getSession();
    out = pageContext.getOut();
    jspxout = out;
    out.write("\r\n");
    out.write("\r\n\r\n");
    readMsg msg=new readMsg();
    String strMessage=msg.sendMsg();
    out.write("\r\n\r\n");
    out.write("\r\n\r\n");
    com.hp.ov.portal.security.LoginErrorMsg error_msg = null;
    synchronized (session) {
    error_msg = (com.hp.ov.portal.security.LoginErrorMsg) pageContext.getAttribute("error_msg", PageContext.SESSION_SCOPE);
    if (error_msg == null){
    try {
    error_msg = (com.hp.ov.portal.security.LoginErrorMsg) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "com.hp.ov.portal.security.LoginErrorMsg");
    } catch (ClassNotFoundException exc) {
    throw new InstantiationException(exc.getMessage());
    } catch (Exception exc) {
    throw new ServletException("Cannot create bean of class " + "com.hp.ov.portal.security.LoginErrorMsg", exc);
    pageContext.setAttribute("error_msg", error_msg, PageContext.SESSION_SCOPE);
    out.write("\r\n\r\n");
    out.write("<html>\r\n");
    out.write("<head>\r\n ");
    out.write("<title>");
    out.print(getLocalizedString(request,resourceBundle,portalTitle));
    out.write(" - ");
    out.print(getLocalizedString(request,resourceBundle,portalTitle));
    out.write(" -");
    out.print(getLocalizedString(request,resourceBundle,portalTitle));
    out.write("- ");
    out.print(getLocalizedString(request,resourceBundle,login));
    out.write("</title>\r\n ");
    out.write("<link rel='stylesheet' type='text/css' href='/OvSipDocs/Skins/Chrome/Chrome.css' />\r\n ");
    out.write("<script language=\"JavaScript\" type=\"text/javascript\">\r\n");
    out.write("<!--\r\n function nsubmit() {\r\n document.pwform.J_PASSWORD.focus();\r\n return false;\r\n }\r\n\r\n function pwsubmit() {\r\n document.pwform.J_USERNAME.value = document.nform.J_USERNAME.value;\r\n \r\n\t\t return true;\r\n }\r\n//-->\r\n\r\n\r\n ");
    out.write("</script>\r\n\r\n");
    out.write("</head>\r\n\r\n");
    out.write("<body bgcolor=\"white\" text=\"black\" onload='document.nform.J_USERNAME.focus()'>\r\n\r\n ");
    out.write("<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">\r\n ");
    out.write("<tr bgcolor=\"darkblue\">\r\n ");
    out.write("<td>\r\n\t ");
    out.write("<font color=\"white\">\r\n\t ");
    out.write("<b> ");
    out.print(getLocalizedString(request,resourceBundle,portalTitle));
    out.write("</b>\r\n\t ");
    out.write("</font>\r\n\t ");
    out.write("</td>\r\n ");
    out.write("</tr>\r\n ");
    out.write("</table>\r\n ");
    out.write("<br> \r\n");
    out.write("<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"55%\">\r\n");
    out.write("<tr bgcolor=\"white\">\r\n");
    out.write("<td>\r\n\t ");
    out.write("<font color=\"red\" size=\"4\">\r\n\t ");
    out.write("<b> ");
    out.print(getLocalizedString(request,resourceBundle,portalTitle1));
    out.write("</b>\r\n\t ");
    out.write("</font>\r\n\t ");
    out.write("</td>\r\n");
    out.write("</tr>\r\n");
    out.write("</table>\r\n");
    out.write("<br> \r\n");
    out.write("<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"55%\">\r\n");
    out.write("<tr bgcolor=\"white\">\r\n");
    out.write("<td>\r\n\t ");
    out.write("<font color=\"red\" size=\"4\">\r\n\t ");
    out.write("<b> ");
    out.print(getLocalizedString(request,resourceBundle,portalTitle2));
    out.write("</b>\r\n\t ");
    out.write("</font>\r\n\t ");
    out.write("</td>\r\n");
    out.write("</tr>\r\n");
    out.write("</table>\r\n");
    out.write("<br>\r\n ");
    out.write("<br>\r\n");
    out.write("<br>\r\n ");
    out.write("<table border='0' cellspacing='0' cellpadding='0' class='paneltable' width='45%'>\r\n ");
    out.write("<tr>\r\n ");
    out.write("<td class='paneltopleftround'>");
    out.write("<img src='/OvSipDocs/C/images/framework/clear.gif' width='24' height='10'/>");
    out.write("</td>\r\n ");
    out.write("<td class='paneltopround'>");
    out.write("<img src='/OvSipDocs/C/images/framework/clear.gif' height='10'/>");
    out.write("</td>\r\n ");
    out.write("<td class='paneltoprightround'>");
    out.write("<img src='/OvSipDocs/C/images/framework/clear.gif' width='24' height='10'/>");
    out.write("</td>\r\n ");
    out.write("</tr>\r\n\r\n ");
    out.write("<tr>\r\n ");
    out.write("<td class='panelleft'> ");
    out.write("</td>\r\n ");
    out.write("<td class='panel'>\r\n ");
    out.write("<table>\r\n ");
    out.write("<tr >\r\n ");
    out.write("<td nowrap>\r\n ");
    out.write("<font color='black'>\r\n\r\n ");
    String message = error_msg.getErrorMsg();
    if (message != null) {
    out.println("<h2>" message "</h2>");
    out.write("\r\n\r\n ");
    out.write("<h2>");
    out.print(getLocalizedString(request,resourceBundle,prompt));
    out.write("</h2>\r\n ");
    out.write("</font>\r\n ");
    out.write("</td>\r\n ");
    out.write("</tr>\r\n ");
    out.write("<tr >\r\n ");
    out.write("<td>\r\n\r\n ");
    out.write("<form name=\"nform\" action=\"");
    out.print(request.getContextPath());
    out.write("/\" onsubmit=\"return nsubmit()\" method=\"post\">\r\n ");
    out.write("<table>\r\n ");
    out.write("<tr>\r\n ");
    out.write("<td>");
    out.print(getLocalizedString(request,resourceBundle,userName));
    out.write("</td>\r\n ");
    out.write("<td>");
    out.write("<input type=\"text\" name=\"J_USERNAME\" size=\"30\"/>");
    out.write("</td>");
    out.write("</tr>\r\n ");
    out.write("<script language=\"JavaScript\" type=\"text/javascript\">\r\n");
    out.write("<!--\r\n document.write('");
    out.write("<\\/form>");
    out.write("<form name=\"pwform\" action=\"");
    out.print(request.getContextPath());
    out.write("/\" onSubmit=\"return pwsubmit()\" method=\"post\">')\r\n//-->\r\n ");
    out.write("</script>\r\n ");
    out.write("<input type=\"hidden\" name=\"J_USERNAME\" value=\"\" />\r\n ");
    out.write("<tr>\r\n ");
    out.write("<td>");
    out.print(getLocalizedString(request,resourceBundle,password));
    out.write("</td>\r\n ");
    out.write("<td>");
    out.write("<input type=\"password\" name=\"J_PASSWORD\" size=\"30\"/>");
    out.write("</td>\r\n ");
    out.write("</tr>\r\n ");
    AppTimeZoneInfo tzis[] = TimeZoneUtils.getTimeZones();
    if (tzis != null) {
    out.write("\r\n ");
    out.write("<tr>\r\n ");
    out.write("<td>");
    out.print(getLocalizedString(request,resourceBundle,timeZone));
    out.write("</td>\r\n ");
    out.write("<td>\r\n ");
    out.write("<select name=\"Timezone\">\r\n ");
    out.write("<option selected=\"true\" value=\"\">");
    out.print(userDefaultTZ);
    out.write("</option>\r\n ");
    for (int i = 0; i < tzis.length; i++) {
    AppTimeZoneInfo tzi = (AppTimeZoneInfo) tzis[i];
    if (tzi.getAdd()) {
    //if (tzi.enabled()) { //588 does no support enabled for timezones
    String timeZoneShortName = tzi.getShortName();
    String timeZoneInfo = TimeZoneUtils.buildTextTimeZone(tzi, false);
    out.write("\r\n ");
    out.write("<option value=\"");
    out.print(timeZoneShortName);
    out.write("\">");
    out.print(timeZoneInfo);
    out.write("</option>\r\n ");
    out.write("\r\n ");
    out.write("</select>\r\n ");
    out.write("</td>\r\n ");
    out.write("</tr>\r\n ");
    out.write("\r\n ");
    out.write("<tr>\r\n ");
    out.write("<td>");
    out.write("<input type=\"submit\" value=\"");
    out.print(getLocalizedString(request,resourceBundle,login));
    out.write("\"/>");
    out.write("</td>\r\n ");
    out.write("</tr>\r\n ");
    out.write("</table>\r\n ");
    out.write("</form>\r\n ");
    out.write("</td>\r\n ");
    out.write("</tr>\r\n ");
    out.write("</table>\r\n\r\n ");
    out.write("</td>\r\n ");
    out.write("<td class='panelright'> ");
    out.write("</td>\r\n ");
    out.write("</tr>\r\n\r\n ");
    out.write("<tr>\r\n ");
    out.write("<td class='panelbottomleft'>");
    out.write("<img src='/OvSipDocs/C/images/framework/clear.gif' width='24' height='17'/>");
    out.write("</td>\r\n ");
    out.write("<td class='panelbottom'> ");
    out.write("</td>\r\n ");
    out.write("<td class='panelbottomright'>");
    out.write("<img src='/OvSipDocs/C/images/framework/clear.gif' width='24' height='17'/>");
    out.write("</td>\r\n ");
    out.write("</tr>\r\n\r\n\r\n");
    out.write("</table>\r\n\r\n ");
    out.write("<br/>\r\n ");
    out.write("<br/>\r\n ");
    out.write("<br/>\r\n \r\n\r\n");
    out.write("<br/>\r\n");
    out.write("<br/>\r\n");
    out.write("<br/>\r\n");
    out.write("<table>\r\n\r\n");
    out.write("<tr bgcolor=\"darkblue\">\r\n\r\n\t ");
    out.write("<font color=white face=\"Verdana\">\r\n\r\n");
    out.write("<script language=\"JavaScript1.2\">\r\n//Response.Write(\"hello\")\r\n\r\n");
    out.write("</script>\r\n");
    out.write("<script language=\"JavaScript1.2\">\r\n\r\n\r\n//Specify the marquee's width (in pixels)\r\nscreenSize = screen.availWidth;\r\n\r\nvar marqueewidth = screenSize + \"px\"\r\n//Specify the marquee's height\r\nvar marqueeheight=\"25px\"\r\n//Specify the marquee's marquee speed (larger is faster 1-10)\r\n//var marqueespeed=2\r\nvar marqueespeed=4\r\n//configure background color:\r\nvar marqueebgcolor=\"rgb(0,128,192)\"\r\n//Pause marquee onMousever (0=no. 1=yes)?\r\nvar pauseit=1\r\n\r\n\r\n\r\nmyMesg='");
    out.write("<NOBR>****Welcome to K-C Self-Service HelpDesk Site****All K-C ITS users are requested to use HP Service Desk 4.5 Desktop Client Application to create / manage tickets****");
    out.write("</NOBR>';\r\nvar marqueecontent=myMesg\r\n\r\n\r\n\r\nmarqueespeed=(document.all)? marqueespeed : Math.max(1, marqueespeed-1) //slow speed down by 1 for NS\r\n\r\nvar copyspeed=marqueespeed\r\nvar pausespeed=(pauseit==0)? copyspeed: 0\r\nvar iedom=document.all||document.getElementById\r\n\r\nif (iedom)\r\ndocument.write('");
    out.write("<span id=\"temp\" style=\"visibility:hidden;position:absolute;top:-100px;left:-9000px\">'+marqueecontent+'");
    out.write("</span>')\r\n\r\nvar actualwidth=''\r\nvar cross_marquee, ns_marquee\r\n\r\nfunction populate(){\r\n\t\r\nif (iedom){\r\n\t\r\ncross_marquee=document.getElementById? document.getElementById(\"iemarquee\") : document.all.iemarquee\r\ncross_marquee.style.left=parseInt(marqueewidth)+8+\"px\"\r\ncross_marquee.innerHTML=marqueecontent\r\nactualwidth=document.all? temp.offsetWidth : document.getElementById(\"temp\").offsetWidth\r\n}\r\nelse if (document.layers){\r\n\t\r\nns_marquee=document.ns_marquee.document.ns_marquee2\r\nns_marquee.left=parseInt(marqueewidth)+8\r\nns_marquee.document.write(marqueecontent)\r\nns_marquee.document.close()\r\nactualwidth=ns_marquee.document.width\r\n}\r\n\r\nlefttime=setInterval(\"scrollmarquee()\",20)\r\n\r\n}\r\n\r\nwindow.onload=populate\r\n\r\n\r\nfunction scrollmarquee(){\r\n\t\r\nif (iedom){\r\n\t\r\nif (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))\r\ncross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed+\"px\"\r\nelse\r\ncross_marquee.style.left=parseInt(marqueewidth)+8+\"px\"\r\n\r\n}\r\nelse if (document.layers){\r\nif (ns_marquee.left>(actualwidth*(-1)+8))\r\n");
    out.write("ns_marquee.left-=copyspeed\r\nelse\r\nns_marquee.left=parseInt(marqueewidth)+8\r\n}\r\n}\r\n\r\nif (iedom||document.layers){\r\n\t\r\nwith (document){\r\n\t\r\ndocument.write('");
    out.write("<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
    out.write("<td>')\r\nif (iedom){\r\nwrite('");
    out.write("<div style=\"position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden\">')\r\nwrite('");
    out.write("<div style=\"position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'\" onMouseover=\"copyspeed=pausespeed\" onMouseout=\"copyspeed=marqueespeed\">')\r\nwrite('");
    out.write("<div id=\"iemarquee\" style=\"position:absolute;left:0px;top:0px\">");
    out.write("</div>')\r\nwrite('");
    out.write("</div>");
    out.write("</div>')\r\n}\r\nelse if (document.layers){\r\nwrite('");
    out.write("<ilayer width='+marqueewidth+' height='+marqueeheight+' name=\"ns_marquee\" bgColor='+marqueebgcolor+'>')\r\nwrite('");
    out.write("<layer name=\"ns_marquee2\" left=0 top=0 onMouseover=\"copyspeed=pausespeed\" onMouseout=\"copyspeed=marqueespeed\">");
    out.write("</layer>')\r\nwrite('");
    out.write("</ilayer>')\r\n}\r\ndocument.write('");
    out.write("</td>");
    out.write("</table>')\r\n}\r\n}\r\n\r\n");
    out.write("</script>\r\n\r\n");
    out.write("</font>\r\n\r\n");
    out.write("</tr>\r\n ");
    out.write("</table>\r\n\r\n");
    out.write("</body>\r\n");
    out.write("</html>\r\n");
    } catch (Throwable t) {
    out = jspxout;
    if (out != null && out.getBufferSize() != 0)
    out.clearBuffer();
    if (pageContext != null) pageContext.handlePageException(t);
    } finally {
    if (_jspxFactory != null) _jspxFactory.releasePageContext(pageContext);
    //portalpage_html_jsp.java//
    package org.apache.jsp;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.servlet.jsp.*;
    import org.apache.jasper.runtime.*;
    import java.util.List;
    import java.util.Iterator;
    import java.util.Date;
    import java.text.DateFormat;
    import com.hp.ov.portal.core.Profile;
    import com.hp.ov.portal.util.NameAndTitle;
    import com.hp.ov.portal.util.Pair;
    import com.hp.ov.portal.util.PortalIDs;
    import java.util.List;
    import java.util.Iterator;
    import com.hp.ov.portal.util.OVResourceBundle;
    import com.hp.ov.portal.core.Profile;
    import com.hp.ov.portal.core.AdminBean;
    import com.hp.ov.portal.util.NameAndTitle;
    import com.hp.ov.portal.util.PortalIDs;
    public class portalpage_html_jsp extends HttpJspBase {
    The following imports must be made in any jsp which includes this page
    via: <%@ include file="common.jsp" %>
    import="java.util.List,
    java.util.Iterator,
              com.hp.ov.portal.core.Profile,
    com.hp.ov.portal.util.NameAndTitle,
    com.hp.ov.portal.util.OVResourceBundle,
              com.hp.ov.portal.util.PortalIDs"
    final static String portalTitle = "HP OpenView Web Console";
    // The following are for the toolbar buttons
    final static String toolbarOptsLabel = "Options";
    final static String toolbarOptsImg = "/OvSipDocs/C/images/framework/opt_icon.gif";
    final static String toolbarAdminLabel = "Admin";
    final static String toolbarAdminImg = "/OvSipDocs/C/images/framework/opt_icon.gif";
    final static String toolbarHomeLabel = "Home";
    final static String toolbarHomeImg = "/OvSipDocs/C/images/framework/opt_icon.gif";
    final static String toolbarLogoutLabel = "Logout";
    final static String toolbarLogoutImg = "/OvSipDocs/C/images/framework/logout_icon.gif";
    final static String toolbarHelpLabel = "Help";
    final static String toolbarHelpImg = "/OvSipDocs/C/images/framework/hlp_icon.gif";
    final static String toolbarOKLabel = "OK";
    final static String toolbarOKImg = null;
    final static String toolbarCancelLabel = "Cancel";
    final static String toolbarCancelImg = null;
    final static String toolbarCloseLabel = "Close";
    final static String toolbarCloseImg = null;
    final static String toolbarApplyLabel = "Apply";
    final static String toolbarApplyImg = null;
    final static String toolbarResetLabel = "Reset";
    final static String toolbarResetImg = null;
    // These are the strings and URLs for the module titlebar area
    final static String moduleEditImg = "/OvSipDocs/C/images/framework/edit.gif";
    final static String moduleEditTxt = "Edit";
    final static String moduleHelpImg = "/OvSipDocs/C/images/framework/help.gif";
    final static String moduleHelpTxt = "Help";
    final static String moduleDetachImg = "/OvSipDocs/C/images/framework/detach.gif";
    final static String moduleDetachTxt = "Detach";
    final static String moduleDeleteImg = "/OvSipDocs/C/images/framework/x.gif";
    final static String moduleDeleteTxt = "Remove";
    final static String moduleDeleteMsg = "Are you sure you want to remove this module? This can not be undone.";
    final static String moduleRollUpTxt = "Roll Up";
    final static String moduleRollDnTxt = "Roll Down";
    final static String moduleRollUpImg = "/OvSipDocs/C/images/framework/rolledup.gif";
    final static String moduleRollDnImg = "/OvSipDocs/C/images/framework/rolleddn.gif";
    private String getLocalizedString(Profile profile, String name, String text)
    HttpServletRequest r

    Hi
    This is a repeated post, posted twice before.
    Thread 1, Thread 2
    I have the followings suggestions for you:
    1. Please post your requirement in the body of the message and not in the 'subject line'.
    2. Please do not open multiple threads for the same query.
    3. Since you have already posted this on the Job Openings forum, please do not repeat this here. You will definetly get a response to your job post in the other forum.

  • I need help with my for loop in this array

    Ok well, I can't get my code to work. Also, please remember that this is just my draft so it isnt pretty. I will fix it up later so please look at it. The thing I want to do is look into the array for a time that matches what the user entered and return the toString() of that one. I know there is something wrong with my for loop but I cant figure how to fix it. please help. here is what i have so far:
    import javax.swing.JOptionPane;
    public class Runner
        public static void main (String[] args)
            String timeStr;
            int time, again, optiStr;
            Inbound[] in = new Inbound[25];
             in[0]=new Inbound ("",0,"On Time num0");
             in[1]=new Inbound ("",2,"On Time num1");
             in[2]=new Inbound ("",3,"Delayed num2");
             in[3]=new Inbound ("",4,"On Time");
             in[4]=new Inbound ("",5,"On Time");
             in[5]=new Inbound ("",6,"Canceled");
             in[6]=new Inbound ("",1,"Canceled num6");
             in[7]=new Inbound ("",8,"On Time");
             in[8]=new Inbound ("",9,"Delayed");
             in[9]=new Inbound ("",10,"On Time");
             in[10]=new Inbound ("",11,"Delayed");
             in[11]=new Inbound ("",12,"On Time");
             in[12]=new Inbound ("",13,"Delayed");
             in[13]=new Inbound ("",14,"On Time");
             in[14]=new Inbound ("",15,"On Time");
             in[15]=new Inbound ("",16,"On Time");
             in[16]=new Inbound ("",17,"Canceled");
             in[17]=new Inbound ("",18,"On Time");
             in[18]=new Inbound ("",19,"On Time");
             in[19]=new Inbound ("",20,"Canceled");
             in[20]=new Inbound ("",21,"On Time");
             in[21]=new Inbound ("",22,"Delayed");
             in[22]=new Inbound ("",23,"On Time");
             in[23]=new Inbound ("",24,"Cancled");
             in[24]=new Inbound ("",7,"On Time num24");
            do{
                timeStr = JOptionPane.showInputDialog ("In military time, what hour do you want?");
                time = Integer.parseInt(timeStr);
                if (time<=0 || time>24)
                 JOptionPane.showMessageDialog (null, "Error");
                 optiStr = JOptionPane.showConfirmDialog (null, "If you want Incoming flights click Yes, but if not click No");
                if (optiStr==JOptionPane.YES_OPTION)
    //(ok this is the for loop i am talking about )
                    for (int index = 0; index < in.length; index++)
                      if ( time == Inbound.getTime())
                   JOptionPane.showMessageDialog (null, Inbound.tostring());  //return the time asked for
    //               else JOptionPane.showMessageDialog (null, "else");
                }//temp return else if failed to find time asked for
    //             else
    //               if (optiStr==JOptionPane.CANCEL_OPTION)
    //                 JOptionPane.showMessageDialog(null,"Canceled");
    //              else
    //                {Outbound.run();
    //                JOptionPane.showMessageDialog (null, "outbound");}//temp
                  again=JOptionPane.showConfirmDialog(null, "Try again?");
            while (again==JOptionPane.YES_OPTION);
    }any help would be greatly appriciated.

    rumble14 wrote:
    Ok well, I can't get my code to work. Also, please remember that this is just my draft so it isnt pretty. I will fix it up later so please look at it. The thing I want to do is look into the array for a time that matches what the user entered and return the toString() of that one. I know there is something wrong with my for loop but I cant figure how to fix it. please help. here is what i have so far:
    >//(ok this is the for loop i am talking about )
    for (int index = 0; index < in.length; index++)
    if ( time == Inbound.getTime())
    JOptionPane.showMessageDialog (null, Inbound.tostring());  //return the time asked for
    Inbound.getTime() is a static method of your Inbound class, that always returns the same value, I presume? As opposed to each of the 25 members of your array in, which have individual values?
    Edited by: darb on Mar 26, 2008 11:12 AM

  • Repaint() in JPanel doesn't align correctly

    Hey all,
    I'm running into this problem with a program I'm writing for work. It's basically a dispatch board which connects to our SQL server via ODBC. When the user presses a "Next" or "Prev" button, the dates will change and show the dispatching for the next or previous week respectively. However, the refreshed components go where they are supposed to, but the old screen is underneath, and shifted slightly so that nothing aligns. In turn, you can make heads or tails as to what's happening. However, if you select File -> Refresh from my menubar (calls repaint() the same way) everything is repainted correctly. Any ideas?
    package dispatchBoard.DispatchBoard;
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Font;
    import java.awt.Graphics;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.awt.event.MouseMotionListener;
    import java.util.Calendar;
    import java.util.GregorianCalendar;
    import java.sql.*;
    import javax.swing.JPanel;
    import sun.misc.Queue;
    public class DB_MainWindow extends JPanel implements MouseListener{
         private static final long serialVersionUID = 1L;
         private int _xRes, _yRes;
         private int _techs;
         private String _dayOption, _monday, _tuesday, _wednesday, _thursday, _friday, _odbcName, _databaseName, _currYear;
         private String[] _months;
         private Tech _myTechList;
         private Font _defaultFont;
         DB_Frame _mainFrame;
         private Calendar cal = new GregorianCalendar();
         public DB_MainWindow(String _resolution, String optionString, String ofTechs, DB_Frame frame, String _odbc, String _database, String _year)
              _xRes = Integer.valueOf(_resolution.substring(0, findCharPosition(_resolution, 'x'))).intValue() - 5;
              _yRes = Integer.valueOf(_resolution.substring(findCharPosition(_resolution, 'x')+1)).intValue() - 30;
              _techs = Integer.valueOf(ofTechs).intValue();
              _dayOption = optionString;
              _mainFrame = frame;
              _odbcName = _odbc;
              _databaseName = _database;
              _currYear = _year;
              setDaysFiveStraight();
              System.out.println(_xRes + " " + _yRes);
              this.setBackground(Color.GRAY);
              this.setPreferredSize(new Dimension(_xRes,_yRes));
              this.addMouseListener(this);
         public void paint(Graphics g)
              _myTechList = null;
              int _spacing = 0;
              int _spacing2 = 0;
              g.setColor(Color.BLACK);
              g.drawLine(60,0,60,_yRes);
              _defaultFont =g.getFont();
              //draw tech barriers
              for (int i = 1; i < _techs+1; i ++)
                   _spacing = _yRes / (_techs+1);
                   g.drawLine(0, _spacing*i, 1366, _spacing*i);
              //draw day barriers
              for (int j = 1; j < 5; j++)
                   _spacing2 = (_xRes-60) / 5;
                   g.drawLine(_spacing2*j + 60, 0, _spacing2*j + 60, 768);
              int _curPos = 60, _timePos = 0;
              int _time[] = {8,9,10,11,12,1,2,3,4,5};
              for (int k = 0; k < 5; k++)
                   _curPos = 60+(k*_spacing2);
                   for (int l = 0; l < 9; l++)
                        g.drawLine( _curPos + (l*(_spacing2/9)), 0+_spacing, _curPos + (l*(_spacing2/9)), _yRes);
                        String _tempString = ""+_time[_timePos];
                        g.drawString(_tempString, _curPos + (l*(_spacing2/9)), _spacing);
                        _timePos++;
                   _timePos = 0;
              //draw graph labels
              System.out.println(_dayOption);
              g.drawString("TECHS", 10, _spacing);
              g.drawString("Monday "+_monday, 60+(_spacing2/2) - 23, _spacing/2);
              g.drawString("Tuesday "+_tuesday, 60+_spacing2+(_spacing2/2) - 26, _spacing/2);
              g.drawString("Wednesday "+_wednesday, 60+2*_spacing2+(_spacing2/2) - 33, _spacing/2);
              g.drawString("Thursday "+_thursday, 60+3*_spacing2+(_spacing2/2) - 28, _spacing/2);
              g.drawString("Friday "+_friday, 60+4*_spacing2+(_spacing2/2) - 25, _spacing/2);
               * At this point the default grid, including all labels, have been drawn on
               * the dispatch board.  Now, we have to fetch the data from the SQL server,
               * place it into some sort of form (possibly 2d array?!) and then print it out
               * on the board....
               * Here goes!
    //          this.addMouseMotionListener(this);
    //          g.drawRect(_mousePosition.x, _mousePosition.y, 10, 10);
              fillInTimes(g, _spacing, _spacing2);
         public void setDaysFiveStraight()
              if (_dayOption.equals(new String("work_week")))
                   _monday = new String("");
                   _tuesday = new String("");
                   _wednesday = new String("");
                   _thursday = new String("");
                   _friday = new String("");
                   String[] _months2 = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"};
                   _months = _months2;
                    * Sunday = 1
                    * Monday = 2
                   System.out.println("DAY OF THE WEEK = "+cal.get(Calendar.DAY_OF_WEEK));
                   if (cal.get(Calendar.DAY_OF_WEEK) == 2)
                        _monday = new String(_months[cal.get(Calendar.MONTH)] + "/"+cal.get(Calendar.DAY_OF_MONTH)+"/"+cal.get(Calendar.YEAR));
                        cal.set(Calendar.DAY_OF_YEAR, cal.get(Calendar.DAY_OF_YEAR)+1);
                        _tuesday = new String(_months[cal.get(Calendar.MONTH)] + "/"+cal.get(Calendar.DAY_OF_MONTH)+"/"+cal.get(Calendar.YEAR));
                        cal.set(Calendar.DAY_OF_YEAR, cal.get(Calendar.DAY_OF_YEAR)+1);
                        _wednesday = new String(_months[cal.get(Calendar.MONTH)] + "/"+cal.get(Calendar.DAY_OF_MONTH)+"/"+cal.get(Calendar.YEAR));
                        cal.set(Calendar.DAY_OF_YEAR, cal.get(Calendar.DAY_OF_YEAR)+1);
                        _thursday = new String(_months[cal.get(Calendar.MONTH)] + "/"+cal.get(Calendar.DAY_OF_MONTH)+"/"+cal.get(Calendar.YEAR));
                        cal.set(Calendar.DAY_OF_YEAR, cal.get(Calendar.DAY_OF_YEAR)+1);
                        _friday = new String(_months[cal.get(Calendar.MONTH)] + "/"+cal.get(Calendar.DAY_OF_MONTH)+"/"+cal.get(Calendar.YEAR));
                   else if (cal.get(Calendar.DAY_OF_WEEK) == 3)
                   {     //tuesday
                        _tuesday = new String(_months[cal.get(Calendar.MONTH)] + "/"+cal.get(Calendar.DAY_OF_MONTH)+"/"+cal.get(Calendar.YEAR));
                        System.out.println("TUESDAY = "+_tuesday);
                        cal.set(Calendar.DAY_OF_YEAR, cal.get(Calendar.DAY_OF_YEAR)+1);
                        _wednesday = new String(_months[cal.get(Calendar.MONTH)] + "/"+cal.get(Calendar.DAY_OF_MONTH)+"/"+cal.get(Calendar.YEAR));
                        cal.set(Calendar.DAY_OF_YEAR, cal.get(Calendar.DAY_OF_YEAR)+1);
                        _thursday = new String(_months[cal.get(Calendar.MONTH)] + "/"+cal.get(Calendar.DAY_OF_MONTH)+"/"+cal.get(Calendar.YEAR));
                        cal.set(Calendar.DAY_OF_YEAR, cal.get(Calendar.DAY_OF_YEAR)+1);
                        _friday = new String(_months[cal.get(Calendar.MONTH)] + "/"+cal.get(Calendar.DAY_OF_MONTH)+"/"+cal.get(Calendar.YEAR));
                        cal.set(Calendar.DAY_OF_YEAR, cal.get(Calendar.DAY_OF_YEAR)-4);
                        _monday = new String(_months[cal.get(Calendar.MONTH)] + "/"+cal.get(Calendar.DAY_OF_MONTH)+"/"+cal.get(Calendar.YEAR));
                   else if (cal.get(Calendar.DAY_OF_WEEK) == 4)
                        _wednesday = new String(_months[cal.get(Calendar.MONTH)] + "/"+cal.get(Calendar.DAY_OF_MONTH)+"/"+cal.get(Calendar.YEAR));
                        cal.set(Calendar.DAY_OF_YEAR, cal.get(Calendar.DAY_OF_YEAR)+1);
                        _thursday = new String(_months[cal.get(Calendar.MONTH)] + "/"+cal.get(Calendar.DAY_OF_MONTH)+"/"+cal.get(Calendar.YEAR));
                        cal.set(Calendar.DAY_OF_YEAR, cal.get(Calendar.DAY_OF_YEAR)+1);
                        _friday = new String(_months[cal.get(Calendar.MONTH)] + "/"+cal.get(Calendar.DAY_OF_MONTH)+"/"+cal.get(Calendar.YEAR));
                        cal.set(Calendar.DAY_OF_YEAR, cal.get(Calendar.DAY_OF_YEAR)-4);
                        _monday = new String(_months[cal.get(Calendar.MONTH)] + "/"+cal.get(Calendar.DAY_OF_MONTH)+"/"+cal.get(Calendar.YEAR));
                        cal.set(Calendar.DAY_OF_YEAR, cal.get(Calendar.DAY_OF_YEAR)+1);
                        _tuesday = new String(_months[cal.get(Calendar.MONTH)] + "/"+cal.get(Calendar.DAY_OF_MONTH)+"/"+cal.get(Calendar.YEAR));
                        //System.out.println("TUESDAY = "+_tuesday);
                   else if (cal.get(Calendar.DAY_OF_WEEK) == 5)
                   {     //thursday
                        _thursday = new String(_months[cal.get(Calendar.MONTH)] + "/"+cal.get(Calendar.DAY_OF_MONTH)+"/"+cal.get(Calendar.YEAR));
                        cal.set(Calendar.DAY_OF_YEAR, cal.get(Calendar.DAY_OF_YEAR)+1);
                        _friday = new String(_months[cal.get(Calendar.MONTH)] + "/"+cal.get(Calendar.DAY_OF_MONTH)+"/"+cal.get(Calendar.YEAR));
                        cal.set(Calendar.DAY_OF_YEAR, cal.get(Calendar.DAY_OF_YEAR)-4);
                        _monday = new String(_months[cal.get(Calendar.MONTH)] + "/"+cal.get(Calendar.DAY_OF_MONTH)+"/"+cal.get(Calendar.YEAR));
                        cal.set(Calendar.DAY_OF_YEAR, cal.get(Calendar.DAY_OF_YEAR)+1);
                        _tuesday = new String(_months[cal.get(Calendar.MONTH)] + "/"+cal.get(Calendar.DAY_OF_MONTH)+"/"+cal.get(Calendar.YEAR));
                        cal.set(Calendar.DAY_OF_YEAR, cal.get(Calendar.DAY_OF_YEAR)+1);
                        _wednesday = new String(_months[cal.get(Calendar.MONTH)] + "/"+cal.get(Calendar.DAY_OF_MONTH)+"/"+cal.get(Calendar.YEAR));
                   else if (cal.get(Calendar.DAY_OF_WEEK) == 6)
                   {     //friday
                        _friday = new String(_months[cal.get(Calendar.MONTH)] + "/"+cal.get(Calendar.DAY_OF_MONTH)+"/"+cal.get(Calendar.YEAR));
                        cal.set(Calendar.DAY_OF_YEAR, cal.get(Calendar.DAY_OF_YEAR)-4);
                        _monday = new String(_months[cal.get(Calendar.MONTH)] + "/"+cal.get(Calendar.DAY_OF_MONTH)+"/"+cal.get(Calendar.YEAR));
                        cal.set(Calendar.DAY_OF_YEAR, cal.get(Calendar.DAY_OF_YEAR)+1);
                        _tuesday = new String(_months[cal.get(Calendar.MONTH)] + "/"+cal.get(Calendar.DAY_OF_MONTH)+"/"+cal.get(Calendar.YEAR));
                        cal.set(Calendar.DAY_OF_YEAR, cal.get(Calendar.DAY_OF_YEAR)+1);
                        _wednesday = new String(_months[cal.get(Calendar.MONTH)] + "/"+cal.get(Calendar.DAY_OF_MONTH)+"/"+cal.get(Calendar.YEAR));
                        cal.set(Calendar.DAY_OF_YEAR, cal.get(Calendar.DAY_OF_YEAR)+1);
                        _thursday = new String(_months[cal.get(Calendar.MONTH)] + "/"+cal.get(Calendar.DAY_OF_MONTH)+"/"+cal.get(Calendar.YEAR));
         private void fillInTimes(Graphics g, int _spacing, int _spacing2) {
              // need to get the data first, building pre-defined array for test data...
              //****START REAL DATA LOAD****\\
    //          Calendar cal = new GregorianCalendar();
             try {
                 // Load the JDBC-ODBC bridge
                 Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
                 // specify the ODBC data source's URL
                 String url = "jdbc:odbc:"+_odbcName;
                 // connect
                 Connection con = DriverManager.getConnection(url,"sa",_currYear);
                 // create and execute a SELECT
                 Statement stmt = con.createStatement();
                 Statement stmt2 = con.createStatement();
                 ResultSet techList = stmt2.executeQuery("USE "+_databaseName+" SELECT Distinct(SV00301.Technician) from SV00301 join SV00115 on SV00301.Technician = SV00115.Technician where SV00115.SV_Inactive<>1");
                 // traverse through results
                 Tech temp;
                 int counter = 0;
                 while(techList.next())
                      if (_myTechList == null)
                           _myTechList = new Tech(techList.getString(1).trim());
                           System.out.println(_myTechList.getName());
                           counter++;
                      else if (!_myTechList.hasNext())
                           _myTechList.setNext(new Tech(techList.getString(1).trim()));
                           System.out.println(_myTechList.getNext().getName());
                           counter++;
                      else
                           temp = _myTechList.getNext();
                           while(temp.hasNext())
                                temp = temp.getNext();
                           temp.setNext(new Tech(techList.getString(1).trim()));
                           System.out.println(temp.getNext().getName());
                           counter++;
    //             printTechList();
                 String nextMonth, prevMonth;
                 if(cal.get(Calendar.MONTH)==11)
                      nextMonth=_months[0];
                 else
                      nextMonth = _months[cal.get(Calendar.MONTH)+1];
                 if(cal.get(Calendar.MONTH) == 0)
                      prevMonth = _months[11];
                 else
                      prevMonth = _months[cal.get(Calendar.MONTH)-1];
                 ResultSet rs = stmt.executeQuery
                 ("USE "+_databaseName+" SELECT * from SV00301 JOIN SV00300 on SV00300.Service_Call_ID = SV00301.Service_Call_ID JOIN SV00115 on SV00300.Technician = SV00115.Technician JOIN SV000805 on SV000805.Service_Call_ID = SV00301.Service_Call_ID and SV000805.Note_Service_Index='Description' where (Month(SV00301.Task_Date)="+_months[cal.get(Calendar.MONTH)]+" or Month(SV00301.Task_Date)="+prevMonth+" or Month(SV00301.Task_Date)="+nextMonth+") and SV00300.Status_of_Call='OPEN' and SV00115.SV_Inactive<>1");
                 System.out.println("USE "+_databaseName+" SELECT * from SV00301 JOIN SV00300 on SV00300.Service_Call_ID = SV00301.Service_Call_ID JOIN SV00115 on SV00300.Technician = SV00115.Technician JOIN SV000805 on SV000805.Service_Call_ID = SV00301.Service_Call_ID and SV000805.Note_Service_Index='Description' where (Month(SV00300.Date_of_Service_Call)="+_months[cal.get(Calendar.MONTH)]+" or Month(SV00300.Date_of_Service_Call)="+prevMonth+" or Month(SV00300.Date_of_Service_Call)="+nextMonth+") and SV00300.Status_of_Call='OPEN' and SV00115.SV_Inactive<>1");
                  while (rs.next()) {
                      // get current row values
                       String servicecallid = rs.getString(1).trim(),
                               tech = rs.getString(4).trim(),
                               rawDate = rs.getString(6).trim(),
                               startTime = rs.getString(7).trim(),
                               _length = rs.getString(9).trim(),
                               description = rs.getString(33).trim(),
                               customernumber = rs.getString(35).trim(),
                               custname = rs.getString(45).trim(),
                               location = rs.getString(46).trim(),
                               calltype = rs.getString(54).trim(),
                               notes = rs.getString(268).trim();   
    //                  String formattedDate = month+"/"+day+"/"+year;
    //                  System.out.println(formattedDate);
    //                  String tech = rs.getString(142).trim();
    //                  String rawDate = rs.getString(144);
                      System.out.println(rawDate);
                      String day = rawDate.substring(8,10);
                      String month = rawDate.substring(5,7);
                      String year = rawDate.substring(0,4);
                      formatNumber(day);
                      formatNumber(month);
    //                  startTime = rs.getString(145);
    //                  String _length = rs.getString(147);
                      int hour = Integer.valueOf(startTime.substring(11,13)).intValue();
                      String minute = startTime.substring(14,16);
                      int minutes = Integer.valueOf(minute).intValue();
                      minutes = minutes / 60;
                      double length = (Integer.valueOf(_length).intValue())/100;
                      // print values
                      //System.out.println ("Service_Call_ID = " + Surname);
                      if (hour!=0)
                           sortJob(new Job(servicecallid, custname, new MyDate(month,day,year), hour+minutes,length, description, customernumber, location, calltype, notes), _myTechList, tech);
                  // close statement and connection
                  stmt.close();
                  con.close();
                  catch (java.lang.Exception ex) {
                      ex.printStackTrace();
              //draw techs and blocks of jobs!!!!!
              //***TECHS***\\
             Tech _tempTech = new Tech("DOOKIE");
              int multiplier = 2;
              if (_myTechList.hasNext())
                   g.setColor(Color.BLACK);
                   _tempTech = _myTechList.getNext();
                   g.drawString(_myTechList.getName(),5,(_spacing)*multiplier);
                   System.out.println("printJobs(g, "+_myTechList.getName()+","+multiplier+","+_spacing+","+_spacing2+")");
                   printJobs(g,_myTechList,multiplier, _spacing,_spacing2);
                   multiplier++;
              while(_tempTech.hasNext())
                   g.setColor(Color.BLACK);
                   g.drawString(_tempTech.getName(),5,(_spacing)*multiplier);
                   System.out.println("printJobs(g, "+_tempTech.getName()+","+multiplier+","+_spacing+","+_spacing2+")");
                   printJobs(g,_tempTech,multiplier, _spacing,_spacing2);
                   multiplier++;
                   _tempTech = _tempTech.getNext();
              g.setColor(Color.BLACK);
              g.drawString(_tempTech.getName(),5,(_spacing)*multiplier);
              System.out.println("printJobs(g, "+_tempTech.getName()+","+multiplier+","+_spacing+","+_spacing2+")");
              printJobs(g,_tempTech,multiplier, _spacing,_spacing2);
              //***TIME BLOCKS***\\\
         private void printTechList() {
              // TODO Auto-generated method stub
              boolean temp = !_myTechList.hasNext();
              Tech tempTech = _myTechList;
              System.out.println("BEGINNING TECH LIST PRINTOUT!!!!");
              while (tempTech.hasNext() || temp)
                   System.out.println(tempTech.getName());
                   if (temp)
                        temp = !temp;
                   else
                        tempTech = tempTech.getNext();
              System.out.println(tempTech.getName());
              System.out.println("END TECH LIST PRINTOUT!!!");
         private void formatNumber(String month) {
              // TODO Auto-generated method stub
              if (month.equals(new String("01")))
                   month = new String("1");
              else if (month.equals(new String("02")))
                   month = new String("2");
              else if (month.equals(new String("03")))
                   month = new String("3");
              else if (month.equals(new String("04")))
                   month = new String("4");
              else if (month.equals(new String("05")))
                   month = new String("5");
              else if (month.equals(new String("06")))
                   month = new String("6");
              else if (month.equals(new String("07")))
                   month = new String("7");
              else if (month.equals(new String("08")))
                   month = new String("8");
              else if (month.equals(new String("09")))
                   month = new String("9");
         private void printJobs(Graphics g, Tech techList, int multiplier, int _spacing, int _spacing2) {
              Job tempJob = techList.getJobs();
              boolean temp = false;
              if (tempJob != null)
              {     temp = !tempJob.hasNext();
              while (tempJob.hasNext() || temp)
                   g.setColor(Color.RED);
                   String _tempDate = new String(tempJob.getDate().toString());
    //               System.out.println("This job has date of: "+_tempDate);
                   int horizontalMultiplier = 0;
                   if (_tempDate.equals(_monday))
                        horizontalMultiplier = 0;
                   else if (_tempDate.equals(_tuesday))
                        horizontalMultiplier = 1;
                   else if (_tempDate.equals(_wednesday))
                        horizontalMultiplier = 2;
                   else if (_tempDate.equals(_thursday))
                        horizontalMultiplier = 3;
                   else if (_tempDate.equals(_friday))
                        horizontalMultiplier = 4;
                   else
                        horizontalMultiplier = 5;
    //               System.out.println("HorizontalMultiplier = "+horizontalMultiplier);
                   if (horizontalMultiplier !=5)
                        if (tempJob.getJobCallType().equals(new String("TM"))) g.setColor(new Color(0,255,0));
                        else if (tempJob.getJobCallType().equals(new String("SU"))) g.setColor(new Color(0,255,255));
                        else if (tempJob.getJobCallType().equals(new String("SPD"))) g.setColor(new Color(44,148,67));
                        else if (tempJob.getJobCallType().equals(new String("QUO"))) g.setColor(new Color(0,255,255));
                        else if (tempJob.getJobCallType().equals(new String("MCC"))) g.setColor(new Color(255,0,255));
                        else if (tempJob.getJobCallType().equals(new String("MC"))) g.setColor(new Color(128,0,255));
                        else if (tempJob.getJobCallType().equals(new String("CBS"))) g.setColor(new Color(0,0,255));
                        else if (tempJob.getJobCallType().equals(new String("AS"))) g.setColor(new Color(255,255,255));
                        else g.setColor(Color.red);
                        g.fillRect(/*START X*/(int)(60+(horizontalMultiplier*_spacing2)+(tempJob.getStarTime()-8)*(_spacing2/9)+1),/*START Y*/_spacing*(multiplier-1)+1,/*LENGTH*/(int)(tempJob.getJobLength()*(_spacing2/9)-1),/*WIDTH*/_spacing-1);
                        System.out.println("g.fillRect("+((int)(60+(horizontalMultiplier*_spacing2)+(tempJob.getStarTime()-8)*(_spacing2/9)+1))+","+(_spacing*(multiplier-1)+1)+","+((int)(tempJob.getJobLength()*(_spacing2/9)-1))+","+(_spacing-1)+") :: Multiplier = "+multiplier+" :: JOB NAME = "+tempJob.getJobName()+" :: JOB NUMBER = "+tempJob.getJobNumber());
                        g.setColor(Color.BLACK);
                        g.setFont(new Font("Monofonto", Font.PLAIN, 22));
                        if ((int)(tempJob.getJobLength()*(_spacing2/9)-1) >0)
                             g.drawString(formatStringLength(tempJob.getJobName().toUpperCase(), tempJob.getJobLength()), (int)(60+(horizontalMultiplier*_spacing2)+(tempJob.getStarTime()-8)*(_spacing2/9)+1), (_spacing*(multiplier)+1)-_spacing/2+5);
                        g.setFont(_defaultFont);
                        if (!temp)
                             tempJob = tempJob.getNext();
                             if (tempJob.hasNext() == false)
                                  temp = true;
                        else
                             temp = !temp;
                   else
                        System.out.println("*g.fillRect("+((int)(60+(horizontalMultiplier*_spacing2)+(tempJob.getStarTime()-8)*(_spacing2/9)+1))+","+(_spacing*(multiplier-1)+1)+","+((int)(tempJob.getJobLength()*(_spacing2/9)-1))+","+(_spacing-1)+") :: Multiplier = "+multiplier+" :: JOB NAME = "+tempJob.getJobName()+" :: JOB NUMBER = "+tempJob.getJobNumber());
                        if (!temp)
                             tempJob = tempJob.getNext();
                             if (tempJob.hasNext() == false)
                                  temp = true;
                        else
                             temp = !temp;
         //     g.fillRect((int)(60+(tempJob.getStarTime()-8)*(_spacing2/9)+1),_spacing*(multiplier-1)+1,(int)(tempJob.getJobLength()*(_spacing2/9)-1),_spacing-1);
         private String formatStringLength(String string, double jobLength) {
              // TODO Auto-generated method stub
              if (jobLength*3>string.length())
                   return string;
              return string.substring(0, new Double(jobLength*3).intValue());
         private void sortJob(Job job, Tech techList, String techName) {
              Tech _tempTech2;
              if (techName.equals(techList.getName()))
                   techList.insertJob(job);
                   System.out.println("ADDED " + job.getJobName() +" TO " + techName);
              else
                   _tempTech2 = techList.getNext();
                   while (!_tempTech2.getName().equals(techName) && _tempTech2.hasNext())
                        _tempTech2 = _tempTech2.getNext();
    //                    System.out.println(_tempTech2.getName()+" vs. " + techName);
                   if (_tempTech2.getName().equals(techName))
                        _tempTech2.insertJob(job);
                        System.out.println("ADDED " + job.getJobName() +" TO " + techName);
                   else
                        System.out.println("TECH NAME: "+_tempTech2.getName()+" NOT FOUND :: COULD NOT INSERT JOB");
         private int findCharPosition(String _resolution2, char c) {
              // TODO Auto-generated method stub
              for (int i = 0; i < _resolution2.length(); i++)
                   if (_resolution2.charAt(i) == c)
                        return i;
              return 0;
         public void mouseReleased(MouseEvent arg0) {
              // TODO Auto-generated method stub
              System.out.println("Mouse clicked at coordinates: "+arg0.getX()+", "+arg0.getY()+"\nAttempting to intelligently find the job number");
               * Find the tech
              int techNum = arg0.getY()/(_yRes / (_techs+1));
              String techName= new String("");
              int counter = 0;
              Tech temp = _myTechList;
              boolean found = true;
              while(temp.hasNext() && found)
                   counter++;
                   if (counter == techNum)
                        techName = temp.getName();
                        found = false;
                   else
                        temp = temp.getNext();
              System.out.println("The "+techNum+"th tech was selected... which means you clicked "+techName);
               * Find the day
              int day = (arg0.getX()-60)/(0 + ((_xRes-60)/5));
              String days[] = {_monday, _tuesday, _wednesday, _thursday, _friday};
              System.out.println("The day you chose was "+days[day]);
               * Find the time
              int blocksIn = ((arg0.getX()-60)/(((_xRes-60)/5)/9))%9;
              System.out.println(blocksIn+" blocks inward!!!!");
               * Find the job
               *           - temp is already initialized to the current tech!!
              System.out.println(temp.getName()+" has "+temp.getNumberOfJobs()+" jobs");
              Job current = temp.getJobs();
              Queue jobQueue = new Queue();
              boolean first = true;
              while(current.hasNext() || first)
                   if(current.getDate().toString().equals(days[day]))
                        jobQueue.enqueue(current);
                        System.out.println("Queued the job on "+current.getDate().toString()+"::"+current.getJobNumber());
                        if (first)
                             first = false;
                             current = current.getNext();
                        else
                             current = current.getNext();
                   else
                        System.out.println("Did not queued the job on "+current.getDate().toString()+"::"+current.getJobNumber());
                        if (first)
                             first = false;
                             current = current.getNext();
                        else
                             current = current.getNext();
              if(current.getDate().toString().equals(days[day]))
                   jobQueue.enqueue(current);
                   System.out.println("Queued the job on "+current.getDate().toString()+"::"+current.getJobNumber());
              else
                   System.out.println("Did not queue the job on "+current.getDate().toString()+"::"+current.getJobNumber());
              blocksIn+=8;
              while(!jobQueue.isEmpty())
                   try {
                         * Get a job off the queue... now check the times
                        Job dqJob = (Job)jobQueue.dequeue();
                        System.out.println(dqJob.getStarTime()+"<="+blocksIn +" && "+(dqJob.getStarTime()+dqJob.getJobLength()-1)+">="+blocksIn+" :: "+dqJob.getJobName());
                        if (dqJob.getStarTime()<=blocksIn && dqJob.getStarTime()+dqJob.getJobLength()-1>=blocksIn)
                             System.out.println("MONEY!!!! Found job: "+dqJob.getJobName());
                             new JobDisplayer(dqJob, _xRes, _yRes);
                   } catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
         public void mouseEntered(MouseEvent arg0) {
              // TODO Auto-generated method stub
         public void mouseExited(MouseEvent arg0) {
              // TODO Auto-generated method stub
         public void mousePressed(MouseEvent arg0) {
              // TODO Auto-generated method stub
         public void mouseClicked(MouseEvent arg0) {
              // TODO Auto-generated method stub
         public void nextDay() {
              // TODO Auto-generated method stub
              if (_dayOption.equals(new String("work_week")))
                   cal.set(Calendar.DAY_OF_YEAR, cal.get(Calendar.DAY_OF_YEAR)+7);
                   setDaysFiveStraight();
              this.repaint();
         public void prevDay() {
              // TODO Auto-generated method stub
              if (_dayOption.equals(new String("work_week")))
                   cal.set(Calendar.DAY_OF_YEAR, cal.get(Calendar.DAY_OF_YEAR)-7);
                   setDaysFiveStraight();
                   this.repaint();
              this.repaint();
    }Sorry for the huge chunk of code.
    Thanks in advance,
    Jeff

    Sorry for the huge chunk of code.
    Mm, yes, I'm far too lazy to read all that.
    But you should be overriding paintComponent(), not paint().
    http://www.google.co.uk/search?hl=en&q=java+swing+painting&btnG=Google+Search&meta=
    I've not bothered to work out from that pile of magic numbers exactly what you're tring to draw but is it not something that JTable would happily do?

  • How to show a background image in the Forms 6i MDI window?

    Hello,
    We are using Oracle Forms 6i Release 2 Patch 18 on Windows XP in client/server environment (not web server).
    Is there any way to show a background image in the MDI root window without using DLL injection to subclass the MDI root window procedure.
    Kurt

    Please try this 
    Public Function Decompress(ByVal arr As Byte()) As Byte()
            Dim s As Byte()
            Dim notCompressed As Boolean
            notCompressed = False
            Dim MS As System.IO.MemoryStream
            MS = New System.IO.MemoryStream()
            MS.Write(arr, 0, arr.Length)
            MS.Position = 0
            Dim stream As System.IO.Compression.GZipStream
            stream = New System.IO.Compression.GZipStream(MS, System.IO.Compression.CompressionMode.Decompress)
            Dim temp As System.IO.MemoryStream
            temp = New System.IO.MemoryStream()
            Dim buffer As Byte() = New Byte(4096) {}
            While (True)
                Try
                    Dim read As Integer
                    read = stream.Read(buffer, 0, buffer.Length)
                    If (read <= 0) Then
                        Exit While
                    Else
                        temp.Write(buffer, 0, buffer.Length)
                    End If
                Catch ex As Exception
                    notCompressed = True
                    Exit While
                End Try
            End While
            If (notCompressed = True) Then
                stream.Close()
                Return temp.ToArray()
            Else
                Return temp.ToArray()
            End If
        End Function
    Thanks & Regards Manoj

  • How to show a compressed image in the report?

    Hi
    I have created a new report.what i do in application is i  compress the image and save it in database.now i need to retrieve the compressed image and display in the report. I have used the following code to decompress the binary data save in the image.I
    dont know after that what should i do. Please help me to show the picture in SSRS Report. I need to show picture in many reports.one of my doubt is how to call this function in SSRS Report. The function accepts input as byte but in database the column in varbinary.
    should i convert the input type of function to varbinary instead of byte array? Please help me.
    Public Function Decompress(ByVal arr As Byte()) As Byte()
    Dim notCompressed As Boolean
    notCompressed = False
    Dim MS As MemoryStream
    MS = New MemoryStream()
    MS.Write(arr, 0, arr.Length)
    MS.Position = 0
    Dim stream As GZipStream
    stream = New GZipStream(MS, CompressionMode.Decompress)
    Dim temp As MemoryStream
    temp = New MemoryStream()
    Dim buffer As Byte() = New Byte(4096) {}
    While (True)
    Try
    Dim read As Integer
    read = stream.Read(buffer, 0, buffer.Length)
    If (read <= 0) Then
    Exit While
    Else
    temp.Write(buffer, 0, buffer.Length)
    End If
    Catch ex As Exception
    notCompressed = True
    Exit While
    End Try
    End While
    If (notCompressed = True) Then
    stream.Close()
    Return temp.ToArray()
    Else
    Return temp.ToArray()
    End If
    End Function
    Thanks & Regards Manoj

    Please try this 
    Public Function Decompress(ByVal arr As Byte()) As Byte()
            Dim s As Byte()
            Dim notCompressed As Boolean
            notCompressed = False
            Dim MS As System.IO.MemoryStream
            MS = New System.IO.MemoryStream()
            MS.Write(arr, 0, arr.Length)
            MS.Position = 0
            Dim stream As System.IO.Compression.GZipStream
            stream = New System.IO.Compression.GZipStream(MS, System.IO.Compression.CompressionMode.Decompress)
            Dim temp As System.IO.MemoryStream
            temp = New System.IO.MemoryStream()
            Dim buffer As Byte() = New Byte(4096) {}
            While (True)
                Try
                    Dim read As Integer
                    read = stream.Read(buffer, 0, buffer.Length)
                    If (read <= 0) Then
                        Exit While
                    Else
                        temp.Write(buffer, 0, buffer.Length)
                    End If
                Catch ex As Exception
                    notCompressed = True
                    Exit While
                End Try
            End While
            If (notCompressed = True) Then
                stream.Close()
                Return temp.ToArray()
            Else
                Return temp.ToArray()
            End If
        End Function
    Thanks & Regards Manoj

  • How do I get an extended SecurityManager to handle privileged code?

    Hi.
    I have written my own SecurityManager which asks if the user wants to allow the action before denying it. It also offers to write the whole permission into the current policy file.
    The problem I have is that I can't get the securitymanager to handle privileged code. At the moment I get the call stack and check which classes that doesn't have the permission, check their codebase and write the permission to that codebase. But that will fail if any code is privileged.
    So what I need is to get some information about those protection domains that are marked privileged, and it seems that the only way to get that is by using DomainCombiner.
    But it doesn't seem to work at all, thinking that it might have something to do with that I have to run the critical code in my security manager as privileged, and that I do something wrong when I am extracting the DomainCombiner.
    Well, I hope you understand my problem and that someone have some nice idea about how to do it in a clean nice way.
    best regards,
    Fredrik

    Might be better if I post the whole code, it aint that big.
    package tddc03;
    public class SecMan2 extends SecurityManager { 
        private static String separator = System.getProperty("file.separator");
        public SecMan2() {
             super();
        public void checkPermission(final Permission perm) {
         try {
             super.checkPermission(perm);
         catch (final SecurityException se) {
             System.out.println("Securityexception caught: " + se.getMessage());
             System.out.println("Would you like to: 1. Allow once, 2. Allow everytime, 3. Deny?");
             try {
              char res = (char)System.in.read();
              /*Read until end of line, or eof. to descard anything other then the first character*/
              char tmp;
              int readItem;
              do {
                  tmp = (char) (readItem = System.in.read());
              }  while ( tmp != '\n' && readItem != -1 );
              if ((res != '1') && (res != '2')) {
                  System.out.println("deny!");
                  throw se;
              else if (res == '2')
                   /*Well, we need to make the handleException() code to run as privileged code
                    * since it need access to resources that the caller shouldn't have access to.
                    * The code that runs marked as privileged only rely on its own permission, so
                    * we can give this package the permission to write to the policy file without giving
                    * it to the program that is running*/
                    try {
                        AccessController.doPrivileged(
                                       new PrivilegedExceptionAction() {
                                           public Object run() throws SecurityException {
                                                      handleException(se, perm);
                                                      return null;
                    } catch (PrivilegedActionException e) {
                        throw (SecurityException) e.getException();
             } catch (IOException ioe) {
                  System.out.println("IOException on input:" + ioe.getMessage());
                  throw se;
         catch (Exception e) {
             System.out.println("Exception caught :" + e.getMessage());
             e.printStackTrace();
        private void handleException(SecurityException e, final Permission perm) {
         String provider;
         Vector<String> codebase = new Vector();
         /*if you only using your own policy file, there will be one '=' infront of the
           searchpath which we have to remove*/
         provider = System.getProperty("java.security.policy");     
         provider = provider.replaceFirst("=","");     
         /*this means we have to use the default one.*/
         if (provider == null)
             provider = System.getProperty("java.home") + separator +"lib"
              + separator +"security"+separator+"java.policy";
         //codebase = "file:" + System.getProperty("user.dir") + separator + "-";
         Class[] classes = getClassContext();
         ProtectionDomain pd = null;
         for(int i=0; i < classes.length; i++) {
             pd = classes.getProtectionDomain();
         if (pd.implies(perm) == true) {
                        System.out.println(i + ". " + classes[i].toString());
         else {
                        System.out.print(i + ". " + classes[i].toString()+ "[");
                        System.out.println(pd.getCodeSource().getLocation().toString() + "]");
                        codebase.add(pd.getCodeSource().getLocation().toString());
         final File policy_file = new File(provider);
         final PolicyParser parser = new PolicyParser();
         PolicyParser.PermissionEntry perm_entry;
         PolicyParser.GrantEntry grant_entry;
         //Traverse the exception message to get the specs for the new permission
         String perm_type, perm_action, perm_param;
         try {
         //We need to get the data from the exception message, so we will split it up.
         String temp[] = e.getMessage().split("[()]",3);
         temp = temp[1].split("\\s",3);
         perm_type = temp[0];
         perm_param = temp[1];
         if (temp.length > 2)
              perm_action = temp[2];
         else
              perm_action = "";
         perm_entry = new PolicyParser.PermissionEntry(perm_type, perm_param, perm_action);
         FileReader p_reader = new FileReader(policy_file);
         parser.read(p_reader);
         p_reader.close();
         //Travers all grants, looking for the current codeBase
         PolicyParser.GrantEntry list_entry;
         Enumeration elements;
         for(Enumeration ec = codebase.elements(); ec.hasMoreElements();) {
              elements = parser.grantElements();
              grant_entry= new PolicyParser.GrantEntry();
              grant_entry.codeBase = (String) ec.nextElement();
              while(elements.hasMoreElements()) {
              list_entry = (PolicyParser.GrantEntry) elements.nextElement();
              //If null == null or codeBase == codeBase
              if (grant_entry.codeBase.equals(list_entry.codeBase)) {
                   list_entry.add(perm_entry);
                   //To mark that the entry was successfully found
                   grant_entry = null;
                   break;
              if (grant_entry != null) {
              grant_entry.add(perm_entry);
              parser.add(grant_entry);
         FileWriter p_writer = new FileWriter(policy_file);
         parser.write(p_writer);
         p_writer.close();
         Policy.getPolicy().refresh();
         } catch (IOException ioe) {
         System.out.println("IOException caught:" + ioe.getMessage());
         } catch (ParsingException pe) {
         System.out.println("ParsingException caught:" + pe.getMessage());
         } catch (Exception ex) {
         System.out.println("Exception caught:" + ex.getMessage());

  • Getting Exception of MessagingException

    Hi All,
    I am developing Email Application which retrieve the emails from the Gmail Account.
    But I am getting the Exception:
    1)
    javax.mail.MessagingException: Connect failed;  nested exception is: java.io.IOException: Couldn't connect using "javax.net.ssl.SSLSocketFactory" socket factory to host, port: pop.gmail.com, 995; Exception: java.lang.reflect.InvocationTargetException
    2)
    javax.mail.MessagingException: Not connected
    Following is my program.
    // This file has been generated partially by the Web Dynpro Code Generator.
    // MODIFY CODE ONLY IN SECTIONS ENCLOSED BY @@begin AND @@end.
    // ALL OTHER CHANGES WILL BE LOST IF THE FILE IS REGENERATED.
    package com.sap.training;
    // IMPORTANT NOTE:
    // _ALL_ IMPORT STATEMENTS MUST BE PLACED IN THE FOLLOWING SECTION ENCLOSED
    // BY @@begin imports AND @@end. FURTHERMORE, THIS SECTION MUST ALWAYS CONTAIN
    // AT LEAST ONE IMPORT STATEMENT (E.G. THAT FOR IPrivateAccessGmailComp).
    // OTHERWISE, USING THE ECLIPSE FUNCTION "Organize Imports" FOLLOWED BY
    // A WEB DYNPRO CODE GENERATION (E.G. PROJECT BUILD) WILL RESULT IN THE LOSS
    // OF IMPORT STATEMENTS.
    //@@begin imports
    import java.io.IOException;
    import java.util.Properties;
    import javax.mail.Folder;
    import javax.mail.MessagingException;
    import javax.mail.Multipart;
    import javax.mail.Part;
    import javax.mail.Session;
    import javax.mail.Store;
    import javax.mail.URLName;
    import com.sap.training.wdp.IPrivateAccessGmailComp;
    import com.sap.training.wdp.IPublicAccessGmailComp;
    //@@end
    //@@begin documentation
    //@@end
    public class AccessGmailComp
       * Logging location.
      private static final com.sap.tc.logging.Location logger =
        com.sap.tc.logging.Location.getLocation(AccessGmailComp.class);
      static
        //@@begin id
        String id = "$Id$";
        //@@end
        com.sap.tc.logging.Location.getLocation("ID.com.sap.tc.webdynpro").infoT(id);
       * Private access to the generated Web Dynpro counterpart
       * for this controller class.  </p>
       * Use <code>wdThis</code> to gain typed access to the context,
       * to trigger navigation via outbound plugs, to get and enable/disable
       * actions, fire declared events, and access used controllers and/or
       * component usages.
       * @see com.sap.training.wdp.IPrivateAccessGmailComp for more details
      private final IPrivateAccessGmailComp wdThis;
       * Root node of this controller's context. </p>
       * Provides typed access not only to the elements of the root node
       * but also to all nodes in the context (methods node<i>XYZ</i>())
       * and their currently selected element (methods current<i>XYZ</i>Element()).
       * It also facilitates the creation of new elements for all nodes
       * (methods create<i>XYZ</i>Element()). </p>
       * @see com.sap.training.wdp.IPrivateAccessGmailComp.IContextNode for more details.
      private final IPrivateAccessGmailComp.IContextNode wdContext;
       * A shortcut for <code>wdThis.wdGetAPI()</code>. </p>
       * Represents the generic API of the generic Web Dynpro counterpart
       * for this controller. </p>
      private final com.sap.tc.webdynpro.progmodel.api.IWDComponent wdControllerAPI;
       * A shortcut for <code>wdThis.wdGetAPI().getComponent()</code>. </p>
       * Represents the generic API of the Web Dynpro component this controller
       * belongs to. Can be used to access the message manager, the window manager,
       * to add/remove event handlers and so on. </p>
      private final com.sap.tc.webdynpro.progmodel.api.IWDComponent wdComponentAPI;
      public AccessGmailComp(IPrivateAccessGmailComp wdThis)
        this.wdThis = wdThis;
        this.wdContext = wdThis.wdGetContext();
        this.wdControllerAPI = wdThis.wdGetAPI();
        this.wdComponentAPI = wdThis.wdGetAPI().getComponent();
      //@@begin javadoc:wdDoInit()
      /** Hook method called to initialize controller. */
      //@@end
      public void wdDoInit()
        //@@begin wdDoInit()
        //@@end
      //@@begin javadoc:wdDoExit()
      /** Hook method called to clean up controller. */
      //@@end
      public void wdDoExit()
        //@@begin wdDoExit()
        //@@end
      //@@begin javadoc:wdDoPostProcessing()
       * Hook called to handle data retrieval errors before rendering.
       * After doModifyView(), the Web Dynpro Framework gets all context data needed
       * for rendering by validating the contexts (which in turn calls the supply
       * functions and supplying relation roles). In this hook, the application
       * should handle the errors which occurred during validation of the contexts.
       * Using preorder depth-first traversal, this hook is called for all component
       * controllers starting with the current root component.
       * Permitted operations:
       * - Flushing model queue
       * - Creating messages
       * - Reading context and model data
       * Forbidden operations:
       * - Invalidating model data
       * - Manipulating the context
       * - Firing outbound plugs
       * - Creating components
       * @param isCurrentRoot true if this is the root of the current request
      //@@end
      public void wdDoPostProcessing(boolean isCurrentRoot)
        //@@begin wdDoPostProcessing()
        //@@end
      //@@begin javadoc:wdDoBeforeNavigation()
       * Hook before the navigation phase starts.
       * This hook allows you to flush the model queue and handle any
       * errors that occur. Firing outbound plugs is allowed in this hook.
       * Using preorder depth-first traversal, this hook is called for all component
       * controllers starting with the current root component.
       * @param isCurrentRoot true if this is the root of the current request
      //@@end
      public void wdDoBeforeNavigation(boolean isCurrentRoot)
        //@@begin wdDoBeforeNavigation()
        //@@end
      //@@begin javadoc:wdDoApplicationStateChange()
       * Hook that informs the application about a state change.
       * <p>
       * This hook is called e.g. to tell the application that will be
       * <ul>
       *  <li>left via a suspend plug and therefore should go into a suspend/sleep
       *      mode with minimal need of resources. errors that occur. Firing
       *      outbound plugs is allowed in this hook.
       *  <li>left due to a timeout and could write it's state to a data base if the
       *      user comes back later on
       * </ul>
       * The concrete reason is available via IWDApplicationStateChangeInfo
       * <p>
       * <b>Important</b>: This hook is called for the top level component only!
       * @param stateChangeInfo contains the information about the nature of the state change
       * @param stateChangeReturn allows the application to ask for a different state change.
       *        The framework is allowed to ignore it considering i.e. the current resources situation.
      //@@end
      public void wdDoApplicationStateChange(com.sap.tc.webdynpro.progmodel.api.IWDApplicationStateChangeInfo stateChangeInfo, com.sap.tc.webdynpro.progmodel.api.IWDApplicationStateChangeReturn stateChangeReturn)
        //@@begin wdDoApplicationStateChange()
        //@@end
      //@@begin javadoc:Login()
      /** Declared method. */
      //@@end
      public void Login( )
        //@@begin Login()
         try
              Properties props = System.getProperties();
              //props.setProperty("mail.pop3.socketFactory.class", SSL_FACTORY);
              props.setProperty("mail.pop3.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
              props.setProperty("mail.pop3.socketFactory.fallback", "false");
              props.setProperty("mail.pop3.port", "995");
              props.setProperty("mail.pop3.socketFactory.port", "995");
              Session session = Session.getDefaultInstance(props,null);
              URLName urln = new URLName("pop3","pop.gmail.com",995,null,
              wdContext.nodeVnLogin().currentVnLoginElement().getVaUsername(),
              wdContext.nodeVnLogin().currentVnLoginElement().getVaPassword());
              store = session.getStore(urln);
              store.connect();
              wdComponentAPI.getMessageManager().reportSuccess("Suceesfully login");
         catch(MessagingException e)
              wdComponentAPI.getMessageManager().reportSuccess(e.toString());
        //@@end
      //@@begin javadoc:getInboxMsg()
      /** Declared method. */
      //@@end
      public void getInboxMsg( )
        //@@begin getInboxMsg()
         try
              Folder folder = store.getFolder("INBOX");
              folder.open(Folder.READ_ONLY);
              message = folder.getMessages();
              IPublicAccessGmailComp.IVnInboxElement inBoxElement;
                   for(int i=0;i<message.length;i++)
                        inBoxElement=wdContext.nodeVnInbox().createVnInboxElement();
                        inBoxElement.setVaFrom(message<i>.getFrom()[0].toString());
                        inBoxElement.setVaSubject(message<i>.getSubject());
    //                    inBoxElement.setVaIndex(i);
                        wdContext.nodeVnInbox().addElement(inBoxElement);
              wdComponentAPI.getMessageManager().reportSuccess("You have"+wdContext.nodeVnInbox().size()+"message");
              wdContext.nodeVnInbox().setLeadSelection(-1);
         catch(MessagingException e)
              wdComponentAPI.getMessageManager().reportSuccess(e.toString());
        //@@end
      //@@begin javadoc:getTextContent()
      /** Declared method. */
      //@@end
      public void getTextContent( )
        //@@begin getTextContent()
         try
              String temp;
              for(int j=0;j<wdContext.nodeVnInbox().size();j++)
                   if(j<0)
                         temp = "false";
                   else
                         temp = "true";
                   if(wdContext.nodeVnInbox().currentVnInboxElement().getVaIndex() == temp )
                             Object content = message[j].getContent();
                             Multipart multipart=(Multipart)content;
                             Part part=multipart.getBodyPart(0);
                             wdContext.currentContextElement().setCaBodyText(part.getContent().toString());
         catch(MessagingException e)
              wdComponentAPI.getMessageManager().reportSuccess(e.toString());
         catch(IOException e)
                   wdComponentAPI.getMessageManager().reportSuccess(e.toString());
        //@@end
      //@@begin javadoc:Logout()
      /** Declared method. */
      //@@end
      public void Logout( )
        //@@begin Logout()
         try
              store.close();
         catch(MessagingException e)
              wdComponentAPI.getMessageManager().reportSuccess(e.toString());
        //@@end
       * The following code section can be used for any Java code that is
       * not to be visible to other controllers/views or that contains constructs
       * currently not supported directly by Web Dynpro (such as inner classes or
       * member variables etc.). </p>
       * Note: The content of this section is in no way managed/controlled
       * by the Web Dynpro Designtime or the Web Dynpro Runtime.
      //@@begin others
                     //final String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";
                     Store store;
                     javax.mail.Message message[];
      //@@end
    Pls help me out asap
    Thanks & Regards,
    Dhruv Shah
    Edited by: DS on Feb 20, 2008 3:06 PM

    Hi Dhruv,
    Are you sure you can connect to port 995 from the server?
    Jeschael

  • HELP!!!  Adding JPanel to JPanel (long code sample)

    I need some help here. I have been stuck on this for more time than I care to admit. Now this project is due by Monday(tomorrow)! Why does the graph not appear in the tabbed pane "trend report"?? the TrendReport class on line 2131 creates the graph. Line 56 creates an instance. and line 831 adds it to the tabbed pane. everything shows up except the graph.
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import java.text.*;
    import java.util.*;
    import java.lang.*;
    import javax.swing.JPopupMenu;
    import javax.swing.JPanel;
    import javax.swing.JMenu;
    import javax.swing.JMenuItem;
    import javax.swing.JLabel;
    import javax.swing.JTabbedPane;
    import javax.swing.JTextField;
    import javax.swing.JTable;
    import javax.swing.filechooser.*;
    /*<br>
    *A332IWon Class<br>
    *CIS 32 / Cuesta College<br>
    *Assignment     3<br>
    *Due Date 10-08-03<br>
    *<br>
    *<br>
    *<br> >>>>>>>>> Start filling in your class discription here <<<<<<<<<<<<
            >>>>>>>>> And Start filling in your method discriptions <<<<<<<<<<<
    *<br>
    *<br>@author<br>
    *Chris Hoffman, Michael Krempely, Rudy Kalnin, Scott Thayer and Frank Randise<br>
    *@version 10.16<br>
    *<br>
    *<br>
    public class A332IWon extends JFrame
         * Class to handle all data input, output, sorting and display handling.
        private A332IWonEngine engine = new A332IWonEngine();
          * Instance of the inner class "QuickTable" called "quickTabke"
         private QuickTable quickTable = new QuickTable();
          * Instance of the inner class "BasicPayTable" called "basicPayTable"
        private BasicPayTable basicPayTable = new BasicPayTable();
         * Instance of the inner class "TrendReport" called "trendReport"
        private TrendReport trendReport = new TrendReport();       
          * Container that holds all panels, labels, and text fields
         private Container c = getContentPane();
          * The menu bar at the top of the application
         private JMenuBar bar = new JMenuBar();
          * Menu bar header called "File"
         private JMenu menuFile = new JMenu("File");
          * Menu bar header called "Edit"
         private JMenu menuEdit = new JMenu("Edit");
          * Menu bar header called "Reports"
        private JMenu menuReports = new JMenu("Reports");
          * Menu bar header called "Help"
        private JMenu menuHelp = new JMenu("Help");
          * Menu item called "Import" a sub menu item of "menuFile"
         private JMenuItem fileImport = new JMenu("Import");
          * Menu item called "Employee Text File" a sub menu item of "fileImport"
          * which in turn is a sub item of "menuFile"
         private JMenuItem fileEmpTxtFile = new JMenuItem("Employee Text File");
          * Menu item called "Pay Info File" a sub menu item of "fileImport"
          * which in turn is a sub item of "menuFile"
         private JMenuItem filePayInfoFile = new JMenuItem("Pay Info File");
          * Menu item called "Open" a sub menu item of "menuFile"
           private JMenuItem fileOpen = new JMenuItem("Open");
          * Menu item called "Save" a sub menu item of "menuFile"
           private JMenuItem fileSave = new JMenuItem("Save");
          * Menu item called "Exit" a sub menu item of "menuFile"
           private JMenuItem fileExit = new JMenuItem("Exit");
          * Menu item called "Search" a sub menu item of "menuEdit"
          private JMenuItem editSearch = new JMenu("Search");
          * Menu item called "Add/Remove" a sub menu item of "menuEdit"
           private JMenuItem editAddRemove = new JMenuItem("Add/Remove");
          * Menu item called "By ID #" a sub menu item of "editSearch"
          * which in turn is a sub item of "menuEdit"
           private JMenuItem editID = new JMenuItem("By ID #");
          * Menu item called "By name" a sub menu item of "editSearch"
          * which in turn is a sub item of "menuEdit"
           private JMenuItem editName = new JMenuItem("By name");
          * Menu item called "Basic Pay" a sub menu item of "menuReports"
           private JMenuItem repBasicPay = new JMenuItem("Basic Pay");
          * Menu item called "Trend" a sub menu item of "menuReports"
           private JMenuItem repTrend = new JMenuItem("Trend");
          * Menu item called "About" a sub menu item of "menuHelp"
           private JMenuItem helpAbout = new JMenuItem("About");
          * The tabbed pane that holds our table, reports and table editing capabilities
         private JTabbedPane empInfoTabPane = new JTabbedPane();
          * Main panel located in center that holds the tabbed pane "empInfoTabPane"
         private JPanel pCenterMain = new JPanel(new FlowLayout(FlowLayout.LEFT,25,30));
          * Panel that holds the table "table"
         private JPanel pTable = new JPanel(new GridLayout(2,1));
          * Main panel that holds the Basic Pay Report(s)
         private JPanel pBasicPayRep = new JPanel(new FlowLayout(FlowLayout.CENTER,10,20));
          * Main panel that holds the Trend Report(s)
         private JPanel pTrendRep = new JPanel(new FlowLayout(FlowLayout.CENTER,10,10));
          * Panel that holds all the add/remove fields, combo boxes and buttons
         private JPanel pAddRemove = new JPanel(new GridLayout(2,1));
            * Panel and Labels for Basic Pay Report
           private JPanel pBasicPayRepMain = new JPanel(new GridLayout(2,1));
          * Holds the pBasicPayGridLeft and pBasicPayGridRight
         private JPanel pBasicPayRepBot = new JPanel(new FlowLayout(FlowLayout.CENTER));
          * Holds the labels for each report
          * Recent Pay Period Worked, Cumulative Pay, Average Pay
         private JPanel pBasicPayGridLeft = new JPanel(new FlowLayout(FlowLayout.LEFT));
          * Holds all the basic pay report information for
          * Recent Pay Period Worked, Cumulative Pay, Average Pay
         private JPanel pBasicPayGridRight = new JPanel(new FlowLayout(FlowLayout.LEFT,20,0));
          * Displays the total number of employees that worked in the current pay period
         private JLabel txtTotalAllEmployees = new JLabel("0");
          * Displays the total number of Salaried employees that worked in the current pay period
         private JLabel txtTotalSalaried = new JLabel("0");
          * Displays the total number of Hourly employees that worked in the current pay period
         private JLabel txtTotalHourly = new JLabel("0");
          * Displays the total number of Temporary employees that worked in the current pay period
         private JLabel txtTotalTemporary = new JLabel("0");
          * Displays the total number of Contract employees that worked in the current pay period
         private JLabel txtTotalContract = new JLabel("0");
          * Displays the cumulative hourly rate in the current pay period
         private JLabel txtCumHourlyRate = new JLabel("0.00");
          * Displays the cumulative hours workded in the current pay period
           private JLabel txtCumHoursWorked = new JLabel("0");
          * Displays the cumulative gross pay in the current pay period
           private JLabel txtCumGrossPay = new JLabel("0.00");
          * Displays the cumulative tax paid in the current pay period
           private JLabel txtCumTax = new JLabel("0.00");
          * Displays the cumulative net pay in the current pay period
           private JLabel txtCumNetPay = new JLabel("0.00");
          * Displays the average hourly rate in the current pay period
           private JLabel txtAvgHourlyRate = new JLabel("0.00");
          * Displays the average hours workded in the current pay period
           private JLabel txtAvgHoursWorked = new JLabel("0.0");
          * Displays the average gross pay in the current pay period
           private JLabel txtAvgGrossPay = new JLabel("0.00");
          * Displays the average tax paid in the current pay period
           private JLabel txtAvgTax = new JLabel("0.00");
          * Displays the average net pay in the current pay period
           private JLabel txtAvgNetPay = new JLabel("0.00");
          * The table "table" created in the instance "quickTable"
         private JTable table = new JTable(quickTable);
          * The table "table2" created in the instance "BasicPayTable"
         private JTable table2 = new JTable(basicPayTable);
          * Turns the table "table" into a scroll pane
        private JScrollPane scrollpane = new JScrollPane(table);
          * Turns the table "table2" into a scroll pane2
        private JScrollPane scrollpane2 = new JScrollPane(table2);
          * **** Future Button to update the employee information in "table"
        private JButton updateEmplInfo = new JButton("Update");
         * Add button to add an employee
        private JButton bAdd = new JButton("Add");
         * Remove button to remove an employee
         private JButton bRemove = new JButton("Remove");
         * Search by employee ID button
         private JButton bSearchId = new JButton("Search");
         * Search by employee name button
         private     JButton bSearchName = new JButton("Search");
         * Texfield collects an employees ID number
        private JTextField fieldID = new JTextField(6);
         * Texfield collects an employees Last name
         private JTextField fieldLastName = new JTextField(22);
         * Texfield collects an employees First name
         private JTextField fieldFirstName = new JTextField(15);
         * Texfield collects an employees Middle initial
         private JTextField fieldMiddleInitial = new JTextField(1);
         * Texfield collects an employees street address
         private JTextField fieldStreetAddress = new JTextField(22);
         * Texfield collects an employees city lived in
         private JTextField fieldCity = new JTextField(18);
         * Texfield collects an employees state lived in
         private JTextField fieldState = new JTextField(2);
         * Texfield collects an employees zip code
         private JTextField fieldZip = new JTextField(6);
         * Texfield collects an employees hourly rate
         private JTextField fieldHourlyRate = new JTextField("0.00",6);
         * Texfield collects an employees year they started working
         private JTextField fieldYYYY = new JTextField("YYYY",4);
         * Texfield collects an employees ID number to perform a search with
         private JTextField fieldSearchById = new JTextField(6);
         * Texfield collects an employees last name to perform a search with
         private JTextField fieldSearchByLast = new JTextField(22);
         * Texfield collects an employees first name to perform a search with
         private     JTextField fieldSearchByFirst = new JTextField(15);
         * Texfield collects an employees middle initial to perform a search with
         private     JTextField fieldSearchByMiddle = new JTextField(1);
          * Background color designed to mimic Microsofts's default desktop color
         private Color MS = new Color(64,128,128);
         * Color used to simulate a manilla folder
         * <br>Used on the folders
         private Color manilla = new Color(252,220,140);
         * Color a complimenting color to "manilla" and "MS"
         * <br>Used as an accent in the search frames and tabs
         private Color seaFoam = new Color(156,198,172);
         * Color a complimenting color to "manilla" and "MS"
         * <br>Used as an accent in the tabs
         private Color babyBlue = new Color(170,220,238);
         * Color a complimenting color to "manilla" and "MS"
         * <br>Used as an accent in the tabs
         private Color lightPink = new Color(255,204,207);
         * Array of Strings: the 12 months of the year
         private String [] monthMM = {"MM","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug",
                                             "Sep","Oct","Nov","Dec"};
         * Array of Strings: the days of the month
         private String [] dayDD = {"DD","01","02","03","04","05","06","07","08","09","10","11",
                                          "12","13","14","15","16","17","18","19","20","21","22",
                                          "23","24","25","26","27","28","29","30","31"};
         * Array of Strings: employee types
         * <br>"Salaried","Hourly","Temporary","Contract"
         private String [] emplType = {"Emp Type","Salaried","Hourly","Temporary","Contract"};
         * String holds the month by using getSelectedItem()
         private String sMonth = "";
         * String holds the day by using getSelectedItem()
         private String sDay = "";
         * String holds the entire hire date
         private String sHireDate = "";
         * String holds the entire employee address
         private String sEmpAddress = "";
         * Double the horly rate paid to an employee
         private double hourlyRate = 0.0;
         * Drop down combo box displays the months of the year
        private JComboBox listMM = new JComboBox(monthMM);
         * Drop down combo box displays the days of the month
         private JComboBox listDD = new JComboBox(dayDD);
         * Drop down combo box displays the employee types
         private JComboBox listEmplType = new JComboBox(emplType);
         private JPanel pTrendReportMain = new JPanel();
         private JPanel pTrendReport = new JPanel();
         private JPanel pTrendRepMain = new JPanel(new GridLayout(2,1));
         private JPanel pTrendBot = new JPanel(new FlowLayout(FlowLayout.CENTER));
         private JPanel pTrendGridLeft = new JPanel(new FlowLayout(FlowLayout.LEFT));
         private JPanel pTrendGridRight = new JPanel(new FlowLayout(FlowLayout.LEFT,20,0));
         private JButton button, button2;
         private JLabel []JLab = new JLabel[4];
         private JTextField titletxt;
         private JTextField []Text = new JTextField[5];
         private JTextField []labeltxt = new JTextField[5];
         private JLabel txtTrendTotalEmployees = new JLabel("0");
         private JLabel txtTrendCumHourlyRate = new JLabel("0.00");
         private JLabel txtTrendAvgHourlyRate = new JLabel("0.00");
         private JLabel txtTrendTotalSalaried = new JLabel("0");
         private JLabel txtTrendCumHoursWorked = new JLabel("0");
         private JLabel txtTrendAvgHoursWorked = new JLabel("0.0");
         private JLabel txtTrendTotalHourly = new JLabel("0");
         private JLabel txtTrendCumGrossPay = new JLabel("0.00");
         private JLabel txtTrendAvgGrossPay = new JLabel("0.00");
         private JLabel txtTrendTotalTemporary = new JLabel("0");
         private JLabel txtTrendCumTax = new JLabel("0.00");
         private JLabel txtTrendAvgTax = new JLabel("0.00");
         private JLabel txtTrendTotalContract = new JLabel("0");
         private JLabel txtTrendCumNetPay = new JLabel("0.00");
         private JLabel txtTrendAvgNetPay = new JLabel("0.00");
         //Don't know if we can use these yet
         //private JLabel lPayPeriodStart = new JLabel("YYYY MM PP");
         //private JLabel lPayPeriodEnd = new JLabel("YYYY MM PP");
          * Standard constructor
          * <br>Call the main methods required to get the application to start
         public A332IWon(String title)
              super(title);
              menuDialogBar();
              setUpPanels();
              setContainerLayout();
              listenToMenuBar();
              listenToButtons();
              addWindowListener(new CloseWindow());
          * Contains all the ActionListener events associated with the menu bar
         public void listenToMenuBar()
              fileEmpTxtFile.addActionListener(quickTable);
              filePayInfoFile.addActionListener(quickTable);
              fileOpen.addActionListener(quickTable);
              fileSave.addActionListener(quickTable);
              fileExit.addActionListener(quickTable);
              editAddRemove.addActionListener(quickTable);
              editID.addActionListener(quickTable);
              editName.addActionListener(quickTable);
              repBasicPay.addActionListener(quickTable);
              repTrend.addActionListener(quickTable);
              helpAbout.addActionListener(quickTable);
          * Contains all ActionListener events associated with buttons and combo boxes
         public void listenToButtons()
              bAdd.addActionListener(quickTable);
              bRemove.addActionListener(quickTable);
              listMM.addActionListener(quickTable);
              listDD.addActionListener(quickTable);
              listEmplType.addActionListener(quickTable);
              bSearchId.addActionListener(quickTable);
              bSearchName.addActionListener(quickTable);
          * Contains the menu bar, the menus, and all the sub menu items
         public void menuDialogBar()
               JLabel menuShim = new JLabel("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
                                                 + "XXXXXXXXXXXXXXXXXXXXXXx12345");
               setJMenuBar(bar);
               bar.add(menuFile);
               bar.add(menuEdit);
               bar.add(menuReports);
               bar.add(menuHelp);
               bar.add(menuShim);
               menuShim.setVisible(false);
               menuFile.add(fileImport);
               fileImport.add(fileEmpTxtFile);
               fileImport.add(filePayInfoFile);
               menuFile.add(fileOpen);
               menuFile.add(fileSave);
               menuFile.add(fileExit);
               menuEdit.add(editAddRemove);
               menuEdit.add(editSearch);
               editSearch.add(editID);
               editSearch.add(editName);
               menuReports.add(repBasicPay);
               menuReports.add(repTrend);
               menuHelp.add(helpAbout);
          * Sets the layout for the container "c" and sets pCenterMain centered in "c"
         public void setContainerLayout()
              c.setLayout(new BorderLayout());
              c.add(pCenterMain, "Center");
          * Sets up the main panels needed at run time
         public void setUpPanels()
              centerMainPanel();
              tabbedPane();
              tabPanels();
              addRemovePanel();
              basicPayReportMain();
              trendReportMain();
          * Sets up the main panel with the tabbed pane "empInfoTabPane"
         public void centerMainPanel()
              pCenterMain.add(empInfoTabPane);
              pCenterMain.setBackground(MS);
          * Sets up the tabbed pane with the table, and eddit block,
          * basic pay report, and trend report
         public void tabbedPane()
             empInfoTabPane.addTab("Employee Information",pTable);
             empInfoTabPane.addTab("Basic Pay Report",pBasicPayRep);
             empInfoTabPane.addTab("Trend Report",pTrendRep);
             //empInfoTabPane.setBackground(manilla);
             //empInfoTabPane.setBackgroundAt(0,manilla);
             empInfoTabPane.setBackgroundAt(0,seaFoam);
             empInfoTabPane.setBackgroundAt(1,lightPink);
             empInfoTabPane.setBackgroundAt(2,babyBlue);
             //AUTO_RESIZE_OFF
             //empInfoTabPane.setEnabledAt(0,false);
          * Sets up the panels in the tabbed pane
         public void tabPanels()
              //JLabel tabTrendRep = new JLabel("This area will show a Trend report");
             JPanel pTableTop = new JPanel(new FlowLayout(FlowLayout.CENTER,20,20));
             JPanel pTableBottom = new JPanel(new FlowLayout(FlowLayout.LEFT));
              scrollpane.setPreferredSize(new Dimension(695,185));
              scrollpane2.setPreferredSize(new Dimension(695,185));
              pTableTop.add(scrollpane);
              pTableBottom.add(pAddRemove);
              pTableTop.setBackground(manilla);
              pTableBottom.setBackground(manilla);
              pTable.add(pTableTop);
              pTable.add(pTableBottom);
              pBasicPayRep.add(pBasicPayRepMain);
             pBasicPayRep.setBackground(manilla);
             pTrendRep.add(pTrendRepMain);
             pTrendRep.setBackground(manilla);
          * Sets up the basic pay report main panel that holds the table and the bottom pay report
         public void basicPayReportMain()
              pBasicPayRepMain.add(scrollpane2);
              pBasicPayRepMain.add(pBasicPayRepBot);
              basicPayRepTotalsPanel();
          * Sets up the basic pay report grid panel under the basic pay report table.
         public void basicPayRepTotalsPanel()
              JPanel pBasicPayLeftRight = new JPanel(new FlowLayout(FlowLayout.CENTER,10,5));
                pBasicPayRepBot.add(pBasicPayLeftRight);
                pBasicPayRepBot.setBackground(manilla);
                pBasicPayLeftRight.add(pBasicPayGridLeft);
                pBasicPayLeftRight.add(pBasicPayGridRight);
                pBasicPayLeftRight.setBackground(manilla);
                basicPayGridLeft();
                basicPayGridRight();
          * Sets up the left grid of the basic pay report grid panel.
         public void basicPayGridLeft()
              JPanel pColumn1 = new JPanel(new GridLayout(10,1));
              JLabel lblTotalEmployees = new JLabel("Recent Pay Period Worked");
              JLabel lblCumulativePay = new JLabel("Cumulative Pay");
              JLabel lblAveragePay = new JLabel("Average Pay");
              JLabel lblShim1 = new JLabel("X");
              JLabel lblShim2 = new JLabel("X");
              JLabel lblShim3 = new JLabel("X");
              lblShim1.setForeground(manilla);
              lblShim2.setForeground(manilla);
              lblShim3.setForeground(manilla);
              pColumn1.add(lblTotalEmployees);
              pColumn1.add(lblShim1);
              pColumn1.add(new JLabel(" "));
              pColumn1.add(new JLabel(" "));
              pColumn1.add(lblCumulativePay);
              pColumn1.add(lblShim2);
              pColumn1.add(new JLabel(" "));
              pColumn1.add(new JLabel(" "));
              pColumn1.add(lblAveragePay);
              pColumn1.add(lblShim3);
              pColumn1.setBackground(manilla);
              lblTotalEmployees.setForeground(Color.black);
              lblCumulativePay.setForeground(Color.black);
              lblAveragePay.setForeground(Color.black);
              pBasicPayGridLeft.add(pColumn1);
              pBasicPayGridLeft.setBackground(manilla);
          * Sets up the right grid of the basic pay report grid panel.
          * <br>This is one narly method
         public void basicPayGridRight()
              JPanel pColumn1 = new JPanel(new GridLayout(10,1));
              JPanel pColumn2 = new JPanel(new GridLayout(10,1));
              JPanel pColumn3 = new JPanel(new GridLayout(10,1));
              JPanel pColumn4 = new JPanel(new GridLayout(10,1));
              JPanel pColumn5 = new JPanel(new GridLayout(10,1));
                JLabel lblTotalEmployees = new JLabel("Employees");
                JLabel lblTotalSalaried = new JLabel("Salaried");
                JLabel lblTotalHourly = new JLabel("Hourly");
                JLabel lblTotalTemporary = new JLabel("Temporary");
                JLabel lblTotalContract = new JLabel("Contract");
                JLabel lblCumHourlyRate = new JLabel("Pay Rate");
                JLabel lblCumHoursWorked = new JLabel("Hours Worked");
                JLabel lblCumGrossPay = new JLabel("Gross Pay");
                JLabel lblCumTax = new JLabel("Flat Tax 15%");
                JLabel lblCumNetPay = new JLabel("Net Pay");
                JLabel lblAvgHourlyRate = new JLabel("Pay Rate");
                JLabel lblAvgHoursWorked = new JLabel("Hours Worked");
                JLabel lblAvgGrossPay = new JLabel("Gross Pay");
                JLabel lblAvgTax = new JLabel("Flat Tax 15%");
                JLabel lblAvgNetPay = new JLabel("Net Pay");
              pColumn1.add(lblTotalEmployees);
              pColumn1.add(txtTotalAllEmployees);
              pColumn1.add(new JLabel(" "));
              pColumn1.add(new JLabel(" "));
              pColumn1.add(lblCumHourlyRate);
              pColumn1.add(txtCumHourlyRate);
              pColumn1.add(new JLabel(" "));
              pColumn1.add(new JLabel(" "));
              pColumn1.add(lblAvgHourlyRate);
              pColumn1.add(txtAvgHourlyRate);
              pColumn1.setBackground(manilla);
              lblTotalEmployees.setForeground(Color.black);
              txtTotalAllEmployees.setForeground(Color.black);
              lblCumHourlyRate.setForeground(Color.black);
              txtCumHourlyRate.setForeground(Color.black);
              lblAvgHourlyRate.setForeground(Color.black);
              txtAvgHourlyRate.setForeground(Color.black);
              pColumn2.add(lblTotalSalaried);
              pColumn2.add(txtTotalSalaried);
              pColumn2.add(new JLabel(" "));
              pColumn2.add(new JLabel(" "));
              pColumn2.add(lblCumHoursWorked);
              pColumn2.add(txtCumHoursWorked);
              pColumn2.add(new JLabel(" "));
              pColumn2.add(new JLabel(" "));
              pColumn2.add(lblAvgHoursWorked);
              pColumn2.add(txtAvgHoursWorked);
              pColumn2.setBackground(manilla);
              lblTotalSalaried.setForeground(Color.black);
              txtTotalSalaried.setForeground(Color.black);
              lblCumHoursWorked.setForeground(Color.black);
              txtCumHoursWorked.setForeground(Color.black);
              lblAvgHoursWorked.setForeground(Color.black);
              txtAvgHoursWorked.setForeground(Color.black);
              pColumn3.add(lblTotalHourly);
              pColumn3.add(txtTotalHourly);
              pColumn3.add(new JLabel(" "));
              pColumn3.add(new JLabel(" "));
              pColumn3.add(lblCumGrossPay);
              pColumn3.add(txtCumGrossPay);
              pColumn3.add(new JLabel(" "));
              pColumn3.add(new JLabel(" "));
              pColumn3.add(lblAvgGrossPay);
              pColumn3.add(txtAvgGrossPay);
              pColumn3.setBackground(manilla);
              lblTotalHourly.setForeground(Color.black);
              txtTotalHourly.setForeground(Color.black);
              lblCumGrossPay.setForeground(Color.black);
              txtCumGrossPay.setForeground(Color.black);
              lblAvgGrossPay.setForeground(Color.black);
              txtAvgGrossPay.setForeground(Color.black);
              pColumn4.add(lblTotalTemporary);
              pColumn4.add(txtTotalTemporary);
              pColumn4.add(new JLabel(" "));
              pColumn4.add(new JLabel(" "));
              pColumn4.add(lblCumTax);
              pColumn4.add(txtCumTax);
              pColumn4.add(new JLabel(" "));
              pColumn4.add(new JLabel(" "));
              pColumn4.add(lblAvgTax);
              pColumn4.add(txtAvgTax);
              pColumn4.setBackground(manilla);
              lblTotalTemporary.setForeground(Color.black);
              txtTotalTemporary.setForeground(Color.black);
              lblCumTax.setForeground(Color.black);
              txtCumTax.setForeground(Color.black);
              lblAvgTax.setForeground(Color.black);
              txtAvgTax.setForeground(Color.black);
              pColumn5.add(lblTotalContract);
              pColumn5.add(txtTotalContract);
              pColumn5.add(new JLabel(" "));
              pColumn5.add(new JLabel(" "));
              pColumn5.add(lblCumNetPay);
              pColumn5.add(txtCumNetPay);
              pColumn5.add(new JLabel(" "));
              pColumn5.add(new JLabel(" "));
              pColumn5.add(lblAvgNetPay);
              pColumn5.add(txtAvgNetPay);
              pColumn5.setBackground(manilla);
              lblTotalContract.setForeground(Color.black);
              txtTotalContract.setForeground(Color.black);
              lblCumNetPay.setForeground(Color.black);
              txtCumNetPay.setForeground(Color.black);
              lblAvgNetPay.setForeground(Color.black);
              txtAvgNetPay.setForeground(Color.black);
              pBasicPayGridRight.add(pColumn1);
              pBasicPayGridRight.add(pColumn2);
              pBasicPayGridRight.add(pColumn3);
              pBasicPayGridRight.add(pColumn4);
              pBasicPayGridRight.add(pColumn5);
              pBasicPayGridRight.setBackground(manilla);
          * Sets up the trend report main panel that holds the graph and the bottom trend report
         public void trendReportMain()//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
              //pTrendReportMain.add(trendReport);// changed pTrendReport to trendReport
              pTrendRepMain.add(trendReport);//changed pTrendRepMain to trendReport
              pTrendRepMain.add(pTrendBot);
              trendReportTotalsPanel();
         public void trendReportTotalsPanel()
              JPanel pTrendLeftRight = new JPanel(new FlowLayout(FlowLayout.CENTER,10,5));
                pTrendBot.add(pTrendLeftRight);
                pTrendBot.setBackground(manilla);
                pTrendLeftRight.add(pTrendGridLeft);
                pTrendLeftRight.add(pTrendGridRight);
                pTrendLeftRight.setBackground(manilla);
                trendReportLeft();
                trendReportRight();
         public void trendReportLeft()
              JPanel pColumn1 = new JPanel(new GridLayout(10,1));
              JLabel lblTotalEmployees = new JLabel("Recent Pay Period Worked");
              JLabel lblCumulativePay = new JLabel("Cumulative Pay Info");
              JLabel lblAveragePay = new JLabel("Average Pay Info");
              JLabel lblShim1 = new JLabel("X");
              JLabel lblShim2 = new JLabel("X");
              JLabel lblShim3 = new JLabel("X");
              lblShim1.setForeground(manilla);
              lblShim2.setForeground(manilla);
              lblShim3.setForeground(manilla);
              pColumn1.add(lblTotalEmployees);
              pColumn1.add(lblShim1);
              pColumn1.add(new JLabel(" "));
              pColumn1.add(new JLabel(" "));
              pColumn1.add(lblCumulativePay);
              pColumn1.add(lblShim2);
              pColumn1.add(new JLabel(" "));
              pColumn1.add(new JLabel(" "));
              pColumn1.add(lblAveragePay);
              pColumn1.add(lblShim3);
              pColumn1.setBackground(manilla);
              lblTotalEmployees.setForeground(Color.black);
              lblCumulativePay.setForeground(Color.black);
              lblAveragePay.setForeground(Color.black);
              pTrendGridLeft.add(pColumn1);
              pTrendGridLeft.setBackground(manilla);
         public void trendReportRight()
              JPanel pColumn1 = new JPanel(new GridLayout(10,1));
              JPanel pColumn2 = new JPanel(new GridLayout(10,1));
              JPanel pColumn3 = new JPanel(new GridLayout(10,1));
              JPanel pColumn4 = new JPanel(new GridLayout(10,1));
              JPanel pColumn5 = new JPanel(new GridLayout(10,1));
                JLabel lblTotalEmployees = new JLabel("Employees");
                JLabel lblTotalSalaried = new JLabel("Salaried");
                JLabel lblTotalHourly = new JLabel("Hourly");
                JLabel lblTotalTemporary = new JLabel("Temporary");
                JLabel lblTotalContract = new JLabel("Contract");
                JLabel lblCumHourlyRate = new JLabel("Pay Rate");
                JLabel lblCumHoursWorked = new JLabel("Hours Worked");
                JLabel lblCumGrossPay = new JLabel("Gross Pay");
                JLabel lblCumTax = new JLabel("Flat Tax 15%");
                JLabel lblCumNetPay = new JLabel("Net Pay");
                JLabel lblAvgHourlyRate = new JLabel("Pay Rate");
                JLabel lblAvgHoursWorked = new JLabel("Hours Worked");
                JLabel lblAvgGrossPay = new JLabel("Gross Pay");
                JLabel lblAvgTax = new JLabel("Flat Tax 15%");
                JLabel lblAvgNetPay = new JLabel("Net Pay");
              pColumn1.add(lblTotalEmployees);
              pColumn1.add(txtTrendTotalEmployees);     //txtTrendTotalEmployees
              pColumn1.add(new JLabel                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            &n

    This class declaration won't do for loading into a JTabbedPane
    public class TrendReport extends JFrame implements ActionListener {Try this in it's place
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class TrendRx {
      public static void main(String[] args) {
        JFrame f = new JFrame();
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        TrendReport trendReport = new TrendReport();
        f.getContentPane().add(trendReport);
        f.setSize(500,300);
        f.setLocation(100,100);
        f.setVisible(true);
    class TrendReport extends JPanel implements ActionListener {
      int width;
      int height;
      JButton button;
      int []bar = new int[4];
      float []flote = {1395,1296,1402,1522};
      String []valuesInput = {"1395","1296","1402","1522"};
      String str = "", title="Title goes here";
      String []barLabels = {
        "pp01, Oct. 2003","pp02, Oct. 2003","pp01, Nov. 2003","pp02, Nov. 2003"
      String []percent = {"","","",""};
      JLabel []JLab = new JLabel[4];
      JTextField titletxt;
      JTextField []Text = new JTextField[5];
      JTextField []labeltxt = new JTextField[5];
      boolean pieChart;
      public TrendReport() {
        setOpaque(false);
        setLayout(new FlowLayout() );
        button = new JButton("Bar TrendReport");
        button.addActionListener(this);
    //    for (int k=0; k<4; k++){
    //      str = Integer.toString(k+1);
        add(button);
      public void paintComponent(Graphics g) {
        width = getWidth();
        height = getHeight();
        Graphics2D g2 = (Graphics2D)g;                    
        g2.setColor(new Color(223,222,224));
        g2.fillRect(0,0,width,height);
        g2.setColor(Color.orange);
        if(pieChart) {
          g2.fillArc(getW(30), getH(130), getW(220), getH(220), 90, -bar[0]);
          g2.fillRect(getW(270), getH(170), getW(30), getH(20));
        else
          g2.fillRect(getW(30), getH(150), getW(bar[0]), getH(30));
        g2.setColor(Color.green);
        if(pieChart) {
          g2.fillArc(getW(30), getH(130), getW(220), getH(220), 90-bar[0], -bar[1]);
          g2.fillRect(getW(270), getH(210), getW(30), getH(20));
        else
          g2.fillRect(getW(30), getH(190), getW(bar[1]), getH(30));
        g2.setColor(Color.red);
        if(pieChart) {
          g2.fillArc(getW(30), getH(130), getW(220), getH(220),
                     90-(bar[0]+bar[1]), -bar[2]);
          g2.fillRect(getW(270), getH(250), getW(30), getH(20));
        else
          g2.fillRect(getW(30), getH(230), getW(bar[2]), getH(30));
        g2.setColor(Color.blue);
        if(pieChart) {
          g2.fillArc(getW(30), getH(130), getW(220), getH(220),
                     90-(bar[0]+bar[1]+bar[2]), -bar[3]);
          g2.fillRect(getW(270), getH(290), getW(30), getH(20));
        else
          g2.fillRect(getW(30), getH(270), getW(bar[3]), getH(30));
        g2.setColor(Color.black);
        g2.setFont(new Font("Arial", Font.BOLD, 18));
        if(pieChart)
          g2.drawString(title, getW(220), getH(142));
        else
          g2.drawString(title, getW(50), getH(132));
        g2.setFont(new Font("Arial", Font.PLAIN,16));
        int temp=0;
        if(pieChart)
          temp = 185;
        else
          temp = 172;
        for(int j=0; j <4; j++) {
          if(pieChart)
            g2.drawString("$"+valuesInput[j]+" "+barLabels[j]+percent[j],
                          getW(305), getH(temp));//XXXXXXXXXXXXXXX
          else
            g2.drawString("$"+valuesInput[j]+" "+barLabels[j]+percent[j],
                          getW(bar[j]+40), getH(temp));
          temp += 40;
        if(!pieChart){
          g2.drawLine(getW(30), getH(130), getW(30), getH(300));
          g2.drawLine(getW(30), getH(300), getW(430), getH(300));               
          g2.setFont(new Font("Arial", Font.PLAIN,12));
        super.paintComponent(g2);
      private int getW(int dx) {
        return (dx * width) / 550;
      private int getH(int dy) {
        return (dy * height) / 400;
      public void actionPerformed(ActionEvent e) {
        String command = e.getActionCommand();
        if(command.equals("Bar TrendReport")){
          button.setText("Pie Chart");
          pieChart=false;
          try {
            int temp =0;
            java.text.DecimalFormat df = new java.text.DecimalFormat("#0.#");
            for (int j=0; j<4; j++){
              //flote[j] = Float.parseFloat(Text[j].getText());//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
              temp += (int)((flote[j]) +0.5);
            for (int k=0; k<4; k++){
              bar[k] = (int)(((flote[k]/temp) * 360)+0.5);
              //barLabels[k] = labeltxt[k].getText();XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
              flote[k] = (flote[k]/temp) *100;
              percent[k] = ": "+df.format(flote[k])+"%";
          catch(Exception message){
            title = "Oops! Complete all fields, enter numbers only";
        if(command.equals("Pie Chart")){
          button.setText("Bar TrendReport");
          pieChart=true;
        repaint();
    }

Maybe you are looking for