Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

JPanel equivalent in C#

810 views
Skip to first unread message

Doug Mika

unread,
Sep 4, 2015, 3:18:15 PM9/4/15
to
Hi

I have a beginner question. I want to write a card game and I need to know in which "component" I could display my cards so that this component can register clicks (on the card) and "move" the card from one place to another. In java I used JPanel to do this. What would the C# equivalent be?

Thanks

Arne Vajhøj

unread,
Sep 4, 2015, 8:23:19 PM9/4/15
to
System.Windows.Forms.Panel or one of its subclasses
would be my first guess.

Assuming Win Forms and not WPF.

Arne

Doug Mika

unread,
Sep 8, 2015, 10:17:37 AM9/8/15
to
And if I'm using WPF?

Arne Vajhøj

unread,
Sep 8, 2015, 1:49:11 PM9/8/15
to
> And if I'm using WPF?

Maybe System.Windows.Controls.Panel, but I have never worked with WPF.

Arne


mick

unread,
Sep 8, 2015, 2:35:46 PM9/8/15
to
You will get component Click events from all WPF Panel types. I have no
clue what a Jpanel does so it's difficult to suggest the equivalent. The
Grid is general purpose enough and should do what you want though. Try that.

mick


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

Arne Vajhøj

unread,
Sep 8, 2015, 7:53:40 PM9/8/15
to
On 9/8/2015 2:35 PM, mick wrote:
> On 08/09/2015 15:17, Doug Mika wrote:
>> On Friday, September 4, 2015 at 7:23:19 PM UTC-5, Arne Vajhøj wrote:
>>> On 9/4/2015 3:18 PM, Doug Mika wrote:
>>>> I have a beginner question. I want to write a card game and I need
>>>> to know in which "component" I could display my cards so that this
>>>> component can register clicks (on the card) and "move" the card from
>>>> one place to another. In java I used JPanel to do this. What would
>>>> the C# equivalent be?
>>>
>>> System.Windows.Forms.Panel or one of its subclasses
>>> would be my first guess.
>>>
>>> Assuming Win Forms and not WPF.
>>
>> And if I'm using WPF?
>
> You will get component Click events from all WPF Panel types. I have no
> clue what a Jpanel does so it's difficult to suggest the equivalent. The
> Grid is general purpose enough and should do what you want though. Try
> that.

A JPanel is just a simple container component that you can add
other components to. Behavior is managed by adding a layout manager
to the JPanel - so one add BorderLayout, FlowLayout or GridLayout or
something else depending on what one want (if you don't know Swing
then you don't know those, but the names indicate what they do).

Arne


0 new messages