generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Java: UI 101

Previous Thread :: Next Thread 
ZizZazZuz is not online. ZizZazZuz
Joined: 16 Jun 2008
Total Posts: 2743
03 May 2012 06:40 PM
I want to make a simple user interface. The Roblox equivalent of a Textbox and a button that prints the text. How would I do so?
Report Abuse
Legend26 is not online. Legend26
Joined: 08 Sep 2008
Total Posts: 10586
03 May 2012 06:48 PM
JTextButton, JTextLabel
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
03 May 2012 07:23 PM
To access those, you have to add this to the top of your code:


import javax.swing.JButton;
import javax.swing.JTextLabel;


OR


import javax.swing.*;



Then you have to work with the layouts and new windows and all that garbage. If you want a sample, let me know and I'll write one up for you.
Report Abuse
crazyman32 is online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
03 May 2012 07:46 PM
Let me see yo hips javax.swing.*;
Report Abuse
Ozzypig is not online. Ozzypig
Joined: 27 Mar 2008
Total Posts: 4906
03 May 2012 07:55 PM
I didn't know crazyman could javax.swing dance
Report Abuse
ZizZazZuz is not online. ZizZazZuz
Joined: 16 Jun 2008
Total Posts: 2743
03 May 2012 09:36 PM
Nerd humor. I love this forum community. :D
Report Abuse
Legend26 is not online. Legend26
Joined: 08 Sep 2008
Total Posts: 10586
03 May 2012 09:58 PM
Or you can have eclipse import everything you need instead of hunting down what has to be imported specifically.
Report Abuse
SDuke524 is not online. SDuke524
Joined: 29 Jul 2008
Total Posts: 6267
03 May 2012 10:00 PM
What's the main differences between Eclipse and Netbeans? I personally use Netbeans however I've heard a lot more people talking about eclipse than netbeans.
Report Abuse
ZizZazZuz is not online. ZizZazZuz
Joined: 16 Jun 2008
Total Posts: 2743
03 May 2012 10:11 PM
I use eclipse, but only because it was recommended to me.
Report Abuse
crazyman32 is online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
03 May 2012 10:11 PM
Netbeans is really only good if you want to develop GUIs with extreme ease.
Eclipse is the best for straight-up coding

In a professional outlook, do NOT use Netbeans. My dad and his team work with Java for Nationwide Insurance and he explained that Eclipse (SpringSource STS Version preferably) is the best thing to use.
Report Abuse
ZizZazZuz is not online. ZizZazZuz
Joined: 16 Jun 2008
Total Posts: 2743
04 May 2012 08:29 AM
@fire An example would be nice... :S
Report Abuse
ZizZazZuz is not online. ZizZazZuz
Joined: 16 Jun 2008
Total Posts: 2743
04 May 2012 02:05 PM
Up!

BTW, I use JRE 6... Just in case that proves to be a problem.
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
04 May 2012 03:06 PM
"I want to make a simple user interface. The Roblox equivalent of a Textbox and a button that prints the text. How would I do so?"


import javax.swing.*;
import java.awt.event.*;

public class Test {
    // Test.java file
    public static void main(String[] args) {
        JFrame frame = new JFrame("Print Testing Window");
        JButton button = new JButton("Click to Print");
        JPanel panel = new JPanel();

final JTextField text = new JTextField(100);
        // final to be able to access inside anonymous classes

        frame.add(panel);
        panel.add(text);
        panel.add(button);

        button.addActionListener(new ActionListener() {
            // class of type X (unknown) that implements ActionListener
            // AKA anonymous class
            public void actionPerformed(ActionEvent e) {
                System.out.println(text.getText());
            }
        });

        frame.setVisible(true);
        frame.pack();
    }
}




You may have to add a couple more imports. I just typed this up on the spot.
Report Abuse
MrMcAero is not online. MrMcAero
Joined: 21 Apr 2012
Total Posts: 671
04 May 2012 03:15 PM
@AgentFireFox,

I caught a failure in your code. :P

import javax.swing.; //Why do you have a . without a *!??!

Use this for the javax.swing import.

import javax.swing.*; //Will import ALL of javax.swing's importable stuff.

- Cheers!
Report Abuse
C0D3Y is not online. C0D3Y
Joined: 24 Jul 2010
Total Posts: 1692
04 May 2012 03:16 PM
Did not expect to see CM32 bringing up Savage on a forum like this...
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
04 May 2012 03:17 PM
"@AgentFireFox,

I caught a failure in your code. :P

import javax.swing.; //Why do you have a . without a *!??!"


You, sir, are quite delusional.
Report Abuse
MrMcAero is not online. MrMcAero
Joined: 21 Apr 2012
Total Posts: 671
04 May 2012 03:17 PM
Although NetBean's is good, I use a program my dad's company BUILT, and only his company has it.

The main thing I like about their program is that it has auto-update on UI. So I have a window in the
left that show's what my UI will look like.

- Cheers!
Report Abuse
MrMcAero is not online. MrMcAero
Joined: 21 Apr 2012
Total Posts: 671
04 May 2012 03:19 PM
@AgentFireFox,

Honestly, I'm new to Java (Started yesterday) do I not need the *?
Actually does the * do what I said it does? Import all of the
javax.swing
importable stuff? Sorry, also, I couldn't tell if you were joking,
or using sarcasm. LOL.

- Cheers!
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
04 May 2012 03:20 PM
My code had *.
Yes, * does import ALL components. I believe you can also do something like .A* to import all classes beginning with A (though don't quote me on that).
Report Abuse
C0D3Y is not online. C0D3Y
Joined: 24 Jul 2010
Total Posts: 1692
04 May 2012 03:21 PM
Thought that the asterisk meant anything that ended in a certain thing. Not sure though...
Report Abuse
C0D3Y is not online. C0D3Y
Joined: 24 Jul 2010
Total Posts: 1692
04 May 2012 03:21 PM
Late post. I was wrong. Big surprise....
Report Abuse
MrMcAero is not online. MrMcAero
Joined: 21 Apr 2012
Total Posts: 671
04 May 2012 03:24 PM
What?

I'm looking at your code right now, I do not see any *'s.

//It might be the ROBLOX Forum enhancer.

- Cheers!
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
04 May 2012 03:27 PM
Forum enhancer is your problem. It's garbage.
Report Abuse
ZizZazZuz is not online. ZizZazZuz
Joined: 16 Jun 2008
Total Posts: 2743
04 May 2012 03:28 PM
Nice. How would I change the position of the different objects?
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
04 May 2012 03:30 PM
You would have to set the layout to null, then manually set the position and size of each object.



panel.setLayout(null);
button.setBounds(10, 10, 100, 60); //@ (10, 10) w/ size of 100x60
panel.add(button);
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image