|
Hello Everyone
I'm trying to convert this java code to C#, could someone please help me on this because I am very new into programming.
Here is the Java code...
import java.awt.Component;
import javax.swing.JOptionPane;
public class ConfirmDeleteDialog {
public static final int YES = JOptionPane.YES_OPTION;
public static final int NO = JOptionPane.NO_OPTION;
public static final int CANCEL = JOptionPane.CANCEL_OPTION;
static final int OK = JOptionPane.OK_OPTION;
static final int CLOSED = JOptionPane.CLOSED_OPTION;
public static int showMessage(Component parent, String message, String title) {
return JOptionPane.showConfirmDialog(parent, message, title, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
}
}
thanks in advance
lapeci
|
|
|
|
|
That seems to be a custom message box. Hence in C# (if you are using Windows Forms), you could use MessageBox.Show as a replacement for ConfirmDeleteDialog.showMessage . The return value in C# is a DialogResult .
|
|
|
|
|
Hi Bernhard Hiller
Thanks for replaying to my java question. I'm using WPF Window Form (not the Windows Forms). Is there anyway you could help me to convert that java code I'm very new to programming and I don't have a clue how to do it honestly...
Kind Regards
lapeci
|
|
|
|
|
What are you trying to do?
|
|
|
|
|
If you are new to programming then why are you concerned about trying to convert Java to C# when creating a WPF program? Forget Java and spend some time studying how to do things properly in WPF. There are lots of useful samples in the WPF articles section[^].
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
There is no simple equivalent of this in C# as it refers to Java specific components. It would be better if you started with Windows forms[^] in C# and build your program from scratch.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
It can almost be completely converted to C#:
using System.Windows.Forms;
public class ConfirmDeleteDialog
{
public static readonly int YES = DialogResult.Yes;
public static readonly int NO = DialogResult.No;
public static readonly int CANCEL = DialogResult.Cancel;
internal static readonly int OK = DialogResult.OK;
internal static readonly int CLOSED = JOptionPane.CLOSED_OPTION;
public static int showMessage(Component parent, string message, string title)
{
return MessageBox.Show(parent, message, title, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
}
}
Dave Doknjas
Convert between VB, C#, C++, & Java
www.tangiblesoftwaresolutions.com
Instant C# - VB to C# Converter
Instant VB - C# to VB Converter
|
|
|
|