This discussion is archived
2 Replies Latest reply: Jan 5, 2008 1:36 AM by 843804 RSS

VB.NET and JPanel problem

843804 Newbie
Currently Being Moderated

I'm curently evaluating the possibility of incorporating Java components in my company's WINDOWS products. I am working with Visual Basic in Visual Studio 2005 for the Windows part, with JDK1.5.0_07 for the java part. I developed a simple Bean:

public class MyPanel extends JPanel {
     public MyPanel() {
          setLayout(new BorderLayout(5,5));
          add(new JLabel("Test"), BorderLayout.CENTER);

I try to place this bean in a VB form. The VB "form designer" generates the following line of code:

Me.AxExpressionEditorPanel1.location = New System.Drawing.Point(12, 98)

That line generates (at compile time) the error message:

error BC30068: Expression is a value and therefore cannot be the target of an assignment.

Does anybody have an idea what I could do? The same problem arises with the size property of the bean.

Thank you,
  • 1. Re: VB.NET and JPanel problem
    800556 Newbie
    Currently Being Moderated
    See example in the package:[id]95126[SiteID]
  • 2. Re: VB.NET and JPanel problem
    843804 Newbie
    Currently Being Moderated

    I think the problem is that size() and location() are functions in one of JPanel's interfaces (although they have been deprecated). I managed to work around the problem:

    1. Double-click the error message to bring up the form designer.

    2. Remove or comment out the two lines that caused the errors:

    Me.AxExpressionEditorPanel1.size = New System.Drawing.Point(256, 128)
    Me.AxExpressionEditorPanel1.location = New System.Drawing.Point(12, 98)

    3. Insert the following code to set the size and location:

    Me.AxExpressionEditorPanel1.Width = 256
    Me.AxExpressionEditorPanel1.Height = 128
    Me.AxExpressionEditorPanel1.Top = 98
    Me.AxExpressionEditorPanel1.Left = 12

    These code modifications will stay (and can be compiled and run) as long as no changes are made to the form's GUI, which triggers VB to auto-generate the default code, which has to be manually replaced again.

    Also, this can be done only in the form designer in Visual Basic 2005. Editing the file itself outside the IDE will make the file invalid.

    This was tested on JDK1.6.0_03 and Visual Basic 2005 Express.