You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@netbeans.apache.org by Peter Cheung <mc...@hotmail.com> on 2019/07/25 04:35:37 UTC

Newbie questions

Dear All
    How to maintain there is only one instance of a topcomponent window of a specific class?
    How to close all topcomponent of a specific class?


Thanks
From Peter

Re: Newbie questions

Posted by Patrik Karlström <pa...@trixon.se>.
I'm closing all MMapMagnets (kind of property TopComponents), that should
only be visible when the MapTopComponents is with

        final WindowManager windowManager = WindowManager.getDefault();
        windowManager.getModes().stream().filter((mode) ->
!(mode.equals(windowManager.findMode(this)))).forEachOrdered((mode) -> {
            TopComponent selectedTopComponent =
mode.getSelectedTopComponent();
            for (TopComponent tc : mode.getTopComponents()) {
                if (tc instanceof MTopComponent && tc.isOpened() &&
!windowManager.isTopComponentFloating(tc)) {
                    if (tc instanceof MMapMagnet) {
                        if (tc.equals(selectedTopComponent)) {
                            mActiveMapMagnets.add(tc);
                        }

                        tc.close();
                        mMapMagnets.add(tc);
                    }
                }
            }
        });

In short, use the WindowManager and Modes.


And in context, no pun intended.
https://github.com/trixon/mapton/blob/8e149fbe9e2f1cfb0ff585f718c8e3c56eba82ba/core/src/main/java/org/mapton/core/ui/MapTopComponent.java#L192

Den tors 25 juli 2019 kl 06:35 skrev Peter Cheung <mc...@hotmail.com>:

> Dear All
>     How to maintain there is only one instance of a topcomponent window of
> a specific class?
>     How to close all topcomponent of a specific class?
>
>
> Thanks
> From Peter
>

Re: Newbie questions

Posted by Peter Cheung <mc...@hotmail.com>.
Thanks a lot gentlemen, let me improve myself.

On 25 Jul 2019, at 11:53 PM, Geertjan Wielenga <ge...@apache.org>> wrote:

On Thu, Jul 25, 2019 at 5:21 PM Peter Cheung <mc...@hotmail.com>> wrote:

I am not sure why my reason is so important,


The reason is it important is that it provides context to try to understand
what you're trying to achieve. Can you always provide context, as well as
always think about the subject line, which right now has no context at all?
In what was is this a newbie question, at all?


but i just want to do these:

   How to maintain there is only one instance of a topcomponent window of
a specific class?
   How to close all topcomponent of a specific class?

OK, my reason is:

when you open an editor, there is a property window, whatever how many
editor you are opened, since there is only one active editor, so there is
only one property window. If can't control only one instance of a
topcomponent, how can we achieve this.

I am not sure why you think it is so important to ask for my reason to
solve a specific technical question. If people ask "how to solve my
for-loop error", do we really need to know his reason to write his
for-loop? Or I am thinking i am being discriminated.



Yes, the context will always be asked. In this case, the reason why the
Properties window works with the editor is because the Lookup is used. Here
you can learn about the Lookup:

https://platform.netbeans.org/tutorials/nbm-selection-1.html

Gj




If people in here think i am disturbing, i can quit.

Thanks
From Peter
________________________________
From: Eric Bresie <eb...@gmail.com>>
Sent: Thursday, July 25, 2019 10:09 PM
To: Apache NetBeans <de...@netbeans.apache.org>>
Subject: Re: Re: Newbie questions

http://www.catb.org/~esr/faqs/smart-questions.html

Eric Bresie
Ebresie@gmail.com
On July 24, 2019 at 11:54:27 PM PDT, Geertjan Wielenga <
geertjan@apache.org> wrote:
PS: Can you think hard about the subject line when you start a new
thread?

On Thu, Jul 25, 2019 at 8:53 AM Geertjan Wielenga <ge...@apache.org>
wrote:

More details needed, the context, the why, etc.

Gj

On Thu, Jul 25, 2019 at 6:35 AM Peter Cheung <mc...@hotmail.com>
wrote:

