ikvm icon indicating copy to clipboard operation
ikvm copied to clipboard

AWT

Open GeorgeS2019 opened this issue 3 years ago • 16 comments

Not relevant

GeorgeS2019 avatar Sep 10 '22 13:09 GeorgeS2019

AWT is presently unsupported.

wasabii avatar Sep 10 '22 13:09 wasabii

        public override java.awt.Graphics2D createGraphics()
        {
            //Graphics g = Graphics.FromImage(bitmap);
            // HACK for off-screen images we don't want ClearType or anti-aliasing
            // TODO I'm sure Java 2D has a way to control text rendering quality, we should honor that
            //g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
            return new BitmapGraphics(bitmap, this, getFont(), J2C.ConvertColor(getForeground()), J2C.ConvertColor(getBackground()));
        }

https://github.com/ikvm-revived/ikvm/blob/733723d5ab05fc3209d7a58ea27eb5106714de5f/src/IKVM.AWT.WinForms/images.cs#L122

GeorgeS2019 avatar Sep 10 '22 13:09 GeorgeS2019

It's not supported on Windows either.

wasabii avatar Sep 10 '22 13:09 wasabii

AWT is a windowing toolkit. I can't quite figure out what you're suggesting.

wasabii avatar Sep 10 '22 16:09 wasabii

Headless mode might work.

wasabii avatar Sep 10 '22 16:09 wasabii

Will leave this issue around to discuss eventual AWT support.

Ideas:

First off, I think abandoning the existing WinForms support is probably the right thing to do, at least for now. It needs a serious reassessment for Core anyways.

I think a better initial strategy would be to port the actual OpenJDK AWT toolkits to IKVM. They consist currently of mostly native callouts to existing Windowing libraries: Win32, GTK, etc. I think it would be fine to consider compiling the actual C of this, and having it distributed in some separate OS specific packages. IKVM.Java.AWT.Windows, IKVM.Java.AWT.GTK, or something.

Given how well JNI works, this shouldn't actually be much of a problem. We get to make the thing work while not having to write much code of our own.

If somebody wants to, they can implement a managed AWT toolkit.

wasabii avatar Sep 12 '22 05:09 wasabii

I don't know what that error is in reference to. You're going to have to be more specific.

wasabii avatar Sep 15 '22 01:09 wasabii

AWT is not supported.......

wasabii avatar Sep 15 '22 01:09 wasabii

IKVM.AWT.WinForms, which is the AWT toolkit implemented on top of WinForms. It was never a very well-completed project, and ended up pretty broken on Core. Not to mention completely non-cross platform.

wasabii avatar Sep 16 '22 16:09 wasabii

I don't understand the question. Do what? This thread is about AWT, but none of your questions seem to have to do with AWT.

If somebody wants to fix IKVM.AWT.WinForms, they can. It's not on my list of things to work on.

If somebody wants to get the Sun/Oracle native AWT toolkits compiling, they can. But also, not really a focus of mine.

wasabii avatar Sep 16 '22 16:09 wasabii

@wasabii

Thank you, the ported .NET Core IKVM has performed better than my previous experience with .NET Framework when dealing with computing complex images.

GeorgeS2019 avatar Sep 16 '22 19:09 GeorgeS2019

WIP

Instead of creating Panel and Form, work on mapping java.awt.* { image, font, graphics } to .Net core version ikvm.awt { image, font, graphics }

  • [ ] ikvm.awt.NetToolkit

    public sealed class NetToolkit : sun.awt.SunToolkit, ikvm.awt.IkvmToolkit, sun.awt.KeyboardFocusManagerPeerProvider

  • [ ] ikvm.awt.NetGraphicsConfiguration

  • [ ] ikvm.awt.NetGraphicsEnvironment

  • [ ] ikvm.awt.NetGraphics //java.awt.Graphics2D//sun.java2d.SunGraphics2D

GeorgeS2019 avatar Sep 25 '22 22:09 GeorgeS2019

There are from the Nuget (.NETFramework) distributed by https://github.com/windward-studios/ikvm8

image

image

image

GeorgeS2019 avatar Sep 27 '22 20:09 GeorgeS2019

@NightOwl888 @wasabii Why in ikvm-revived these are not included in Ikvm.Runtime.JNI?

  • ikvm-native-win32-x64
  • ikvm-native-win32-x86

