🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #7226

Re: Combine methods

#7226
From: KK
Date: Wed, 04 Jul 2001 03:06
75 lines
3441 bytes
Sorry Joi. Yes, I made a mistake! The codes should be:

    public void showDlgSimLib() {
        dlg_ec_simlib dlg = new dlg_ec_simlib(this);
        Dimension dlgSize = dlg.getPreferredSize();
        Dimension frmSize = getSize();
        Point loc = getLocation();
        dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x,
(frmSize.height - dlgSize.height) / 2 + loc.y);
        dlg.show();
    }

    public void showDlgSynLib() {
        dlg_ec_synlib dlg = new dlg_ec_synlib(this);
        Dimension dlgSize = dlg.getPreferredSize();
        Dimension frmSize = getSize();
        Point loc = getLocation();
        dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x,
(frmSize.height - dlgSize.height) / 2 + loc.y);
        dlg.show();
    }

I want to combine them into one so that I can manage them easier. I find a
problem that since the dialog classes (dlg_ec_simlib and dlg_ec_synlib) are
different so that I cannot use the dialog object as the parameter of the
method.

Ken




"Joi Ellis [TeamB]" <joi@aravox.com> wrote in message
news:3b414f60_2@dnews...
> KK <kk@hotmail.com> wrote:
> > Dear all:
>
> > Is there any solution to combine the following methods into one? Since
they
> > look similar, I would like to combine them and make the program
simplier.
>
> > Ken
>
> > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> >     public void showDlgSimLib() {
> >         dlg_ec_simlib dlg = new dlg_ec_simlib(this);
> >         Dimension dlgSize = dlg.getPreferredSize();
> >         Dimension frmSize = getSize();
> >         Point loc = getLocation();
> >         dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x,
> > (frmSize.height - dlgSize.height) / 2 + loc.y);
> >         dlg.show();
> >     }
>
> >     public void showDlgSimLib() {
> >         dlg_ec_simlib dlg = new dlg_ec_simlib(this);
> >         Dimension dlgSize = dlg.getPreferredSize();
> >         Dimension frmSize = getSize();
> >         Point loc = getLocation();
> >         dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x,
> > (frmSize.height - dlgSize.height) / 2 + loc.y);
> >         dlg.show();
> >     }
>
> Uhh.  These two fragments are identical.  Did you intend to paste in
> a different fragment?
>
>
> --
> Joi Ellis (TeamB)               http://www.teamb.com/
> No direct email, please.
> For best results, post on news server newsgroups.borland.com!
> Newsgroup Info: http://www.borland.com/newsgroups/guide.html
Technical Details
Message-ID: <3b4288c8_1@dnews>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews
References: <3b414874_1@dnews> <3b414f60_2@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,b25916793f54693d
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2001-07-03 20:09:27 PST
From: "KK" <kk@hotmail.com>
Newsgroups: borland.public.jbuilder.java.language
References: <3b414874_1@dnews> <3b414f60_2@dnews>
Subject: Re: Combine methods
Date: Wed, 4 Jul 2001 11:06:37 +0800
Lines: 77
Organization: CDS
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.3018.1300
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.3018.1300
NNTP-Posting-Host: 158.140.230.175
Message-ID: <3b4288c8_1@dnews>
X-Trace: dnews 994216136 158.140.230.175 (3 Jul 2001 20:08:56 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews