#11
|
|||
|
|||
Quote:
|
#12
|
|||
|
|||
Grimm,
If you take a look at the API docs for the ScriptInterface class at the end you'll see a function called registerMenu() https://lsd.ca/umc/docs/plugin-api/c...Interface.html Example Code:
public void init(ScriptInterface script) { script.registerMenu( "Salvage", new JMenuItem("Materials"), "com.lsd.udabot.plugins.salvage.Crafting", "showFrame"); } |
#13
|
|||
|
|||
Buttons
Once you are able to create a frame I have figured out how to add a button and give it an action. Although the way I have this coded when I run the command createFrame() it runs my kosOff() function. It and I was wondering about JPanels if I should use a JPanel if I plane to add more then one button to a window.
Code:
function createFrame() { //myFrame var myFrame = javax.swing.JFrame("Bellum Bot"); b = { actionPreformed: kosOff()} myFrame.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); myFrame.getContentPane().add(myButton1,java.awt.BorderLayout.NORTH); myFrame.pack(); myFrame.setSize(300,200); myFrame.setVisible(true); //myButton1 myButton1 = ("Kos Off"); function kosOff() {umc.parse ("kosOff")} myButton1.addActionListener(kosOff) myButton1Listener = new JavaAdapter(java.awt.event.ActionListener, b) } Hmmm I seem to have found a bug in my code. I know which line it is, I have no clue what is bugged about it. Code:
myFrame.getContentPane().add(myButton1,java.awt.BorderLayout.NORTH); Last edited by Bellum; 10-15-2009 at 02:00 AM. |
#14
|
|||
|
|||
That would be because you never defined the variable myButton1 properly before trying to add it to the content pane.
You also define it wrong later (as a javascript string); addComponent() only accepts well, components. Read the Java 1.6 API docs for information on any of the Java classes http://java.sun.com/javase/6/docs/api/ Code:
var myButton1 = javax.swing.JButton("Button Text"); myFrame.getContentPane().add(myButton1,java.awt.BorderLayout.NORTH); |
Thread Tools | |
Display Modes | |
|
|