Resize « Layout « Java Swing Q&A





1. Retain relative mouse position while resizing a JPanel in a JScrollPane    stackoverflow.com

I'm resizing a JPanel inside of a JScrollPane, and I want to make sure that the point on the JPanel where my mouse is currently located retains its position with respect ...

2. How to "do something" on Swing component resizing?    stackoverflow.com

I've a class which extends JPanel. I overwrote protected void paintComponent(Graphics g). There is a variable which has to be recalculated when the panel's dimensions change. How do I do that ...

3. (SOLVED) GridBagLayout manager and resizing controls    stackoverflow.com

I'm not sure if GridBagLayoutManager is the only layout manager that does this, but here is my problem. I have 4 controls layed out horizontally in a GridBagLayout. To keep things ...

4. Resizing JPanel to prepare for printing without removing it from its original position    stackoverflow.com

In my program I frequently need to print various JComponents (generally JPanels) and I like them to be full-page. The way I do it now is by using the following ...

5. How to have a specific component resize based on available, visible space?    stackoverflow.com

In my application, I have a layout similar to what is shown below: @@@@@@@
XXXXXXX***
XXXXXXX***
XXXXXXX***
%%%%%%% In this layout, X is a JTable. The other components can remain the same size. Is there a layout ...

6. java swing resize    stackoverflow.com

I am writing a library where i am passed in a Container (usually JPanel) and have an xml specification for different controls, their locations, size and other attributes. i have to create ...

7. Java Swing: Do something when a component has *finished* resizing    stackoverflow.com

Apologies for the somewhat unclear question - couldn't think of a better way of putting it. I use a JXTaskPane (from the Swing labs extension API) to display some information. ...

8. Components are not longer resizable after moving    stackoverflow.com

My question relates to swing programming. I want to enlarge a component (component x) by removing it from its parent panel (component a) and adding it in one of component a's ...

9. Forcing a JComponent to be square when being resized    stackoverflow.com

I have a JComponent that does custom drawing, and overrides the following methods:

public Dimension getPreferredSize() {
    return new Dimension(imageWidth, imageHeight);
}