Dear All
How to maintain there is only one instance of a topcomponent window
of a specific class?
How to close all topcomponent of a specific class?


Thanks
From Peter


Re: Re: Newbie questions

Posted by Geertjan Wielenga <ge...@apache.org>.
On Thu, Jul 25, 2019 at 5:21 PM Peter Cheung <mc...@hotmail.com> wrote:

> I am not sure why my reason is so important,


The reason is it important is that it provides context to try to understand
what you're trying to achieve. Can you always provide context, as well as
always think about the subject line, which right now has no context at all?
In what was is this a newbie question, at all?


> but i just want to do these:
>
>     How to maintain there is only one instance of a topcomponent window of
> a specific class?
>     How to close all topcomponent of a specific class?
>
> OK, my reason is:
>
> when you open an editor, there is a property window, whatever how many
> editor you are opened, since there is only one active editor, so there is
> only one property window. If can't control only one instance of a
> topcomponent, how can we achieve this.
>
> I am not sure why you think it is so important to ask for my reason to
> solve a specific technical question. If people ask "how to solve my
> for-loop error", do we really need to know his reason to write his
> for-loop? Or I am thinking i am being discriminated.
>


Yes, the context will always be asked. In this case, the reason why the
Properties window works with the editor is because the Lookup is used. Here
you can learn about the Lookup:

https://platform.netbeans.org/tutorials/nbm-selection-1.html

Gj



>
> If people in here think i am disturbing, i can quit.
>
> Thanks
> From Peter
> ________________________________
> From: Eric Bresie <eb...@gmail.com>
> Sent: Thursday, July 25, 2019 10:09 PM
> To: Apache NetBeans <de...@netbeans.apache.org>
> Subject: Re: Re: Newbie questions
>
> http://www.catb.org/~esr/faqs/smart-questions.html
>
> Eric Bresie
> Ebresie@gmail.com
> > On July 24, 2019 at 11:54:27 PM PDT, Geertjan Wielenga <
> geertjan@apache.org> wrote:
> > PS: Can you think hard about the subject line when you start a new
> thread?
> >
> > On Thu, Jul 25, 2019 at 8:53 AM Geertjan Wielenga <ge...@apache.org>
> > wrote:
> >
> > > More details needed, the context, the why, etc.
> > >
> > > Gj
> > >
> > > On Thu, Jul 25, 2019 at 6:35 AM Peter Cheung <mc...@hotmail.com>
> > > wrote:
> > >
> > > > Dear All
> > > > How to maintain there is only one instance of a topcomponent window
> > > > of a specific class?
> > > > How to close all topcomponent of a specific class?
> > > >
> > > >
> > > > Thanks
> > > > From Peter
> > > >
> > >
>

Re: Newbie questions

Posted by Peter Cheung <mc...@hotmail.com>.
thanks Peter Nabbefeld
________________________________
From: Peter Nabbefeld <pe...@gmx.de>
Sent: Friday, July 26, 2019 3:46 PM
To: dev@netbeans.apache.org <de...@netbeans.apache.org>
Subject: Re: Newbie questions

Then You might be interested in Visual Library tutorials, e.g.
https://platform.netbeans.org/tutorials/nbm-visual_library.html and more
available from https://netbeans.org/kb/trails/platform.html

Regards,
P.