Could we have a Window platform version of Ikvm-revived to slowly figure out why IKVM.AWT.WINFORM is not working?

Ikvm WINWARD

image

ikvm-revived

image

GeorgeS2019 avatar Sep 27 '22 20:09 GeorgeS2019

@jfrijters

Not sure if you are still around, if so, do you think it is feasible to make IKVM.AWT.WinForm to work ONLY for Windows under .NET Core?

GeorgeS2019 avatar Sep 27 '22 20:09 GeorgeS2019

@NightOwl888 Can someone show me how to run and test in headless way for IKVM.AWT.WinForm?

GeorgeS2019 avatar Sep 27 '22 20:09 GeorgeS2019

.NET6-Window version

of IKVM.AWT.WinForm image

GeorgeS2019 avatar Sep 27 '22 20:09 GeorgeS2019

You should probably not bother Jeroen. He is unlikely to answer.

Why in ikvm-revived these are not included in Ikvm.Runtime.JNI?

The native libraries encompassed two parts originally: the JNIEnv bridge, and a number of one-off functions used in various parts of IKVM (mmap, few other minor things). The mmap stuff was removed (by me). All that remains is the JNIEnv bridge. And that continues to live in the ikvm-native library.

wasabii avatar Sep 27 '22 21:09 wasabii

Can someone show me how to run and test in headless way for IKVM.AWT.WinForm?

What tests? What are you talking about?

wasabii avatar Sep 27 '22 21:09 wasabii

@wasabii

What u mean by this? Thanks image

GeorgeS2019 avatar Sep 27 '22 21:09 GeorgeS2019

Yes, but what tests?

wasabii avatar Sep 27 '22 21:09 wasabii

Java has a headless mode. Look it up.

wasabii avatar Sep 27 '22 21:09 wasabii

Will leave this issue around to discuss eventual AWT support.

wasabii avatar Apr 22 '23 17:04 wasabii

Please do not close this issue, as it represents actual future work that should be accomplished.

wasabii avatar Apr 22 '23 17:04 wasabii

This will be done in a couple of weeks https://github.com/ikvmnet/ikvm/issues/381#issuecomment-2065922797

Other reference

https://github.com/DjArt/IKVM.AWT.WinForms/issues/1

GeorgeS2019 avatar Apr 19 '24 07:04 GeorgeS2019

https://github.com/ikvmnet/ikvm/pull/528

GeorgeS2019 avatar May 24 '24 03:05 GeorgeS2019

@lytico @DjArt I downloaded the nuget from the awt action artifact. Then I simply run this code

Next release with AWT

  • 8u152-b08 (GA), October 17th 2017
  • 8u192-b08 (GA), October 16th 2018
  • 8u275-b01 (GA), November 5th 2020 <= targeting
  • 8u302-b08 (GA), July 20th 2021

image

https://wiki.openjdk.org/display/jdk8u

GeorgeS2019 avatar May 26 '24 01:05 GeorgeS2019

AWT support merged into develop branch.

wasabii avatar May 26 '24 14:05 wasabii

@wasabii

Using the latest 8.9.0-pre.1 https://www.nuget.org/packages/IKVM/8.9.0-pre.1 Strange font remain.

using System.Diagnostics;

using java.awt;

namespace IKVM.ConsoleApp
{

    public static class Program
    {
        public static void Main(string[] args)
        {
            while (!Debugger.IsAttached)
                System.Threading.Thread.Sleep(100);

            AWTExample1.Foo();

            [email protected]("hi");
            System.Console.ReadLine();
        }

        public class AWTExample1 : Frame
        {

            AWTExample1()
            {
                var t = new TextField("THIS IS TEXT");
                t.setBounds(30, 30, 80, 30);
                add(t);

                var b = new Button("1234");
                b.setLabel("1234");
                b.setBounds(30, 100, 80, 30);
                add(b);

                var b2 = new Button("1234");
                b2.setLabel("1234");
                b2.setBounds(30, 200, 80, 30);
                add(b2);

                setSize(300, 300);
                setTitle("This is our basic AWT example");
                setLayout(null);
                setVisible(true);
            }

            public static void Foo()
            {
                new AWTExample1();
            }

        }

    }

}

GeorgeS2019 avatar Jul 07 '24 22:07 GeorgeS2019