Official Nodeka Board  

Go Back   Official Nodeka Board > Nodeka > Scripting > UMC

Reply
 
Thread Tools Display Modes
  #11  
Old 10-14-2009, 06:30 AM
Bellum Bellum is offline
Novice
 
Join Date: Sep 2009
Posts: 25
Default

Quote:
Originally Posted by grimm View Post
I think its possible to code without getting into the core of UMC. as the salvage plugin provided by Uda didn't need to change any UMC files. it just added an addition jar?

i could be wrong.
But if Uda could shed some light on how we can do this . It'll be most appreciated.
Oh yea, good point. Lol I did notice that the 3 posts he made were his first 3 on this site. I don't think he really comes to this site often =/ I'm still working on making buttons do something lol. I would love to see a section with java and javascript questions since both are now usable with umc.
Reply With Quote
  #12  
Old 10-15-2009, 01:17 AM
uda uda is offline
Wanderer
 
Join Date: Oct 2009
Posts: 8
Default

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");
}
This registers the top level name Salvage under Plugins with a menu item of Materials which calls the showFrame() function of the com.lsd.udabot.plugins.salvage.Crafting class.
Reply With Quote
  #13  
Old 10-15-2009, 01:55 AM
Bellum Bellum is offline
Novice
 
Join Date: Sep 2009
Posts: 25
Default 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);
Error: Can't find method java.awt.Container.add(string,java.lang.String). (window.js#13)

Last edited by Bellum; 10-15-2009 at 02:00 AM.
Reply With Quote
  #14  
Old 10-20-2009, 07:51 PM
uda uda is offline
Wanderer
 
Join Date: Oct 2009
Posts: 8
Default

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);
You will also have to look at the ActionListener class for the JButton to trigger click events.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:31 PM.


Design By: Miner Skinz.com
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.