RosettaCodeData/Task/Hello-world-Graphical/NetRexx/hello-world-graphical-3.netrexx
2023-07-01 13:44:08 -04:00

88 lines
2.1 KiB
Text

/* NetRexx */
options replace format comments java crossref symbols binary
class RCHelloWorld_GraphicalAWT_01 extends Dialog implements ActionListener
properties private constant
msgText = 'Goodbye, World!'
properties indirect
ok = boolean
can = boolean
okButton = Button
canButton = Button
buttonPanel = Panel
method RCHelloWorld_GraphicalAWT_01(frame = Frame, msg = String, canaction = boolean) public
super(frame, 'Default', isTrue)
setLayout(BorderLayout())
add(BorderLayout.CENTER, Label(msg))
addOKCancelPanel(canaction)
createFrame()
pack()
setVisible(isTrue)
return
method RCHelloWorld_GraphicalAWT_01(frame = Frame, msg = String) public
this(frame, msg, isFalse)
return
method addOKCancelPanel(canaction = boolean)
setButtonPanel(Panel())
getButtonPanel.setLayout(FlowLayout())
createOKButton()
if canaction then do
createCancelButton()
end
add(BorderLayout.SOUTH, getButtonPanel)
return
method createOKButton()
setOkButton(Button('OK'))
getButtonPanel.add(getOkButton)
getOkButton.addActionListener(this)
return
method createCancelButton()
setCanButton(Button('Cancel'))
getButtonPanel.add(getCanButton)
getCanButton.addActionListener(this)
return
method createFrame()
dim = getToolkit().getScreenSize
setLocation(int(dim.width / 3), int(dim.height / 3))
return
method actionPerformed(ae = ActionEvent) public
if ae.getSource == getOkButton then do
setOk(isTrue)
setCan(isFalse)
setVisible(isFalse)
end
else if ae.getSource == getCanButton then do
setCan(isTrue)
setOk(isFalse)
setVisible(isFalse)
end
return
method main(args = String[]) public constant
mainFrame = Frame()
mainFrame.setSize(200, 200)
mainFrame.setVisible(isTrue)
message = RCHelloWorld_GraphicalAWT_01(mainFrame, msgText, isTrue)
if message.isOk then
say 'OK pressed'
if message.isCan then
say 'Cancel pressed'
message.dispose
mainFrame.dispose
return
method isTrue() public static returns boolean
return 1 == 1
method isFalse() public static returns boolean
return \isTrue