LoginSignup
2
4

More than 5 years have passed since last update.

Processing3製のアプリでMacのメニューバーを使う

Last updated at Posted at 2017-06-18

Macのデスクトップ上部にあるメニューバーを、
Processing3で作成したアプリケーションで使ってみましょう。

menubar.png

注意

  • 動作環境 : processing3.3
  • デスクトップ上部のメニューバーは、アプリとしてエクスポート後のみ使用可能

内容

メニューバーを作るには、JavaのSwingにあるJMenuBarを使用します。

sample.pde
import java.awt.*;
import javax.swing.*;

JLayeredPane pane = new JLayeredPane();
JMenuBar  menubar = new JMenuBar();

void setup() {
  System.setProperty("apple.laf.useScreenMenuBar", "true");

  Canvas canvas = (Canvas) surface.getNative();
  pane = (JLayeredPane) canvas.getParent().getParent();

  JMenu     menu = new JMenu("menu");
  JMenuItem item = new JMenuItem("item");
  menu.add(item);
  menubar.add(menu);
  pane.add(menubar);
}

  
System.setProperty("apple.laf.useScreenMenuBar", "true");
これによって、Macのメニューバーを使用するようになります。

こんな感じになれば成功です。

スクリーンショット 2017-06-18 22.40.12.png

参考

processing3でAWT/swingを使う。

2
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
4