I apologize. Thanks for the response. I am looking into MigLayout. When
you
see my code you are going to puck. Anyhoo, I played with it some more a
found out I couldn’t reference constants with ‘.’ notation.
Example:
I was using *
import* javax.swing.GroupLayout.Alignment
when I should have, I believe, being using
*import javax.swing.GroupLayout::Alignment
*
I modified the code and am now getting this error:
*TypeError: HORIZONTAL
javax.swing.GroupLayout$SequentialGroup 1ad0839 , size=0,
alignment=null prefs
=[0 0 0]
javax.swing.GroupLayout$ParallelGroup f6f1b6 , size=0,
alignment=null
prefs=
[0 0 0]
VERTICAL
javax.swing.GroupLayout$SequentialGroup 771eb1 , size=0,
alignment=null
prefs=
[0 0 0]
javax.swing.GroupLayout$ParallelGroup 801059 , size=0,
alignment=null
prefs=
[0 0 0]
is not a class/module
initUI at CompareOperations.rb:91
initialize at CompareOperations.rb:32
(root) at CompareOperations.rb:162*
I am really not sure how to decipher that. Now, the code.
The Horrible Truth:
*#!/usr/local/bin/jruby
include Java
import javax.swing.JButton
import javax.swing.JFrame
import javax.swing.JPanel
import java.lang.System
import java.awt.Color
import javax.swing.JLabel
import java.awt.Dimension
import javax.swing.JTextArea
import javax.swing.SwingConstants
import javax.swing.BorderFactory
import javax.swing.GroupLayout
import javax.swing.GroupLayout::Alignment
import javax.swing.JScrollPane
import java.awt.Font
import javax.swing.LayoutStyle
import java.lang.Short
class GUI < JFrame
def initialize
super "GUI"
self.initUI
end
def initUI
layout = GroupLayout.new self.getContentPane
self.getContentPane.setLayout layout
self.setBackground Color.new 66, 66, 66
#self.setPreferredSize Dimension.new 900,660
#initialize components
oldLabel = JLabel.new "Legacy"
newLabel = JLabel.new "New"
oldTextArea = JTextArea.new
newTextArea = JTextArea.new
oldScroll = JScrollPane.new
newScroll = JScrollPane.new
clearButton1 = JButton.new "Clear"
clearButton2 = JButton.new "Clear"
runButton = JButton.new "Run"
quitButton = JButton.new "Quit"
#set compnent attributes
oldLabel.setFont Font.new("Tahoma", 1, 11)
newLabel.setFont Font.new("Tahoma", 1, 11)
oldTextArea.setEditable true
oldTextArea.setBackground Color.new 232, 232, 234
oldTextArea.setColumns 20
oldTextArea.setRows 5
oldTextArea.setBorder BorderFactory.createLineBorder Color.new
20,
26, 40
oldScroll.setViewportView oldTextArea
newTextArea.setEditable true
newTextArea.setBackground Color.new 232, 232, 234
newTextArea.setColumns 20
newTextArea.setRows 5
newTextArea.setBorder BorderFactory.createLineBorder Color.new
20,
26, 40
newScroll.setViewportView newTextArea
clearButton1.setBackground Color.new 20, 26, 40
clearButton1.setForeground Color.white
clearButton2.setBackground Color.new 20, 26, 40
clearButton2.setForeground Color.white
runButton.setFont Font.new("Tahoma", 1, 11)
runButton.setBackground Color.new 20, 26, 40
runButton.setForeground Color.white
quitButton.setBackground Color.new 20, 26, 40
quitButton.setForeground Color.white
quitButton.add_action_listener do |e|
System.exit 0
end
#end set comonent attributes
#design layout
layout.setHorizontalGroup(layout \
.createParallelGroup(Alignment::LEADING)\
.addGroup(layout.createSequentialGroup \
.addGap(31, 31, 31) \
.addGroup(layout.createParallelGroup(Alignment::LEADING)
.addComponent(oldLabel)
.addComponent(oldScroll,
layout::PREFERRED_SIZE,
429,
layout::PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup
.addGap(10, 10, 10)
.addComponent(clearButton1)))
.addPreferredGap(SComponentPlacement::RELATED)
.addGroup(layout.createParallelGroup(Alignment::LEADING)
.addComponent(newScroll,
layout::PREFERRED_SIZE,
429,
layout::PREFERRED_SIZE)
.addComponent(newLabel)
.addGroup(layout.createSequentialGroup
.addGap(10,10,10)
.addComponent(clearButton2)))
.addContainerGap(32, Short::MAX_VALUE))
.addGroup(Alignment::TRAILING,
layout.createSequentialGroup
.addContainerGap(425, Short::MAX_VALUE) \
.addGroup(layout.createParallelGroup(Alignment::LEADING)
.addComponent(quitButton)
.addComponent(runButton))
.addGap(447, 447, 447)))
layout.setVerticalGroup(layout \
.createParallelGroup(Alignment::LEADING) \
.addGroup(layout.createSequentialGroup \
.addGap(17, 17, 17) \
.addGroup(layout.createParallelGroup(Alignment::TRAILING)
.addComponent(oldLabel)
.addComponent(newLabel))
.addPreferredGap(ComponentPlacement::RELATED)
.addGroup(layout.createParallelGroup(Alignment::LEADING,
false)
.addComponent(newScroll)
.addComponent(oldScroll,
layout::DEFAULT_SIZE,
521,
layout::MAX_VALUE)
.addPreferredGap(ComponentPlacement::RELATED) \
.addGroup(layout.createParallelGroup(Alignment::BASELINE)
.addComponent(clearButton2)
.addComponent(clearButton1))
.addGap(18, 18, 18)
.addComponent(runButton)
.addPreferredGap(ComponentPlacement::RELATED,
DEFAULT_SIZE,
MAX_VALUE)
.addComponent(quitButton)
.addContainerGap)))
layout.linkSize SwingConstants::HORIZONTAL, quitButton,
runButton, clearButton1, clearButton2
self.pack
#end design layout
self.setDefaultCloseOperation JFrame::EXIT_ON_CLOSE
self.setLocationRelativeTo nil
self.setVisible true
end
end
GUI.new
*