0 Replies - 1473 Views - Last Post: 06 March 2010 - 07:05 PM

#1 Raynes   User is offline

  • D.I.C Lover
  • member icon

Reputation: 615
  • View blog
  • Posts: 2,815
  • Joined: 05-January 09

An example of using the Swing GUI library in Ioke

Posted 06 March 2010 - 07:05 PM

Description: This is a simple Ioke script. You can just install Ioke P from the Ioke website, save this file into a file with a .ik extension, and run it by doing 'ioke .ik' on the command-line.It creates a simple Swing window with a text field and a button. You enter text, press the button, and a window will pop up greeting you by the name you entered into the text field.
  :javax:swing, :JFrame, :JButton, 
  :JLabel, :JOptionPane, :JPanel, 
import java:awt:event:ActionListener
import java:awt:BorderLayout

message = method(
  "Gets the message to display text based
  on the current text in textfield.",textfield,
  "Hello, " + textfield getText + "!"

nameField = JTextField new("World", 10)

button = JButton new("Press me!") do(
  addActionListener(fn(e, JOptionPane showMessageDialog(nil, message(nameField))))
  addActionListener(fn(e, "button pressed" println)))

panel = JPanel new do(
  add(JLabel new("Name: "))

frame = JFrame new("My frame.") do(
  add(panel, BorderLayout field:CENTER)
  add(button, BorderLayout field:SOUTH)
  setDefaultCloseOperation(JFrame field:EXIT_ON_CLOSE)
  visible = true

Is This A Good Question/Topic? 0
  • +

Page 1 of 1