Am 25.07.19 um 18:37 schrieb Peter Cheung:
> Dear Peter
>      I prefer not to use the traditional properties window. What i am doing is to build a 'logic simulator' in netbeans for people to simulate their logic-gates-design. Since the gates' logos are in square, so i want to create my ideal panel layout.
>
>
> Thanks
>  From Peter
> ________________________________
> From: Peter Nabbefeld <pe...@gmx.de>
> Sent: Friday, July 26, 2019 12:25 AM
> To: dev@netbeans.apache.org <de...@netbeans.apache.org>
> Subject: Re: Newbie questions
>
>
> Hello Peter,
>
> the cause for asking for context is just this: dependent on where You
> want a TopComponent to be used, it's usually managed differently. E.g.
> Palette windows etc. are usually used in the context of editing a
> specific file type.
>
> If I understand Your question correctly, You want to use a properties
> window like in the GUI builder? It seems, the properties window is just
> hidden for other files, You can e.g. open it using "Windows -> IDE Tools
> -> Properties".
>
> For property sheet extension, this tutorial might help:
> https://platform.netbeans.org/tutorials/nbm-property-editors.html
>
> Kind regards
> Peter
>
>
>
>
> Am 25.07.19 um 17:15 schrieb Peter Cheung:
>> I am not sure why my reason is so important, but i just want to do these:
>>
>>       How to maintain there is only one instance of a topcomponent window of a specific class?
>>       How to close all topcomponent of a specific class?
>>
>> OK, my reason is:
>>
>> when you open an editor, there is a property window, whatever how many editor you are opened, since there is only one active editor, so there is only one property window. If can't control only one instance of a topcomponent, how can we achieve this.
>>
>> I am not sure why you think it is so important to ask for my reason to solve a specific technical question. If people ask "how to solve my for-loop error", do we really need to know his reason to write his for-loop? Or I am thinking i am being discriminated.
>>
>> If people in here think i am disturbing, i can quit.
>>
>> Thanks
>>   From Peter
>> ________________________________
>> From: Eric Bresie <eb...@gmail.com>
>> Sent: Thursday, July 25, 2019 10:09 PM
>> To: Apache NetBeans <de...@netbeans.apache.org>
>> Subject: Re: Re: Newbie questions
>>
>> http://www.catb.org/~esr/faqs/smart-questions.html
>>
>> Eric Bresie
>> Ebresie@gmail.com
>>> On July 24, 2019 at 11:54:27 PM PDT, Geertjan Wielenga <ge...@apache.org> wrote:
>>> PS: Can you think hard about the subject line when you start a new thread?
>>>
>>> On Thu, Jul 25, 2019 at 8:53 AM Geertjan Wielenga <ge...@apache.org>
>>> wrote:
>>>
>>>> More details needed, the context, the why, etc.
>>>>
>>>> Gj
>>>>
>>>> On Thu, Jul 25, 2019 at 6:35 AM Peter Cheung <mc...@hotmail.com>
>>>> wrote:
>>>>
>>>>> Dear All
>>>>> How to maintain there is only one instance of a topcomponent window
>>>>> of a specific class?
>>>>> How to close all topcomponent of a specific class?
>>>>>
>>>>>
>>>>> Thanks
>>>>>   From Peter
>>>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@netbeans.apache.org
> For additional commands, e-mail: dev-help@netbeans.apache.org
>
> For further information about the NetBeans mailing lists, visit:
> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
>
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@netbeans.apache.org
For additional commands, e-mail: dev-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists




Re: Newbie questions

Posted by Peter Nabbefeld <pe...@gmx.de>.
Then You might be interested in Visual Library tutorials, e.g.
https://platform.netbeans.org/tutorials/nbm-visual_library.html and more
available from https://netbeans.org/kb/trails/platform.html

Regards,
P.


