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
54
votes
9 answers

Showing a Windows form on a secondary monitor?

I'm trying to set a Windows Form on secondary monitor, as follows: private void button1_Click(object sender, EventArgs e) { MatrixView n = new MatrixView(); Screen[] screens = Screen.AllScreens; setFormLocation(n, screens[1]); …
David Hodgson
  • 10,104
  • 17
  • 56
  • 77
36
votes
7 answers

What is setBounds and how do I use it?

I cannot find anything on setBounds, what it is for, or what its function actually is. Could someone clear me up on this? Thanks so much!
JeremyF
  • 735
  • 3
  • 10
  • 19
12
votes
3 answers

How to dynamically add JLabels to JPanel?

I'm having a problem with this. I have a JPanel and normally I would create a JLabel like this: JLabel lblNewLabel = new JLabel("New label"); lblNewLabel.setBounds(0, 0, 135, 14); panel.add(lblNewLabel); but I want each time I click a button, in…
martin
  • 1,007
  • 2
  • 16
  • 32
7
votes
1 answer

Why does TForm.SetBounds only work correctly when TForm.Position is set to poDefault at design time

I have noticed something very strange. I am persisting the top, left, width, and height properties of a form when it is closing, and using this information to restore the form's last position when it is once again opened by calling SetBounds using…
Cary Jensen
  • 3,751
  • 3
  • 32
  • 55
6
votes
3 answers

setbounds on google maps api v3

I'm trying to set the bounds of a map fitbounds doesnt work because it puts some space around the bounds therefore doing {{{map.fitBounds(map.getBounds())}}} a few times will quickly zoom the map out I need to be able to…
msaspence
  • 1,424
  • 2
  • 14
  • 25
4
votes
0 answers

setBounds image width 100%

Can I setBounds the full width photos the textView sorry i cant good speak English my code : public class ImageGetter implements Html.ImageGetter { @Override public Drawable getDrawable(String source) { Drawable drawable =…
2
votes
1 answer

How do I do boundCenterBottom with setBounds in android?

I'm making an app that sets a pin down on a certain location. I would like the location to be at the bottom center of the image. I'm using the setBounds method to create the bound but I'm not sure how to make it "boundCenterBottom" …
Sean Pan
  • 493
  • 2
  • 6
  • 21
2
votes
1 answer

Why null layouts and absolute positions are bad practice in Swing?

I have code with null panel: JPanel thePanel = new JPanel(); thePanel.setLayout(null); I used setBounds(x, y, width, heigth), for example here: label2.setBounds(150, 220, 459, 311); I read that this is not a good practice, can you tell me why? Is…
Persantarus
  • 37
  • 1
  • 6
2
votes
0 answers

set bounds not resizing correctly

I created a custom view and set the background to a XML drawable shape. The goal is when the user clicks on the view it increases in size, however setBounds(0, 0, width * 2, height * 2) increases the size, but cuts off some of the new view and it…
Derek Dawson
  • 502
  • 5
  • 14
2
votes
2 answers

Java setBounds() method (JFrame)

Hi Im using the setBounds method to open a window whith a certain size. But the size that I pass in the argument is the size of the window including the bars of the frame. How can I set the dimensions only for the content?
Pablo Ajo
  • 43
  • 1
  • 4
2
votes
1 answer

Using setBounds or setLocation on JTextArea isn't working

I am adding a JTextArea to my JPanel with this code: commentTextArea.setLineWrap(true); commentTextArea.setWrapStyleWord(true); commentTextArea.setVisible(true); this.add(commentTextArea); commentTextArea.setBounds(0, 0, 100,…
Harry
  • 772
  • 10
  • 32
2
votes
1 answer

JTextArea position, setBounds does not work?

I want a JTextArea in a certain position. I tried several things like using different LayoutManagers, no LayoutManager at all, setLayout(null) etc. Whatever I do, it seems like setBounds(), setLocation() and setSize() aren't working here, but I read…
mcCat
  • 120
  • 2
  • 13
2
votes
2 answers

Changing the Bounds of a Swing GUI and Naming of the JButtons

I know how to set the the bounds, so in the end a new setbounds() call would give the new bounds, but I dont know how long/wide should the new bound be, it depends on the input number of buttons like here for example : import…
Anarkie
  • 657
  • 3
  • 19
  • 46
1
vote
1 answer

How do I modify the setBounds method for JComponents?

I wish to create a certain method that can help speed me up in GUI design. I take longest in using setBounds. Now, I would just go for FlowLayout or GridLayout but I don't like being to reliant on those. Basically, I am thinking of a method like…
ArcIX
  • 35
  • 4
1
vote
1 answer

Is it possible to set bounds for the view before it is shown

-(void)CallingView2{ SettingsViewController *aSettingsView = [[SettingsViewController alloc] initWithNibName:@"Settings" bundle:nil]; [self setSettingsViewController:aSettingsView]; [aSettingsView release]; [UIView…
Spire
  • 1,055
  • 2
  • 17
  • 47
1
2 3 4 5