Questions tagged [setbounds]

In `Java`, `setBounds()` is a method that resizes swing components

In Java, setBounds() is a method that resizes swing components with the syntax (x-dimension, y-dimension, width of component, height of component). setBounds() is a hybrid of setSize() and setLocation(). The (x,y) location is relative to the parent of the component.

75 questions
0
votes
1 answer

.setBounds() not working with nested JLabels

I'm making a Chess-like game in Java Swing (I know Swing isn't the proper way to go about it but I want to attempt it nevertheless) I am having a problem with making the chess pieces show up on the display at the proper paces. Due to the nature of…
user13086011
0
votes
1 answer

Updating location of JPanel

im currently working on a game in Java and a problem occured. It is a strategy game. My game area or map is a JPanel, which i put in a JScrollPane, allowing you to scroll around the map. I put other JPanels on the map, for example a bar for info…
Random
  • 1
0
votes
0 answers

Why am I required to call setBounds twice for it to work

As part of an application I'm writing, I resize and move a picture of a pallet in a JLabel. Because the JLabel is in a JLayeredPane, I'm not using a layout manager, and as a result, ever time I resize the palletLabel's icon I use setBounds() to…
Sam Hilton
  • 30
  • 6
0
votes
1 answer

How to repaint Image after changing?

I have a JPanel, in which I have a JLabel, which contains an Image, like this: JLabel imageLabel = new JLabel(new ImageIcon(image)); after that, I set the bounds of the imageLabel, like this: //I want the Image to be in the middle of the…
user8491933
0
votes
0 answers

java Jtextfield not appears what is wrong?

I have a frame with some JTextFields but when I execute this not appears I have a frame with some JTextFields but when I execute this not appears I have a frame with some JTextFields but when I execute this not appears I have a frame with some…
0
votes
2 answers

Creating a GUI using setBounds()

I read that it is bad to use the setBounds() command for creating GUIs. I know how to use Layout Managers and I have to say that they also have their disadvantages. I'm programming a Game at the Moment and sometimes I need to stack Components…
DevEmil
  • 27
  • 8
0
votes
0 answers

Create Boundary for a Control Resize

I am creating a label control that allows resizing from the top and bottom of the label. It also only slides vertically when moved. I created the boundaries for its movement and for the bottom part of the resizable label, but I'm having trouble…
MBasic
  • 23
  • 6
0
votes
3 answers

Java swing GUI absolute positioning

I know that absolute positioning is not recommended, but I need to show my labels randomly scattered as well as randomly changing their positions. I have researched how to use setBounds but it doesn't seem to work. The following code shows the…
MNS
  • 45
  • 2
  • 2
  • 8
0
votes
1 answer

angular ng-Map setBounds to adjust with circle radius

I am using ngMaps in Angular. I have created a map and included a shape (circle) that can be adjusted depending on my radius value. Is it possible to set the bounds of the map to adjust to include the entire circle? Here is my view:
Sachin Karia
  • 547
  • 2
  • 8
  • 22
0
votes
1 answer

setBounds value for width that will set width to minimum?

Is there a value that can be put into setBounds to set the width to the minimum needed? JLabel title = new JLabel("Title Text"); title.setBounds(50, 20, ?, 13); Rather than using guess & check to find the minimum width, is there a value I can use?
jzbakos
  • 285
  • 1
  • 3
  • 12
0
votes
1 answer

JScrollPane used so I can't set bounds of other JComponents

There's a simple application that uses JScrollPane for 2 lists and have 1 button to switch them. I want to add many more Swing elements, but I cannot move them with object.setBounds. Whatever I will write in this method element doesn't change its…
0
votes
1 answer

using setbounds un java

I have this exercise in my textbook: In this exercise, you will explore a simple way of visualizing a Rectangle object. The setBounds method of the JFrame class moves a frame window to a given rectangle. Complete the following program to visually…
0
votes
1 answer

How to pause the process in case of setBounds

I want to show movement of label for a while on pressing of button. Please help. Just tell me how I pause the process for a while during the changing of setBounds, in this case sleep method pauses the process but just last setBound statement…
0
votes
2 answers

Scrollbar JTextarea not working

For some reason my scrollbar is appearing but it is not working. What is suppose to happen is using the scrollbar to scroll through the text of the textarea. Can somebody please explain why this isnt working? import java.io.*; import…
0
votes
0 answers

Auto scaling components with Java JFrame

I'm coding on Java with visualswing4eclipse. My environmentis Eclipse IDE Version: Luna Service Release 2 (4.4.2). I'm trying to write a function, which auto resize all components inside frame when user change size of window. Here's code: private…
mad357
  • 1
  • 3