Am 25.07.19 um 18:37 schrieb Peter Cheung:
> Dear Peter
>      I prefer not to use the traditional properties window. What i am doing is to build a 'logic simulator' in netbeans for people to simulate their logic-gates-design. Since the gates' logos are in square, so i want to create my ideal panel layout.
>
>
> Thanks
>  From Peter
> ________________________________
> From: Peter Nabbefeld <pe...@gmx.de>
> Sent: Friday, July 26, 2019 12:25 AM
> To: dev@netbeans.apache.org <de...@netbeans.apache.org>
> Subject: Re: Newbie questions
>
>
> Hello Peter,
>
> the cause for asking for context is just this: dependent on where You
> want a TopComponent to be used, it's usually managed differently. E.g.
> Palette windows etc. are usually used in the context of editing a
> specific file type.
>
> If I understand Your question correctly, You want to use a properties
> window like in the GUI builder? It seems, the properties window is just
> hidden for other files, You can e.g. open it using "Windows -> IDE Tools
> -> Properties".
>
> For property sheet extension, this tutorial might help:
> https://platform.netbeans.org/tutorials/nbm-property-editors.html
>
> Kind regards
> Peter
>
>
>
>
> Am 25.07.19 um 17:15 schrieb Peter Cheung:
>> I am not sure why my reason is so important, but i just want to do these:
>>
>>       How to maintain there is only one instance of a topcomponent window of a specific class?
>>       How to close all topcomponent of a specific class?
>>
>> OK, my reason is:
>>
>> when you open an editor, there is a property window, whatever how many editor you are opened, since there is only one active editor, so there is only one property window. If can't control only one instance of a topcomponent, how can we achieve this.
>>
>> I am not sure why you think it is so important to ask for my reason to solve a specific technical question. If people ask "how to solve my for-loop error", do we really need to know his reason to write his for-loop? Or I am thinking i am being discriminated.
>>
>> If people in here think i am disturbing, i can quit.
>>
>> Thanks
>>   From Peter
>> ________________________________
>> From: Eric Bresie <eb...@gmail.com>
>> Sent: Thursday, July 25, 2019 10:09 PM
>> To: Apache NetBeans <de...@netbeans.apache.org>
>> Subject: Re: Re: Newbie questions
>>
>> http://www.catb.org/~esr/faqs/smart-questions.html
>>
>> Eric Bresie
>> Ebresie@gmail.com
>>> On July 24, 2019 at 11:54:27 PM PDT, Geertjan Wielenga <ge...@apache.org> wrote:
>>> PS: Can you think hard about the subject line when you start a new thread?
>>>
>>> On Thu, Jul 25, 2019 at 8:53 AM Geertjan Wielenga <ge...@apache.org>
>>> wrote:
>>>
>>>> More details needed, the context, the why, etc.
>>>>
>>>> Gj
>>>>
>>>> On Thu, Jul 25, 2019 at 6:35 AM Peter Cheung <mc...@hotmail.com>
>>>> wrote:
>>>>
>>>>> Dear All
>>>>> How to maintain there is only one instance of a topcomponent window
>>>>> of a specific class?
>>>>> How to close all topcomponent of a specific class?
>>>>>
>>>>>
>>>>> Thanks
>>>>>   From Peter
>>>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@netbeans.apache.org
> For additional commands, e-mail: dev-help@netbeans.apache.org
>
> For further information about the NetBeans mailing lists, visit:
> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
>
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@netbeans.apache.org
For additional commands, e-mail: dev-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists




Re: Newbie questions

Posted by Peter Cheung <mc...@hotmail.com>.
Dear Peter
    I prefer not to use the traditional properties window. What i am doing is to build a 'logic simulator' in netbeans for people to simulate their logic-gates-design. Since the gates' logos are in square, so i want to create my ideal panel layout.


Thanks
From Peter
________________________________
From: Peter Nabbefeld <pe...@gmx.de>
Sent: Friday, July 26, 2019 12:25 AM
To: dev@netbeans.apache.org <de...@netbeans.apache.org>
Subject: Re: Newbie questions


Hello Peter,

the cause for asking for context is just this: dependent on where You
want a TopComponent to be used, it's usually managed differently. E.g.
Palette windows etc. are usually used in the context of editing a
specific file type.

If I understand Your question correctly, You want to use a properties
window like in the GUI builder? It seems, the properties window is just
hidden for other files, You can e.g. open it using "Windows -> IDE Tools
-> Properties".

For property sheet extension, this tutorial might help:
https://platform.netbeans.org/tutorials/nbm-property-editors.html

Kind regards
Peter




