美文网首页
Java和DirectUI之间的太极 —— 用Java代码启动原

Java和DirectUI之间的太极 —— 用Java代码启动原

作者: 天下第九九八十一 | 来源:发表于2023-03-03 14:50 被阅读0次

    Java代码,IDEA里面编写效率高。界面呢,还是原生界面,DirectUI方案简单一些 —— 没有巨量内存占用,没有厚重历史包袱。

    于是就有Java结合DirectUI的需求。很明显,这又是个网上没人讨论的话题。

    Java 和 DirectUI 就是逻辑和现实的两极,是轻和重的辩证,而我在中,运筹,施法,从无极虚空之中抽取出神兵利器,运转无限太极。

    第一式,查看log

    Java支持将输出流重定向至文件。而IDEA支持加载外部log文件。问题解决。

    需要在编辑器里随便运行一个例程,在“运行配置”,某隐藏区域,可以加载外部文件。例程运行后,就开始读取日志了,和普通log一样显示。

    不过,加载的log文件处于第二个标签页位置,需要手动激活。可以用AHK自动化。

    无毒有偶,[IDEA用户社区也有人提问:为什么不能在程序运行后,自动激活想要的输出窗口?

    悬年未决,待我出手:

    gist -- FIX IDEA -- "Focus on Start-up" option doesn't work

    First, I don't press the little "play" button on the toolbar to run my code. instead I use AHK to trigger the "Run" keystroke when I righ-click on the left-edge of my screen.

    Then, to active the desired log tab. keep the "focus on startup" checked on all log tabs. this will bring the focus to the log window on startup, not to the desired log tab.

    Finally, tell AHK to press the keystroke "select next tab", in my case "alt+right", immediately before the test runs, through the "before launch" configuration, or through the java ProcessBuilder api.

    • gist.github.com/KnIfER/2554aebdbe1fd8f36194baa29c445fcb

    第二式,无限调用

    • zhihu.com/question/53576680/answer/2920970878

    见上视频。

    相关文章

      网友评论

          本文标题:Java和DirectUI之间的太极 —— 用Java代码启动原

          本文链接:https://www.haomeiwen.com/subject/tngjldtx.html