-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added button_events module and check_box class
- Loading branch information
Showing
6 changed files
with
101 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
############################################################################### | ||
# This file is part of RSwing. # | ||
# RSwing - Swing wrapper for JRuby # | ||
# (C) 2008 Christopher Bertels (bakkdoor@flasht.de) # | ||
# # | ||
# RSwing is free software: you can redistribute it and/or modify # | ||
# it under the terms of the GNU Lesser General Public License as published by # | ||
# the Free Software Foundation, either version 3 of the License, or # | ||
# (at your option) any later version. # | ||
# # | ||
# RSwing is distributed in the hope that it will be useful, # | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of # | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | ||
# GNU Lesser General Public License for more details. # | ||
# # | ||
# You should have received a copy of the GNU Lesser General Public License # | ||
# along with RSwing. If not, see <http://www.gnu.org/licenses/>. # | ||
############################################################################### | ||
|
||
module RSwing | ||
module Components | ||
JCheckBox = javax.swing.JCheckBox | ||
|
||
# CheckBox-Class. Wraps JCheckBox-Class. | ||
class CheckBox < JCheckBox | ||
include Component | ||
include Events::ButtonEvents | ||
|
||
# - <tt>text</tt>: The Text to be displayed on the checkbox. | ||
# - <tt>options</tt>: Options-Hash with the following valid values: | ||
# 1. <tt>:visible => true</tt> | ||
# 2. <tt>:enabled => true</tt> | ||
# 3. <tt>:selected => true</tt> # (default: false) | ||
# 4. <tt>:layout => nil</tt> # Layout-Options (e.g. GridBagContraints-Object) (default: none) | ||
# 5. <tt>:icon => nil</tt> # Icon-Symbol to be displayed next to/instead of the text on the checkbox (default: none) | ||
# 6. <tt>:name => :check_box</tt> Name of the checkbox for access via parent-container (default: none) | ||
def initialize(text, options = {}, &block) | ||
super(text, Options.value_for(options => :selected)) | ||
|
||
self.visible = Options.value_for(options => :visible) | ||
self.enabled = Options.value_for(options => :enabled) | ||
self.icon = Options.value_for(options => :icon) | ||
|
||
# call block with current object, if given | ||
if block_given? | ||
yield self | ||
end | ||
|
||
unless options.empty? | ||
Container.add_if_requested(self, options) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
############################################################################### | ||
# This file is part of RSwing. # | ||
# RSwing - Swing wrapper for JRuby # | ||
# (C) 2008 Christopher Bertels (bakkdoor@flasht.de) # | ||
# # | ||
# RSwing is free software: you can redistribute it and/or modify # | ||
# it under the terms of the GNU Lesser General Public License as published by # | ||
# the Free Software Foundation, either version 3 of the License, or # | ||
# (at your option) any later version. # | ||
# # | ||
# RSwing is distributed in the hope that it will be useful, # | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of # | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | ||
# GNU Lesser General Public License for more details. # | ||
# # | ||
# You should have received a copy of the GNU Lesser General Public License # | ||
# along with RSwing. If not, see <http://www.gnu.org/licenses/>. # | ||
############################################################################### | ||
|
||
module RSwing | ||
module Components | ||
module Events | ||
module ButtonEvents | ||
ActionListener = java.awt.event.ActionListener | ||
ItemListener = java.awt.event.ItemListener | ||
ChangeListener = javax.swing.event.ChangeListener | ||
|
||
# Eventhandler for clicked (actionPerformed) event. | ||
# Takes a block, which will be executed if this event occurs. | ||
event_for self => :on_click, ActionListener => :actionPerformed | ||
event_for self => :on_item_state_changed, ItemListener => :itemStateChanged | ||
event_for self => :on_state_changed, ChangeListener => :stateChanged | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters