September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -1,15 +1,16 @@
|
|||
#import system.
|
||||
#import forms.
|
||||
#import extensions.
|
||||
import forms.
|
||||
import extensions.
|
||||
|
||||
#class Window
|
||||
class Window
|
||||
{
|
||||
#field form.
|
||||
#field lblClicks.
|
||||
#field btmClickMe.
|
||||
#field clicksCount.
|
||||
object form.
|
||||
object lblClicks.
|
||||
object btmClickMe.
|
||||
|
||||
#constructor new
|
||||
//Store how much clicks the user doed
|
||||
object clicksCount.
|
||||
|
||||
constructor new
|
||||
[
|
||||
form := SDIDialog new.
|
||||
lblClicks := Label new.
|
||||
|
|
@ -17,30 +18,32 @@
|
|||
|
||||
clicksCount := 0.
|
||||
|
||||
form controls append:lblClicks.
|
||||
form controls append:btmClickMe.
|
||||
form controls;
|
||||
append:lblClicks;
|
||||
append:btmClickMe.
|
||||
|
||||
form set &caption:"Rosseta Code".
|
||||
form set &x:100 &y:100.
|
||||
form set &width:160 &height:80.
|
||||
form
|
||||
set caption:"Rosseta Code";
|
||||
set x:100 y:100;
|
||||
set width:160 height:80.
|
||||
|
||||
lblClicks set &x:10 &y:2.
|
||||
lblClicks set &width:160 &height:20.
|
||||
lblClicks set &caption:"Clicks: 0".
|
||||
lblClicks
|
||||
set x:10 y:2;
|
||||
set width:160 height:20;
|
||||
set caption:"Clicks: 0".
|
||||
|
||||
btmClickMe set &x:7 &y:20.
|
||||
btmClickMe set &width:140 &height:30.
|
||||
btmClickMe set &caption:"Click me".
|
||||
btmClickMe set &onClick:args
|
||||
|
||||
[ $self $onButtonClick. ].
|
||||
btmClickMe
|
||||
set x:7 y:20;
|
||||
set width:140 height:30;
|
||||
set caption:"Click me";
|
||||
set onClick(:args)[ $self $onButtonClick ]
|
||||
]
|
||||
|
||||
#method $onButtonClick
|
||||
$onButtonClick
|
||||
[
|
||||
clicksCount := clicksCount + 1.
|
||||
lblClicks set &caption:("Clicks: " + clicksCount literal).
|
||||
lblClicks set caption("Clicks: " + clicksCount literal).
|
||||
]
|
||||
|
||||
#method => form.
|
||||
dispatch => form.
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
iCount As Integer 'Counter of clicks!
|
||||
hLabel As Label 'We need a Label
|
||||
|
||||
Public Sub Form_Open()
|
||||
Dim hButton As Button 'We need a Button
|
||||
|
||||
With Me 'Set the Form's Properties..
|
||||
.height = 75 'Set the Height
|
||||
.Width = 300 'Set the Width
|
||||
.Arrangement = Arrange.Vertical 'Arrange items vertically
|
||||
.Padding = 5 'Border area
|
||||
.Title = "Click counter!" 'Title displayed on the Form
|
||||
End With
|
||||
|
||||
hlabel = New Label(Me) 'Add a Label to the form
|
||||
|
||||
With hlabel 'Set the Label's Properties..
|
||||
.expand = True 'Expand the Label to fit the Form
|
||||
.Text = "There have been no clicks yet" 'Add Text to the Label
|
||||
.Alignment = Align.Center 'Center the Text
|
||||
End With
|
||||
|
||||
hButton = New Button(Me) As "Button1" 'Add a Button to the form as Event "Button1"
|
||||
|
||||
With hButton 'Set the Button's Properties..
|
||||
.Height = 28 'Set the Height
|
||||
.Text = "&Click me" 'Add Text (The '&' adds a keyboard shortcut)
|
||||
End With
|
||||
|
||||
End
|
||||
|
||||
Public Sub Button1_Click() 'When the Button is clicked..
|
||||
|
||||
Inc iCount 'Increase the value of iCount
|
||||
hLabel.text = "The button has been clicked " & iCount & " times" 'Display the amount of clicks"
|
||||
|
||||
End
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
#javaj#
|
||||
|
||||
<frames> main, Simple click counter
|
||||
|
||||
<layout of main>
|
||||
PANEL, X
|
||||
bClick me, lClicks
|
||||
|
||||
#data#
|
||||
|
||||
<NN> 0
|
||||
<lClicks> //There have been no clicks yet
|
||||
|
||||
#listix#
|
||||
|
||||
<-- bClick me>
|
||||
NUM=, NN, NN+1
|
||||
-->, lClicks data!,, //@<NN> clicks so far
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
// version 1.0.6
|
||||
|
||||
import java.awt.BorderLayout
|
||||
import java.awt.event.ActionEvent
|
||||
import java.awt.event.ActionListener
|
||||
import javax.swing.*
|
||||
|
||||
class Clicks : JFrame(), ActionListener {
|
||||
private var clicks = 0
|
||||
private val label: JLabel
|
||||
private val clicker: JButton
|
||||
private var text: String
|
||||
|
||||
init {
|
||||
text = "There have been no clicks yet"
|
||||
label = JLabel(text)
|
||||
clicker = JButton("click me")
|
||||
clicker.addActionListener(this) // listen to the button
|
||||
layout = BorderLayout() // handles placement of components
|
||||
add(label, BorderLayout.CENTER) // add the label to the biggest section
|
||||
add(clicker, BorderLayout.SOUTH) // put the button underneath it
|
||||
setSize(300, 200) // stretch out the window
|
||||
defaultCloseOperation = EXIT_ON_CLOSE // stop the program on "X"
|
||||
isVisible = true // show it
|
||||
}
|
||||
|
||||
override fun actionPerformed(arg0: ActionEvent) {
|
||||
if (arg0.source == clicker) { // if they clicked the button
|
||||
if (clicks == 0) text = "There has been " + (++clicks) + " click"
|
||||
else text = "There have been " + (++clicks) + " clicks"
|
||||
label.text = text // change the text
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
Clicks() // call the constructor where all the magic happens
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
1) the label: {div {@ id="label"} There have been no clicks yet }
|
||||
2) the button: {input {@ type="button" value="click me" onclick="CLICKAPP.inc()" }}
|
||||
3) the script: {script °° code °°} where code is a single function:
|
||||
|
||||
var CLICKAPP = (function() {
|
||||
var counter = 0;
|
||||
var inc = function() {
|
||||
counter++;
|
||||
getId('label').innerHTML =
|
||||
'There are ' + counter + ' clicks now';
|
||||
};
|
||||
return {inc:inc}
|
||||
})();
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
/* REXX ***************************************************************************************
|
||||
* 18.06.2014 Walter Pachl shortened from Rony Flatscher's bsf4oorexx (see sourceforge) samples
|
||||
* Look there for ShowCount.rxj
|
||||
* bsf4oorexx lets the ooRexx program use Java classes
|
||||
**********************************************************************************************/
|
||||
userData=.directory~new -- a directory which will be passed to Rexx with the event
|
||||
|
||||
-- create a framed Java window, set a title text
|
||||
win=.bsf~new("java.awt.Frame", "Show Count")
|
||||
-- Create a Java RexxProxy for controlling the closing of the application
|
||||
rexxCloseEH =.RexxCloseAppEventHandler~new -- Rexx event handler
|
||||
-- Create Java RexxProxy for the Rexx event handler
|
||||
rpCloseEH=BsfCreateRexxProxy(rexxCloseEH,,"java.awt.event.WindowListener" )
|
||||
win~addWindowListener(rpCloseEH) -- add RexxProxy event handler
|
||||
|
||||
-- create a Java push button
|
||||
but=.bsf~new("java.awt.Button","Press me!")
|
||||
-- Create a RexxProxy for the button Rexx event handler
|
||||
rp=BsfCreateRexxProxy(.RexxShowCountEventHandler~new,userData,"java.awt.event.ActionListener")
|
||||
but~addActionListener(rp) -- add RexxProxy event handler
|
||||
|
||||
lab=.bsf~new("java.awt.Label") -- create a Java label,set it to show the text centered
|
||||
userData~label=lab -- save label object for later use in event handler
|
||||
lab~setAlignment(lab~center) -- set alignment to center
|
||||
lab~setText("Button was not yet pressed") -- assign initial text to the label
|
||||
|
||||
win ~~add("Center",lab) ~~add("South",but) -- add the label and the button to the frame
|
||||
win ~~pack -- now calculate all widget dimensions
|
||||
call enlargeWidth win,but,120 -- enlarge the width of the frame and the button
|
||||
|
||||
win ~~setVisible(.true) ~~toFront -- make frame visible and move it to the front
|
||||
|
||||
userData~i=0 -- set counter to 0
|
||||
|
||||
rexxCloseEH~waitForExit -- wait until we are allowed to end the program
|
||||
|
||||
-- if Java was loaded by Rexx,then terminate Java's RexxEngine to inhibit callbacks from Java
|
||||
call BSF.terminateRexxEngine
|
||||
|
||||
::requires BSF.CLS -- get Java support
|
||||
|
||||
/* enlarge the width of the frame and of the button without using a layout manager */
|
||||
::routine enlargeWidth
|
||||
use arg win,but,addToWidth
|
||||
winDim=win~getSize -- get frame's dimension
|
||||
winDim~width+=addToWidth -- increase width
|
||||
win~setSize(winDim) -- set frame's dimension
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* Rexx event handler to set "close app" indicator */
|
||||
::class RexxCloseAppEventHandler
|
||||
::method init -- constructor
|
||||
expose closeApp
|
||||
closeApp = .false -- if set to .true, then it is safe to close the app
|
||||
|
||||
::attribute closeApp -- indicates whether app should be closed
|
||||
|
||||
::method unknown -- intercept unhandled events,do nothing
|
||||
|
||||
::method windowClosing -- event method (from WindowListener)
|
||||
expose closeApp
|
||||
closeApp=.true -- indicate that the app should close
|
||||
|
||||
::method waitForExit -- method blocks until attribute is set to .true
|
||||
expose closeApp
|
||||
guard on when closeApp=.true
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* Rexx event handler to process tab changes */
|
||||
::class RexxShowCountEventHandler
|
||||
::method actionPerformed
|
||||
use arg eventObject,slotDir
|
||||
call showCount slotDir~userData
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
::routine ShowCount -- increment counter and show text
|
||||
use arg userData
|
||||
userData~i+=1 -- increment counter in directory object
|
||||
Select -- construct text part
|
||||
When userData~i=1 Then how_often='once'
|
||||
When userData~i=2 Then how_often='twice'
|
||||
When userData~i=3 Then how_often='three times'
|
||||
Otherwise how_often=userData~i 'times'
|
||||
End
|
||||
userData~label~setText("Button was pressed" how_often) -- display text
|
||||
Loading…
Add table
Add a link
Reference in a new issue