Am 25.07.19 um 17:15 schrieb Peter Cheung:
> I am not sure why my reason is so important, but i just want to do these:
>
>      How to maintain there is only one instance of a topcomponent window of a specific class?
>      How to close all topcomponent of a specific class?
>
> OK, my reason is:
>
> when you open an editor, there is a property window, whatever how many editor you are opened, since there is only one active editor, so there is only one property window. If can't control only one instance of a topcomponent, how can we achieve this.
>
> I am not sure why you think it is so important to ask for my reason to solve a specific technical question. If people ask "how to solve my for-loop error", do we really need to know his reason to write his for-loop? Or I am thinking i am being discriminated.
>
> If people in here think i am disturbing, i can quit.
>
> Thanks
>  From Peter
> ________________________________
> From: Eric Bresie <eb...@gmail.com>
> Sent: Thursday, July 25, 2019 10:09 PM
> To: Apache NetBeans <de...@netbeans.apache.org>
> Subject: Re: Re: Newbie questions
>
> http://www.catb.org/~esr/faqs/smart-questions.html
>
> Eric Bresie
> Ebresie@gmail.com
>> On July 24, 2019 at 11:54:27 PM PDT, Geertjan Wielenga <ge...@apache.org> wrote:
>> PS: Can you think hard about the subject line when you start a new thread?
>>
>> On Thu, Jul 25, 2019 at 8:53 AM Geertjan Wielenga <ge...@apache.org>
>> wrote:
>>
>>> More details needed, the context, the why, etc.
>>>
>>> Gj
>>>
>>> On Thu, Jul 25, 2019 at 6:35 AM Peter Cheung <mc...@hotmail.com>
>>> wrote:
>>>
>>>> Dear All
>>>> How to maintain there is only one instance of a topcomponent window
>>>> of a specific class?
>>>> How to close all topcomponent of a specific class?
>>>>
>>>>
>>>> Thanks
>>>>  From Peter
>>>>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@netbeans.apache.org
For additional commands, e-mail: dev-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists




Re: Newbie questions

Posted by Peter Nabbefeld <pe...@gmx.de>.
Hello Peter,

the cause for asking for context is just this: dependent on where You
want a TopComponent to be used, it's usually managed differently. E.g.
Palette windows etc. are usually used in the context of editing a
specific file type.

If I understand Your question correctly, You want to use a properties
window like in the GUI builder? It seems, the properties window is just
hidden for other files, You can e.g. open it using "Windows -> IDE Tools
-> Properties".

For property sheet extension, this tutorial might help:
https://platform.netbeans.org/tutorials/nbm-property-editors.html

Kind regards
Peter




Am 25.07.19 um 17:15 schrieb Peter Cheung:
> I am not sure why my reason is so important, but i just want to do these:
>
>      How to maintain there is only one instance of a topcomponent window of a specific class?
>      How to close all topcomponent of a specific class?
>
> OK, my reason is:
>
> when you open an editor, there is a property window, whatever how many editor you are opened, since there is only one active editor, so there is only one property window. If can't control only one instance of a topcomponent, how can we achieve this.
>
> I am not sure why you think it is so important to ask for my reason to solve a specific technical question. If people ask "how to solve my for-loop error", do we really need to know his reason to write his for-loop? Or I am thinking i am being discriminated.
>
> If people in here think i am disturbing, i can quit.
>
> Thanks
>  From Peter
> ________________________________
> From: Eric Bresie <eb...@gmail.com>
> Sent: Thursday, July 25, 2019 10:09 PM
> To: Apache NetBeans <de...@netbeans.apache.org>
> Subject: Re: Re: Newbie questions
>
> http://www.catb.org/~esr/faqs/smart-questions.html
>
> Eric Bresie
> Ebresie@gmail.com
>> On July 24, 2019 at 11:54:27 PM PDT, Geertjan Wielenga <ge...@apache.org> wrote:
>> PS: Can you think hard about the subject line when you start a new thread?
>>
>> On Thu, Jul 25, 2019 at 8:53 AM Geertjan Wielenga <ge...@apache.org>
>> wrote:
>>
>>> More details needed, the context, the why, etc.
>>>
>>> Gj
>>>
>>> On Thu, Jul 25, 2019 at 6:35 AM Peter Cheung <mc...@hotmail.com>
>>> wrote:
>>>
>>>> Dear All
>>>> How to maintain there is only one instance of a topcomponent window
>>>> of a specific class?
>>>> How to close all topcomponent of a specific class?
>>>>
>>>>
>>>> Thanks
>>>>  From Peter
>>>>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@netbeans.apache.org
For additional commands, e-mail: dev-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists




Re: Re: Newbie questions

Posted by Peter Cheung <mc...@hotmail.com>.
I am not sure why my reason is so important, but i just want to do these:

    How to maintain there is only one instance of a topcomponent window of a specific class?
    How to close all topcomponent of a specific class?

OK, my reason is:

when you open an editor, there is a property window, whatever how many editor you are opened, since there is only one active editor, so there is only one property window. If can't control only one instance of a topcomponent, how can we achieve this.

I am not sure why you think it is so important to ask for my reason to solve a specific technical question. If people ask "how to solve my for-loop error", do we really need to know his reason to write his for-loop? Or I am thinking i am being discriminated.

If people in here think i am disturbing, i can quit.

Thanks
From Peter
________________________________
From: Eric Bresie <eb...@gmail.com>
Sent: Thursday, July 25, 2019 10:09 PM
To: Apache NetBeans <de...@netbeans.apache.org>
Subject: Re: Re: Newbie questions

http://www.catb.org/~esr/faqs/smart-questions.html

Eric Bresie
Ebresie@gmail.com
> On July 24, 2019 at 11:54:27 PM PDT, Geertjan Wielenga <ge...@apache.org> wrote:
> PS: Can you think hard about the subject line when you start a new thread?
>
> On Thu, Jul 25, 2019 at 8:53 AM Geertjan Wielenga <ge...@apache.org>
> wrote:
>
> > More details needed, the context, the why, etc.
> >
> > Gj
> >
> > On Thu, Jul 25, 2019 at 6:35 AM Peter Cheung <mc...@hotmail.com>
> > wrote:
> >
> > > Dear All
> > > How to maintain there is only one instance of a topcomponent window
> > > of a specific class?
> > > How to close all topcomponent of a specific class?
> > >
> > >
> > > Thanks
> > > From Peter
> > >
> >

Re: Re: Newbie questions

Posted by Eric Bresie <eb...@gmail.com>.
http://www.catb.org/~esr/faqs/smart-questions.html

Eric Bresie
Ebresie@gmail.com
> On July 24, 2019 at 11:54:27 PM PDT, Geertjan Wielenga <ge...@apache.org> wrote:
> PS: Can you think hard about the subject line when you start a new thread?
>
> On Thu, Jul 25, 2019 at 8:53 AM Geertjan Wielenga <ge...@apache.org>
> wrote:
>
> > More details needed, the context, the why, etc.
> >
> > Gj
> >
> > On Thu, Jul 25, 2019 at 6:35 AM Peter Cheung <mc...@hotmail.com>
> > wrote:
> >
> > > Dear All
> > > How to maintain there is only one instance of a topcomponent window
> > > of a specific class?
> > > How to close all topcomponent of a specific class?
> > >
> > >
> > > Thanks
> > > From Peter
> > >
> >

Re: Newbie questions

Posted by Geertjan Wielenga <ge...@apache.org>.
PS: Can you think hard about the subject line when you start a new thread?

On Thu, Jul 25, 2019 at 8:53 AM Geertjan Wielenga <ge...@apache.org>
wrote:

> More details needed, the context, the why, etc.
>
> Gj
>
> On Thu, Jul 25, 2019 at 6:35 AM Peter Cheung <mc...@hotmail.com>
> wrote:
>
>> Dear All
>>     How to maintain there is only one instance of a topcomponent window
>> of a specific class?
>>     How to close all topcomponent of a specific class?
>>
>>
>> Thanks
>> From Peter
>>
>

Re: Newbie questions

Posted by Geertjan Wielenga <ge...@apache.org>.
More details needed, the context, the why, etc.

Gj

On Thu, Jul 25, 2019 at 6:35 AM Peter Cheung <mc...@hotmail.com> wrote:

> Dear All
>     How to maintain there is only one instance of a topcomponent window of
> a specific class?
>     How to close all topcomponent of a specific class?
>
>
> Thanks
> From Peter
>