You are viewing our Forum Archives. To view or take place in current topics click here.
[Java] Controls (User Interface) Glitchy?
Posted:

[Java] Controls (User Interface) Glitchy?Posted:

Z61
  • V5 Launch
Status: Offline
Joined: Apr 16, 201014Year Member
Posts: 4,309
Reputation Power: 179
Status: Offline
Joined: Apr 16, 201014Year Member
Posts: 4,309
Reputation Power: 179
Well I've just got into Java via a friend showing me the basics over Teamviewer.
Anyway we can't seem to understand why but the controls don't show up until hovered or clicked(textbox) and the only button on the page fully encompasses the form.

If you didn't understand the above I've included a picture:
[ Register or Signin to view external links. ]

Here is the code I am using for Control creation, which works fine.
Note: I haven't put the imports or the constructor in this.

//Begin User Control Creation
         button = new JButton();
         field1 = new JTextField();
         field2 = new JTextField();
         label = new JLabel();
          //End User Control Creation
         //Begin User Control Text Properties
         label.setText("+");
         button.setText("ADD");
         //End User Control Text Properties
         //Begin User Control Size Properties
         field1.setSize(45, 22);
           button.setSize(50, 20);
           label.setSize(20,20);
           //End User Control Size Properties
           //Begin User Control Location Properties
           button.setLocation(90, 35);
           field1.setLocation(40, 2);
              label.setLocation(70, 2);

Sorry if its messy, it looks more organized locally
#2. Posted:
Logiztics
  • Junior Member
Status: Offline
Joined: Apr 07, 201212Year Member
Posts: 51
Reputation Power: 2
Status: Offline
Joined: Apr 07, 201212Year Member
Posts: 51
Reputation Power: 2
I have had the same problem before and as you probably figured out there is no real answer on the Internet well I have the answer. The answer is add this to your code:

(your JFrame Name).setLayout(null);

and once you put this in your code all of your sizes and things will be set to the dimensions that you have set. Also if you have any other problems PM me since I'm going into University next year for Computer Science and I'm in Grade 12 Programming as of right now.
#3. Posted:
TTGXMODsX
  • TTG Natural
Status: Offline
Joined: Feb 06, 201014Year Member
Posts: 996
Reputation Power: 64
Status: Offline
Joined: Feb 06, 201014Year Member
Posts: 996
Reputation Power: 64
Logiztics wrote I have had the same problem before and as you probably figured out there is no real answer on the Internet well I have the answer. The answer is add this to your code:

(your JFrame Name).setLayout(null);

and once you put this in your code all of your sizes and things will be set to the dimensions that you have set. Also if you have any other problems PM me since I'm going into University next year for Computer Science and I'm in Grade 12 Programming as of right now.


That's wrong your setLayout does not need to be null i'm however guessing that you are using the border layout I suggest you use the gridlayout will give you much more flexibility
#4. Posted:
Logiztics
  • Junior Member
Status: Offline
Joined: Apr 07, 201212Year Member
Posts: 51
Reputation Power: 2
Status: Offline
Joined: Apr 07, 201212Year Member
Posts: 51
Reputation Power: 2
TTGXMODsX wrote
Logiztics wrote I have had the same problem before and as you probably figured out there is no real answer on the Internet well I have the answer. The answer is add this to your code:

(your JFrame Name).setLayout(null);

and once you put this in your code all of your sizes and things will be set to the dimensions that you have set. Also if you have any other problems PM me since I'm going into University next year for Computer Science and I'm in Grade 12 Programming as of right now.


That's wrong your setLayout does not need to be null i'm however guessing that you are using the border layout I suggest you use the gridlayout will give you much more flexibility


It actually does you doorknob. If you don't put that in then the computer will still set the button to full screen even if you use gridlayout or anything. If you don't believe then fine, but I just created a game for my final project in class and if you don't the button would fit the entire screen.
#5. Posted:
TTGXMODsX
  • TTG Natural
Status: Offline
Joined: Feb 06, 201014Year Member
Posts: 996
Reputation Power: 64
Status: Offline
Joined: Feb 06, 201014Year Member
Posts: 996
Reputation Power: 64
Logiztics wrote
TTGXMODsX wrote
Logiztics wrote I have had the same problem before and as you probably figured out there is no real answer on the Internet well I have the answer. The answer is add this to your code:

(your JFrame Name).setLayout(null);

and once you put this in your code all of your sizes and things will be set to the dimensions that you have set. Also if you have any other problems PM me since I'm going into University next year for Computer Science and I'm in Grade 12 Programming as of right now.


That's wrong your setLayout does not need to be null i'm however guessing that you are using the border layout I suggest you use the gridlayout will give you much more flexibility


It actually does you doorknob. If you don't put that in then the computer will still set the button to full screen even if you use gridlayout or anything. If you don't believe then fine, but I just created a game for my final project in class and if you don't the button would fit the entire screen.


That's why you declare the z,y values
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.