Java
view release on metacpan or search on metacpan
examples/swing/browser/menu_bar.pl view on Meta::CPAN
foreach (@_)
{
$menu_bar->add($_);
}
# Add menu bar to our frame
return $menu_bar;
# $frame->setJMenuBar($menu_bar);
}
# Going for popup menu
# Create Popup menu
# my $popup = $java->create_object("$swing.JPopupMenu");
# Add some stuff to it...
# $popup->add(&menu_item("Open...",\&menu_handler,"open",0,0));
# $popup->addSeparator;
# Like a sub-menu...
# my $colors = $java->create_object("$swing.JMenu","Colors");
# $popup->add($colors);
# Set up some radio items in the sub-menu of the popup menu
# my $color_group = $java->create_object("$swing.ButtonGroup");
# $colors->add(&radio_item("Red",\&menu_handler,"color(red)",$color_group));
# $colors->add(&radio_item("Green",\&menu_handler,"color(green)",$color_group));
# $colors->add(&radio_item("Blue",\&menu_handler,"color(blue)",$color_group));
#
#// Now have it show up when user clicks in the window...
# So when I get an event that I want I'll show 'em the popup window
# $java->do_event($panel,"addMouseListener",\&mouse_handler);
# Get the main frame rockin'!
# $frame->setSize(450,300);
# $frame->setVisible("true:b");
# $frame->show;
# This is my exciting event loop!
# my $cont = 1;
# while($cont)
examples/swing/browser/menu_bar.pl view on Meta::CPAN
my $id = $event->getID->get_value;
#// A MousePressed Event...
if ($mp == $id)
{
# This works on every other platform but Windows! Ridickerous.
# 'get_value' for boolean values returns the string
# "true" or "false"
if ($event->isPopupTrigger->get_value eq "true")
{
# Show our popup window at X,Y coordinates of mouse
# Note use of 'get_value' to get the actual
# integer position of mouse!
$popup->show($object,$event->getX->get_value,$event->getY->get_value);
}
}
}
examples/swing/menu.pl view on Meta::CPAN
my $edit_menu = $java->create_object("$swing.JMenu","Edit");
$edit_menu->setMnemonic("E:char");
# Cut
$edit_menu->add(&menu_item("Cut",\&menu_handler,"cut",0,$java->get_field("java.awt.event.KeyEvent","VK_X")));
# Copy
$edit_menu->add(&menu_item("Copy",\&menu_handler,"copy",'C',$java->get_field("java.awt.event.KeyEvent","VK_C")));
# Paste
$edit_menu->add(&menu_item("Paste",\&menu_handler,"paste",0,$java->get_field("java.awt.event.KeyEvent","VK_V")));
# A dummy menu to let user know they can click in window to get popup menu
my $t_menu = $java->create_object("$swing.JMenu","Click in window for popup menu!");
# Menu bar
my $menu_bar = $java->create_object("$swing.JMenuBar");
$menu_bar->add($file_menu);
$menu_bar->add($edit_menu);
$menu_bar->add($t_menu);
# Add menu bar to our frame
$frame->setJMenuBar($menu_bar);
# Going for popup menu
# Create Popup menu
my $popup = $java->create_object("$swing.JPopupMenu");
# Add some stuff to it...
$popup->add(&menu_item("Open...",\&menu_handler,"open",0,0));
$popup->addSeparator;
# Like a sub-menu...
my $colors = $java->create_object("$swing.JMenu","Colors");
$popup->add($colors);
# Set up some radio items in the sub-menu of the popup menu
my $color_group = $java->create_object("$swing.ButtonGroup");
$colors->add(&radio_item("Red",\&menu_handler,"color(red)",$color_group));
$colors->add(&radio_item("Green",\&menu_handler,"color(green)",$color_group));
$colors->add(&radio_item("Blue",\&menu_handler,"color(blue)",$color_group));
#// Now have it show up when user clicks in the window...
# So when I get an event that I want I'll show 'em the popup window
$java->do_event($panel,"addMouseListener",\&mouse_handler);
# Get the main frame rockin'!
$frame->setSize(450,300);
$frame->setVisible("true:b");
$frame->show;
# This is my exciting event loop!
my $cont = 1;
while($cont)
examples/swing/menu.pl view on Meta::CPAN
my $id = $event->getID->get_value;
#// A MousePressed Event...
if ($mp == $id)
{
# This works on every other platform but Windows! Ridickerous.
# 'get_value' for boolean values returns the string
# "true" or "false"
if ($event->isPopupTrigger->get_value eq "true")
{
# Show our popup window at X,Y coordinates of mouse
# Note use of 'get_value' to get the actual
# integer position of mouse!
$popup->show($object,$event->getX->get_value,$event->getY->get_value);
}
}
}
( run in 1.260 second using v1.01-cache-2.11-cpan-364913b4093 )