public Dimension getMinimumSize() {
    return new ...





10. Handling user driven resizing, position changes in Java Swing    stackoverflow.com

I'm currently building a Java Swing GUI and I was wondering how user (mouse, say) driven resizing is handled. My problem is that when I try and resize my main window, ...

11. Resize Swing component when content has changed dynamically    stackoverflow.com

I have, the same issue with two components JTextField and JComboBox, I assume the solution I'm looking for would solve it for all components. I have set the size of the components ...

12. Java Swing: Relative Positioning and Automatic Resizing?    stackoverflow.com

I have a createUI() function which loads JPanel into NORTH, SOUTH, EAST.

private void createUI() {
    add(createToolBar(), BorderLayout.NORTH);
    add(createDataView(), BorderLayout.SOUTH);
    add(createHistoryView(), BorderLayout.EAST);

  ...

13. Java Swing: Paint(), doLayout() not synchonised. E.g. The error message is wrong displayed, on window resizing it goes wrong    stackoverflow.com

I work on a UI java application composed from:

  • top header
  • left menu
  • header text
  • error message (displayed on the page's header)
  • center container (JPanel) which is changed dinamically, in dependence of selected menu item (from ...

14. GUI with fluid resizing behaviour    stackoverflow.com

is it possible using swing, to build a GUI whose elements, when the GUI is resized, keep te proportion between themself? Or i should fire a "resize every GUI component" function ...

15. Why is my Java swing application misbehaving?    stackoverflow.com

When I try to maximize the window, the orinigal window rendering remains while another maximized window appears making it messy.


import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import ...

16. JScrollpane resizing with variable-sized content    stackoverflow.com

My resizable JScrollPane's content has a minimum width. If the JScrollPane is smaller than this width, horizontal scroll bars should appear. If it's greater than this width, the viewport content should ...





17. Java: GridLayout calls layoutContainer before resize finished    stackoverflow.com

I have a simple gui with container using the GridLayout Manager. I added two components which inherit from JComponent and paint some stuff on screen using paintComponent. Now i added the componentListener to ...

18. swing question on resize controls on maximize    stackoverflow.com

I have a JFrame with the following layout and components:

 _________________________________________ 
 |  __________________________________    | 
 |  |JTree   |   ...

19. Resizing only one part of the Java Swing components    stackoverflow.com

On my Java Swing application I have two components. On the left side is a navigation (JList) and on the right side is a JTable. I would like to leave the ...

20. how to keep world position constant, when resizing java applet?    stackoverflow.com

first post. Thanks for viewing. I'm building a fairly complex application in Java, with JBox2D (actually, PBox2D, a wrapper for Processing). One component of this Java application is in Processing (PApplet), containing ...

21. how to use setResizable method here    stackoverflow.com

enter image description here I am using netbeans as an IDE. how can i set setResizable(false) on JFrame.I dont see the object of JFrame in netbeans.

22. Programming a GUI with resizable components using Java.swing    stackoverflow.com

I'm supposed to program a GUI. Every component in this GUI has to have the possibility to be resized dynamically. So far I worked with GlassPane and ContentPane, added a JPanel ...

23. Resizing a frame and its components when using NULL Layout    stackoverflow.com

When using null layout, how to resize components? I mean their position and size. I know that using layout managers we need not take care of this issue. But my requirement is to ...

24. Swing Component - disabling resize in layout    stackoverflow.com

I have a custom GUI compomemt, which is based on Swing's JPanel. This component is placed in a JFrame, that uses BorderLayout. When I resize the frame, this component keeps resizing. ...

25. GridBagLayout within JScrollPane not resizing properly    stackoverflow.com

I have a JPanel with a GridBagLayout inside of a JScrollPane. I also have an 'add' button within the JPanel which, when clicked, will be removed from the JPanel, adds a ...

26. How to overlay, resize and centre a component on a JPanel?    stackoverflow.com

I've spent a while reading and experimenting here, and come up with a few approaches, but not got any of them to work completely yet, so I would like to know ...

27. How to make a swing component's bounds fixed    stackoverflow.com

I have a JPanel to which I have added a few components (checkbox, combo etc.). I have noticed that, when the frame is maximized, the bounds of components also move or ...

28. GUI builder -- keeping components centered during resize    forums.netbeans.org

I'm working on becoming with familiar with the GUI builder, and I have a question: what would be the best approach to creating a layout with a pair of buttons that ...

29. Resizing problem in Gui Builder.    forums.netbeans.org

Hello, I am building a gui with the Gui Builder and over the time I have been working on it, the height of the gui grew without me setting any parameters. Now it is high that I need to scroll if I want to see the statusbar. If I simply grab the edges they just spring back. If I try this ...

30. GridBagLayout update without resize    coderanch.com

In gridBagLayout, components are adjusted according to their weights when the container is resized. I have a situation where I need the container to be updated with new weights without resizing the container. can this be done? Do I have to send a resize message to the container? If so, how is this done? TIA, Jeff

31. Resizing components    coderanch.com

32. swing components resizing    coderanch.com

33. resizing swing components    coderanch.com

34. Help Needed For Resizing of Swing Comp    coderanch.com

Hi All! Can anybody help me out.......................I'm facing problems in scaling some components through code in runtime. Prob. 1: I am increasing the size and font of a JComboBox in Runtime. if i click on ComboBox, in the drop down all items are of smaller fond and as soon as i select an item, after getting selected it gets bigger. How ...

35. Resizing    coderanch.com

36. resize ?    coderanch.com

38. Bean Resizing problem    coderanch.com

Hi I've designed a bean inside an applet overriding the ComponentResized event for both the bean and the applet. During run time, when I drag the bean all its components gets resized properly, but when I use the maximise buttons, the bean components(the bean has a JTable, 2 JButtons and a JScrollPane) and the applet components(2 JButtons) don't function properly. Here ...

39. How do I do resizing of a bean dynamically ?!!    coderanch.com

Hi I have a bean and I've added the bean to the Visual Cafe component library which means that I can drag and drop the bean like any other swing components such as buttons, labels etc. So, when I specify the properties of the bean in the property list, the bean should resize accordingly.But, when I try this, the bean is ...

40. making resizable components?    coderanch.com

41. how to resize and always have the same proportions?    coderanch.com

Hi Angela, I don't think you can affect the way a user resizes the window. All you can do is to resize it correctly after they are done shrinking or stretching it. You setup a component listener and override the componentResized method. Regards, Manfred. [This message has been edited by Manfred Leonhardt (edited December 07, 2001).]

42. Very Interesting. Resize versus Maximize    coderanch.com

Hi Folks, I have a list of JInternalFrames. Only one is visible at a time. In the componentResized event listener, if the visible JInternalFrame is resized, i resize all the other JInternalFrames in the list. And when i hide the current one and show the other, it shows up with the new size(It doesn't trigger a new ComponentResized event). All is ...

43. How to resize the component    coderanch.com

44. How to resize in border layout?    coderanch.com

45. Resize JTabel    coderanch.com

46. Resize Problem    coderanch.com

Hello Geeks, I am currently working on an application which needs to have a customizable display area. Consider the display area to have four ports as shown below: _ _ |_|_| |_|_| Now each of the ports shud be resizable by dragging a mouse on any of the vertical/horiztonal lines. So any of the ports can be resized by dragging its ...

47. Resize Problem    coderanch.com

48. Component resizing    coderanch.com

Hello, I am writting a stock controlling program.In that, I am doing some thing like this. When the user selects an item code from a combo box the measuring type(Quantity type) is taken from a databasedandplaced in a combo box. The problem is depending on the values it gets as quantity type the size of the combo box resizes. I am ...

49. hwo to resize line    coderanch.com

i had draw line on the view(mvc str) and when i resize the line by mouse public void mothname(Point last) { line.x2 = last.x - position.x; line.y2 = last.y - position.y; }//this position is the line's position if i resize the end_point the application is right but when i resize the start_point the line not get the right resize the start ...

50. how to resize    coderanch.com

51. Component resize. What is best?    coderanch.com

52. resize    coderanch.com

53. Resizing swing components    coderanch.com

54. Scaling on resize    coderanch.com

Hi there, I have jInternalFrame with jTable and two jPanels on it, with various components on these. My goal is to scale the components instead of letting them get cropped when the window is resized, everything must be displayed at all times even if unreadable! This is causeing me major headaches! Pleas help if you can.

55. Resize TitleBorder    coderanch.com

56. GridBagLayout in panels - resize causes bunching up..    coderanch.com

Hey guys, Relatively new to Swing coding. I have an applicaiton with many panels, all using grid bags.. (I found it the easiest one to get things into the places i want them to be in). Everything looks nice when there is enough space, but when i crop the window to some very small size, instead of just not being able ...

57. resizing without using gridbaglayout    coderanch.com

hey guys we've been using gridbaglayout in class now for quite sometime now, and everyone including the professor thinks its overly complicated. I have now one question. When using gridbaglayout its possible to set the variables to let specific panels stretch horizontally and vertically. Is it possible to do this without using gridbagLayout. My professor sais it is, but that its ...

58. KTable resizing    coderanch.com

Hi guys, I currently have KTables (SWT) working on an eclipse rcp. The only problem is that I cannot get the height of the table to increase. It only shows the 1st 3 rows. If anyone could help, It would be greatly appreciated table = new KTable(container, SWT.SINGLE | SWTX.FILL_WITH_DUMMYCOL| SWTX.AUTO_SCROLL | SWTX.FILL_WITH_LASTCOL | SWTX.EDIT_ON_KEY); //create Column models int columns = ...

59. GridBagLayout squishes components on resize    coderanch.com

Hi Guys : Im using GridBagLayout to layout 5 components. Im not trying to do anything fancy... All the components being added below are scrollpanes with Jtables inside. When I have a maximized window, the layout is fine, but my problem is that if I resize the window, all the components get squished together in a really small area in the ...

60. Resizing DefaultTreeCellRenderer    coderanch.com

the ... seems to work OK like this import java.awt.*; import javax.swing.*; import javax.swing.tree.*; class Testing { public void buildGUI() { JTree tree = new JTree(); JScrollPane sp = new JScrollPane(tree); tree.setCellRenderer(new DefaultTreeCellRenderer(){ public Component getTreeCellRendererComponent(JTree tree,Object value, boolean sel,boolean expanded,boolean leaf,int row,boolean hasFocus){ JLabel label = (JLabel)super.getTreeCellRendererComponent(tree,value, sel,expanded,leaf,row,hasFocus); label.setPreferredSize(new Dimension(40,15)); return label; } }); JFrame f = new JFrame(); f.getContentPane().add(sp); ...

61. GridBagLayout resize issue    coderanch.com

Hello, Im trying to left-orient a JLabel and JList in a GridBagLayout panel thats in a split pane. I'm using a GridBagLayout because I'm trying to left orient everything in the panel...I tried to use a BoxLayout but everything was center-oriented, the only way I found to get the Label to become left-oriented in the pane was to increase the size ...

62. Resize width only?    coderanch.com

63. Resizing Layout with change in Screen Resolution    coderanch.com

Hi all, I am programming a Swing application. The entire gui of the application is divided into 9 equal sized panels arranged in 3 rows and 3 columns. Now some panels have tabbed panes and some have some buttons (JButtons). Now the screen resolution of my laptop is 1280x800 pixels. I am using layout managers to layout these panels and the ...

64. Need Help, can only show the composite when resize the view manually    coderanch.com

Hi all, I am writing an eclipse plugin that extend the View extension point to create my own view. I can' t use JFace for my view so i have to work directly with SWt using the parent Composite given in parameter of the CreatePartControl method invoked when the user click on Windows -> Show View -> My Own View. When ...

65. Reg:Component Resize    coderanch.com

Heres the code which i used for arranging the components. this is actually very easy to arrange components. Easier than the layouts like grouplayout and gridbag layout. the only problem i face is the resizing of the components. panel4.setLayout(null); tname = new JLabel("Task Name"); tname.setForeground(Color.BLUE); tname.setBounds(10,10,80,20); tnametf = new JTextField(25); tnametf.setBounds(90,10,250,20); taskl = new JLabel("Enter Date"); taskl.setForeground(Color.BLUE); taskl.setBounds(10,50,80,20); tasktf = new ...

68. resizing an icon in gridlayout    coderanch.com

So what do you expect? Suppose you have a 2x2 grid: did you expect the top left cell (let's say) to be bigger than the others? Then it wouldn't be a grid, would it? A more reasonable expectation (remember, I don't know what you expect) would be for the layout manager to scale the icon down to fit in the box. ...

69. add(lable) doesnt show till i resize    coderanch.com

im trying to move my debugging output from system.out.println() to the frame i made with the awt that already has some buttons and things in it. so every time i do something, im trying to do this.add(label) to tell me that what i expect is being done is being done. but when i add lables, they dont show up until i ...

70. Resizable swing elements    coderanch.com

Kevin's links will help you, of that I've no doubt. If after reading them you're still stuck, please come on back and show us what you've tried, describe to us what is not working and how it's not working, provide pictures if necessary, and let's see if we can help you get this thing off the ground. Best of luck!

71. Help with GridBagLayout resize behaviour    coderanch.com

If I set the look and feel to the default Metal and include this line, it does respect the minumum sizes. However it makes the frame take the Metal look, as well as the whole GUI, so it's not really a solution. The line doesn't have any effect with Nimbus either either (frame is as per System look and feel).

72. Resize components inside a JPane when using Null Layout    coderanch.com

Hi All, I am using Null Layout. Reason, I should be able to move the components anywhere on the screen. I also have features like resizing the component once its added to the frame and deleting them if user prefers to. Basically the component I am talking here is a JLabel with an image icon set on it. I realize that ...

73. GridBagLayout Resizing    java-forums.org

I've just started learning about GridBagLayout. I'm in the processes of turning a GridLayout gui into a GridBagLayout GUI. Everything works great. My only hiccup is that whenever items get removed or added, the Layout resizes itself. All I want is for the columns and rows to be equal height and width always, regardless of the size of components. I've tried ...

74. gridbaglayout does not resize with the window    java-forums.org

No, for every component weight x and y are set to 0.0. Here is the initComponents autogenerated code: Java Code: /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // ...

75. GUI resize issue    java-forums.org

Hi, I am trying to make it so my JFrame's size cannot be changed. It needs to be 700 X 450 always. I want to make it so the user cannot maximize or scretch the frame in any way. I thought just the min and max size to those would do it, but when I used frame.setMaximumSize and frame.setMinimumSize, they did ...

77. Resizing swing GUI    java-forums.org

78. NetBeans Simple GUI resizing    forums.oracle.com

My steps; (using Netbeans) 1) Create a single JFrame within a single Class 2) Set the Layout; Absolute (or Freemode FreeDesign) of the current Frame Layout 3) Drag n drop all of the components into d stage 4) I confused... should I put the components of the Down side at once? (refer to the image previously) If no need to put ...

79. Layout resize in Swing    forums.oracle.com

Hello all I have a my GUI for my app.. and the issue is that once i get all my components the way i want them to be displayed, when i maximize the window, the whole thing turns into a mess. i've read about the Spring layout but i dont see that among the options in the netbeans layout list. Is ...

80. GUI Resizing Issues    forums.oracle.com

Thanks! Adding it to BorderLayout.CENTER did the trick, it now resizes the text area. If I don't set a preferred size, it makes the entire thing span both my monitors, and makes it virtually unusable. When you said set the preferred size on the panel, which panel were you talking about? Also, when I expand the window, the Genre and Rating ...

81. layout manager doesn't resize controls when I hide a JPanel in applet    forums.oracle.com

//Initialize the applet public void init() { try { var0 = this.getParameter("param0", ""); } catch(Exception e) { e.printStackTrace(); } try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } boolean kvmCaptured = false; Vector driveList = new Vector(); Color pressedColor = new Color(128, 255, 128); Color pressedColorFont = new Color(0, 210, 0); Color upColor = UIManager.getColor("Button.background"); JPanel contentPane = new JPanel(); ...