use javax.swing.event.ChangeEvent
use javax.swing.event.ChangeListener
use javax.swing.JComponent
use javax.swing.JPanel
use javax.swing.JSplitPane
use javax.swing.JLabel
use java.awt.Container
use java.awt.Dimension
use java.awt.GridBagLayout
use java.awt.GridBagConstraints
use java.awt.Insets
declare BBjSysGui sysgui!
declare BBjWindow window!
declare BBjButton button!
declare BBjCEdit cedit!
declare BBjCheckBox checkbox!
declare BBjEditBox editbox!
declare BBjImageCtrl imagectrl!
declare BBjInputE inpute!
declare BBjInputN inputn!
declare BBjInputD inputd!
declare BBjListBox listbox!
declare BBjListButton listbutton!
declare BBjListEdit listedit!
declare BBjNavigator navigator!
declare BBjProgressBar progressbar!
declare BBjScrollBar scrollbar!
declare BBjStaticText statictext!
declare BBjToolButton toolbutton!
declare BBjTree tree!
declare BBjStandardGrid grid!
declare Container container!
declare Dimension@ dimension!
declare JComponent component!
declare JPanel@ clientPanel!
declare GridBagLayout@ layout!
declare GridBagConstraints@ c!
open (unt)"X0"
sysgui! = BBjAPI().getSysGui()
window! = sysgui!.addWindow(100,100,800,600,"BBjWindow",$00010013$)
layout! = new GridBagLayout@()
clientPanel! = new JPanel@()
clientpanel!.setLayout(layout!)
sizer! = new Sizer(clientPanel!)
declare Insets@ i!
i! = new Insets@(3,3,3,3)
declare BBjNumber EAST
declare BBjNumber NORTHEAST
declare BBjNumber NORTHWEST
declare BBjNumber NONE
declare BBjNumber HORZ
declare BBjNumber VERT
declare BBjNumber BOTH
EAST = java.awt.GridBagConstraints.EAST
NORTHEAST = java.awt.GridBagConstraints.NORTHEAST
NORTHWEST = java.awt.GridBagConstraints.NORTHWEST
NONE = java.awt.GridBagConstraints.NONE
HORZ = java.awt.GridBagConstraints.HORIZONTAL
VERT = java.awt.GridBagConstraints.VERTICAL
BOTH = java.awt.GridBagConstraints.BOTH
ListSample$ = "A"+$0A$+"B"+$0A$+"C"+$0A$+"D"+$0A$+"E"+$0A$+"F"+$0A$
text! = new JLabel@("BBjEditBox")
c! = new GridBagConstraints@(0,0,1,1,1,0,NORTHEAST,NONE,i!,0,0)
clientPanel!.add(text!,c!);
editbox! = window!.addEditBox(101,10,10,90,30,"BBjEditBox")
c! = new GridBagConstraints@(1,0,1,1,1,0,NORTHWEST,HORIZONTAL,i!,0,0)
clientPanel!.add(editbox!,c!);
sizer!.setSize(1,90,30)
text! = new JLabel@("BBjListBox")
c! = new GridBagConstraints@(2,0,1,1,1,0,NORTHEAST,NONE,i!,0,0)
clientPanel!.add(text!,c!);
listbox! = window!.addListBox(102,10,10,90,30,ListSample$)
c! = new GridBagConstraints@(3,0,1,2,1,1,NORTHWEST,BOTH,i!,0,0)
clientPanel!.add(listbox!,c!);
text! = new JLabel@("BBjCEdit")
c! = new GridBagConstraints@(4,0,1,1,1,0,NORTHEAST,NONE,i!,0,0)
clientPanel!.add(text!,c!);
gosub gettysburg
cedit! = window!.addCEdit(103,10,10,200,100,gettysburg$,$0182$)
c! = new GridBagConstraints@(5,0,1,2,3,0,NORTHWEST,BOTH,i!,0,0)
clientPanel!.add(cedit!,c!);
sizer!.setSize(5,200,80)
text! = new JLabel@("BBjInputE")
c! = new GridBagConstraints@(0,1,1,1,0,0,NORTHEAST,NONE,i!,0,0)
clientPanel!.add(text!,c!);
inpute! = window!.addInputE(104,10,10,90,30)
c! = new GridBagConstraints@(1,1,1,1,1,0,NORTHWEST,HORIZONTAL,i!,0,0)
clientPanel!.add(inpute!,c!);
sizer!.setSize(7,90,30)
text! = new JLabel@("BBjInputN")
c! = new GridBagConstraints@(0,2,1,1,0,0,NORTHEAST,NONE,i!,0,0)
clientPanel!.add(text!,c!);
inputn! = window!.addInputN(105,10,10,90,30)
c! = new GridBagConstraints@(1,2,1,1,1,0,NORTHWEST,HORIZONTAL,i!,0,0)
clientPanel!.add(inputn!,c!);
sizer!.setSize(9,90,30)
text! = new JLabel@("BBjListButton")
c! = new GridBagConstraints@(2,2,1,1,0,0,NORTHEAST,NONE,i!,0,0)
clientPanel!.add(text!,c!);
listbutton! = window!.addListButton(106,10,10,90,90,ListSample$)
c! = new GridBagConstraints@(3,2,1,1,1,0,NORTHWEST,HORIZONTAL,i!,0,0)
clientPanel!.add(listbutton!,c!);
sizer!.setSize(11,90,30)
text! = new JLabel@("BBjTree")
c! = new GridBagConstraints@(4,2,1,1,0,0,NORTHEAST,NONE,i!,0,0)
clientPanel!.add(text!,c!);
tree! = window!.addTree(107,10,10,200,100)
dim music$[2,4]
music$[0,0]="The Beatles"
music$[0,1]="Hey Jude",MUSIC$[0,2]="Let It Be",MUSIC$[0,3]="Twist and Shout",MUSIC$[0,4]="Yesterday"
music$[1,0]="Paul Simon"
music$[1,1]="Bridge Over Troubled Waters",MUSIC$[1,2]="Hearts and Bones",MUSIC$[1,3]="Kathy's Song",MUSIC$[1,4]="The Sound of Silence"
music$[2,0]="Willie Nelson"
music$[2,1]="Always On My Mind",MUSIC$[2,2]="Getting Over You",MUSIC$[2,3]="Old Fords and Natural Stone",MUSIC$[2,4]="This Morning"
parent=0,node=1
tree!.setRoot(parent,"Music Tree")
for artist=0 to 2
node=node+1
tree!.addExpandableNode(node,parent,music$[artist,0])
song_parent=node
for song=1 TO 4
node=node+1
tree!.addNode(node,song_parent,music$[artist,song])
next song
next artist
c! = new GridBagConstraints@(5,2,1,3,3,1,NORTHWEST,BOTH,i!,0,0)
clientPanel!.add(tree!,c!);
sizer!.setSize(13,200,100)
text! = new JLabel@("BBjInputD")
c! = new GridBagConstraints@(0,3,1,1,0,0,NORTHEAST,NONE,i!,0,0)
clientPanel!.add(text!,c!);
inputd! = window!.addInputD(108,10,10,90,30)
c! = new GridBagConstraints@(1,3,1,1,1,0,NORTHWEST,HORIZONTAL,i!,0,0)
clientPanel!.add(inputd!,c!);
sizer!.setSize(15,90,30)
text! = new JLabel@("BBjListEdit")
c! = new GridBagConstraints@(2,3,1,1,0,0,NORTHEAST,NONE,i!,0,0)
clientPanel!.add(text!,c!);
listedit! = window!.addListEdit(109,10,10,90,90,ListSample$)
c! = new GridBagConstraints@(3,3,1,1,1,0,NORTHWEST,HORIZONTAL,i!,0,0)
clientPanel!.add(listedit!,c!);
sizer!.setSize(17,90,30)
text! = new JLabel@("BBjCheckBox")
c! = new GridBagConstraints@(0,4,1,1,0,0,NORTHEAST,NONE,i!,0,0)
clientPanel!.add(text!,c!);
declare BBjCheckBox check1!
check1! = window!.addCheckBox(110,10,10,90,30,"Check1")
c! = new GridBagConstraints@(1,4,1,1,1,0,NORTHWEST,HORIZONTAL,i!,0,0)
clientPanel!.add(check1!,c!);
sizer!.setSize(19,90,30)
text! = new JLabel@("BBjCheckBox")
c! = new GridBagConstraints@(2,4,1,1,0,0,NORTHEAST,NONE,i!,0,0)
clientPanel!.add(text!,c!);
declare BBjCheckBox check2!
check2! = window!.addCheckBox(111,10,10,90,30,"Check2")
c! = new GridBagConstraints@(3,4,1,1,1,0,NORTHWEST,HORIZONTAL,i!,0,0)
clientPanel!.add(check2!,c!);
sizer!.setSize(21,90,30)
text! = new JLabel@("BBjRadioButton")
c! = new GridBagConstraints@(0,5,1,1,0,0,NORTHEAST,NONE,i!,0,0)
clientPanel!.add(text!,c!);
declare BBjRadioButton radio1!
radio1! = window!.addRadioButton(112,10,10,90,30,"Radio1",$0020$)
c! = new GridBagConstraints@(1,5,1,1,1,0,NORTHWEST,HORIZONTAL,i!,0,0)
clientPanel!.add(radio1!,c!);
sizer!.setSize(23,90,30)
text! = new JLabel@("BBjRadioButton")
c! = new GridBagConstraints@(2,5,1,1,0,0,NORTHEAST,NONE,i!,0,0)
clientPanel!.add(text!,c!);
declare BBjRadioButton radio2!
radio2! = window!.addRadioButton(113,10,10,90,30,"Radio2",$0020$)
c! = new GridBagConstraints@(3,5,1,1,1,0,NORTHWEST,HORIZONTAL,i!,0,0)
clientPanel!.add(radio2!,c!);
sizer!.setSize(25,90,30)
radiogroup! = window!.addRadioGroup()
radioGroup!.add(radio1!)
radioGroup!.add(radio2!)
text! = new JLabel@("BBjGrid")
c! = new GridBagConstraints@(4,5,1,1,0,0,NORTHEAST,NONE,i!,0,0)
clientPanel!.add(text!,c!);
grid! = window!.addGrid(114,10,10,300,100)
grid!.setNumRows(10)
grid!.setNumColumns(10)
grid!.setDefaultColumnWidth(30)
grid!.setHorizontalScrollable(sysgui!.TRUE)
grid!.setVerticalScrollable(sysgui!.TRUE)
grid!.setScrollUpdate(sysgui!.TRUE)
grid!.setDefaultAlignment(sysgui!.GRID_ALIGN_LEFT)
grid!.setHasColumnHeader(sysgui!.TRUE)
grid!.setDefaultAlignment(sysgui!.GRID_ALIGN_LEFT)
grid!.setEditable(sysgui!.TRUE)
c! = new GridBagConstraints@(5,5,1,3,3,1,NORTHWEST,BOTH,i!,0,0)
clientPanel!.add(grid!,c!);
sizer!.setSize(27,200,100)
text! = new JLabel@("BBjProgressBar")
c! = new GridBagConstraints@(0,6,1,1,0,0,NORTHEAST,NONE,i!,0,0)
clientPanel!.add(text!,c!);
declare BBjProgressBar progress!
progress! = window!.addProgressBar(115,10,10,90,30)
c! = new GridBagConstraints@(1,6,3,1,1,0,NORTHWEST,HORIZONTAL,i!,0,0)
clientPanel!.add(progress!,c!);
sizer!.setSize(29,90,30)
text! = new JLabel@("BBjNavigator")
c! = new GridBagConstraints@(0,7,1,1,0,0,NORTHEAST,NONE,i!,0,0)
clientPanel!.add(text!,c!);
navigator! = window!.addNavigator(116,10,10,150,30,"BBjNavigator")
c! = new GridBagConstraints@(1,7,3,1,1,0,NORTHWEST,HORIZONTAL,i!,0,0)
clientPanel!.add(navigator!,c!);
sizer!.setSize(31,150,30)
text! = new JLabel@("BBjScrollBar")
c! = new GridBagConstraints@(0,8,1,1,0,0,NORTHEAST,NONE,i!,0,0)
clientPanel!.add(text!,c!);
scrollbar! = window!.addHorizontalScrollBar(1116,10,10,90,30)
c! = new GridBagConstraints@(1,8,3,1,1,0,NORTHWEST,HORIZONTAL,i!,0,0)
clientPanel!.add(scrollbar!,c!);
sizer!.setSize(33,90,30)
text! = new JLabel@("BBjImage")
c! = new GridBagConstraints@(4,8,1,1,0,0,NORTHEAST,NONE,i!,0,0)
clientPanel!.add(text!,c!);
declare BBjImage image!
image! = BBjAPI().getSysGui().getImageManager().loadImageFromFile("chilelogo.bmp")
imagectrl! = window!.addImageCtrl(117,10,10,90,30,image!)
c! = new GridBagConstraints@(5,8,1,3,3,1,NORTHWEST,BOTH,i!,0,0)
clientPanel!.add(imagectrl!,c!);
text! = new JLabel@("BBjButton")
c! = new GridBagConstraints@(0,9,1,1,0,0,NORTHEAST,NONE,i!,0,0)
clientPanel!.add(text!,c!);
button! = window!.addButton(1110,10,10,90,30,"Button")
c! = new GridBagConstraints@(1,9,1,1,1,0,NORTHWEST,HORIZONTAL,i!,0,0)
clientPanel!.add(button!,c!);
sizer!.setSize(37,90,30)
declare JLabel@ text!
text! = new JLabel@("BBjToolButton")
c! = new GridBagConstraints@(2,9,1,1,0,0,NORTHEAST,NONE,i!,0,0)
clientPanel!.add(text!,c!);
toolbutton! = window!.addToolButton(1111,10,10,90,30,"Tool Button")
c! = new GridBagConstraints@(3,9,1,1,1,0,NORTHWEST,HORIZONTAL,i!,0,0)
clientPanel!.add(toolbutton!,c!);
sizer!.setSize(39,90,30)
dimension! = new Dimension@(cast(BBjNumber,window!.getWidth()),cast(BBjNumber, window!.getHeight()))
clientPanel!.setPreferredSize(dimension!)
window!.addWrappedJComponent(2222, 0, 0, window!.getWidth(), window!.getY(), clientPanel!)
clientPanel!.setPreferredSize(dimension!)
window!.setVisible(1)
listener! = new Listener()
window!.setCallback(window!.ON_CLOSE,"eoj")
window!.setCallback(window!.ON_RESIZE,"resize")
button!.setCallback(button!.ON_BUTTON_PUSH,listener!,"buttonPush")
toolbutton!.setCallback(toolbutton!.ON_TOOL_BUTTON_PUSH,listener!,"toolButtonPush")
process_events
eoj:
release
resize:
event!=BBjAPI().getSysGui().getLastEvent()
dimension! = new Dimension@(cast(BBjNumber,event!.getWidth()),cast(BBjNumber,event!.getHeight()))
clientPanel!.setPreferredSize(dimension!)
return
class public Sizer
field private JPanel@ panel!
method public Sizer(JPanel@ panel!)
#panel! = panel!
methodend
method public void setSize(BBjNumber i, BBjNumber w, BBjNumber h)
dimension! = new Dimension@(w,h)
component! = #panel!.getComponent(i)
component!.setMinimumSize(dimension!)
methodend
classend
class public Listener
method public void stateChanged(ChangeEvent p_event!)
print " =============== in listener ================="
print p_event!
target! = p_event!.getSource()
? target!.getValue()
methodend
method public void buttonPush(BBjButtonPushEvent event!)
print "button pushed"
methodend
method public void toolButtonPush(BBjToolButtonPushEvent event!)
print "tool button pushed"
methodend
classend
gettysburg:
gettysburg$ =
: "Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal."+$0a$+$0a$+
: "Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived and so dedicated, can long endure. We are met on a great battle-field of that war. We have come to dedicate a portion of that field, as a final resting place for those who here gave their lives that that nation might live. It is altogether fitting and proper that we should do this."+$0a$+$0a$+
: "But, in a larger sense, we can not dedicate -- we can not consecrate -- we can not hallow -- this ground. The brave men, living and dead, who struggled here, have consecrated it, far above our poor power to add or detract. The world will little note, nor long remember what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced. It is rather for us to be here dedicated to the great task remaining before us -- that from these honored dead we take increased devotion to that cause for which they gave the last full measure of devotion -- that we here highly resolve that these dead shall not have died in vain -- that this nation, under God, shall have a new birth of freedom -- and that government of the people, by the people, for the people, shall not perish from the earth."+$0a$
return
|