Checkbox - JRuby

Hi all,

This one has me beaten. The code follows below.

I am creating a GUI, which contains a single checkbox (more soon) and a
Go button.

All I am trying to do at this stage is:
1. Create a GUI with checkbox - DONE
2. Put a tick in the box & click go - DONE
3. After licking go, I want to test if the checkbox is selected and if
it, output "Box was ticked" - this just does not happen

Can anyone perhaps spot the stupid mistake I am making?

include Java

module Js
  import java.awt.GridLayout
  include_package "javax.swing"
  include_package "javax.swing.JFrame"
  include_package "javax.swing.JButton"
  include_package "javax.swing.JPanel"
  include_package "javax.swing.JOptionPane"
  include_package "javax.swing.JPane"
  include_package "javax.swing.JScrollPane"
  include_package "javax.swing.JCheckBox"
end

panel = Js::JPanel.new
panel.setLayout GridLayout.new 10, 2

eCheckBox = Js::JCheckBox.new
elbl = Js::JLabel.new(“Everything");

panel.add(eCheckBox);
panel.add(elbl);

goButton = Js::JButton.new("Run")
panel.add goButton

frame = Js::JFrame.new()
frame.add panel
frame.pack
frame.setTitle(“GUI Checkbox")
frame.setResizable false
frame.setLocationRelativeTo nil

goButton.addActionListener do |e|
  if EVTCheckBox.isSelected()
    puts “Box was ticked"
  end
  frame.dispose()
end

frame.setVisible true

···

--
Posted via http://www.ruby-forum.com/.

As far as I can see EVTCheckBox is never defined in this piece of code.

Cheers

robert

···

On Wed, Jan 15, 2014 at 1:40 PM, Stuart Clarke <lists@ruby-forum.com> wrote:

Hi all,

This one has me beaten. The code follows below.

I am creating a GUI, which contains a single checkbox (more soon) and a
Go button.

All I am trying to do at this stage is:
1. Create a GUI with checkbox - DONE
2. Put a tick in the box & click go - DONE
3. After licking go, I want to test if the checkbox is selected and if
it, output "Box was ticked" - this just does not happen

Can anyone perhaps spot the stupid mistake I am making?

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

Robert Klemme wrote in post #1133241:

3. After licking go, I want to test if the checkbox is selected and if
it, output "Box was ticked" - this just does not happen

Can anyone perhaps spot the stupid mistake I am making?

As far as I can see EVTCheckBox is never defined in this piece of code.

Cheers

robert

Sorry thats a typo, below is correct.

goButton.addActionListener do |x|
  if eCheckBox.isSelected()
    puts “Box was ticked"
  end
  frame.dispose()
end

···

On Wed, Jan 15, 2014 at 1:40 PM, Stuart Clarke <lists@ruby-forum.com> > wrote:

--
Posted via http://www.ruby-forum.com/.