Resize « JFrame « Java Swing Q&A





1. Can I set a window in Java so it has uniform resizing (ie. a square)?    stackoverflow.com

I've seen several applications window's only allow the user to resize it in the diagonal direction, so it must maintain its square shape. Is it possible to specify this constrain using swing/java? ...

2. Resizing a JFrame    stackoverflow.com

Ok, this will be rather noobish - I'm making a GUI with the Eclipse Visual Editor (a JFrame with stuff in it), basically on the left side there are some buttons ...

3. Java resizing my splitter frame    stackoverflow.com

I have a jDialog with a splitter inside it. One side has a tree while the other side has a frame. Whenever I use setVisible(false) to hide the frame, the splitter resizes ...

4. JFrame resizable height ONLY    stackoverflow.com

JFrame.setResizable(true) lets the user resize both the width and height of a window. Does a method exist which allows the user to ONLY resize the height? Thanks. Edit: The solutions below do NOT ...

5. java scaling of a jframe    stackoverflow.com

Is it possible to create a JFrame and setResizeable(true), but have the x and y values scale by the same amount, i.e. you cannot increase just the x or y but ...

6. J frame resizing in an aspect ratio    stackoverflow.com

Hey there. I've made a game using a jframe with componenets. Is there a way that I can make the JFrame bigger but using a square aspect so that the length ...

7. I have to resize my JFrame for the contents to show up. How can i fix that?    stackoverflow.com

When I run my gui, I have to resize the window for everything to show up. Does someone know what the problem is?

8. Unexpandable Window    stackoverflow.com

While using JFrame, is it possible to have the window unable to be expanded by the user?

9. JFrame resize question    stackoverflow.com

So I am trying to create a JFrame that will resize to a width and height based off a certain fixed value. i.e. when you use the mouse to change the size of ...





10. resize a window bases on the text content    stackoverflow.com

I want to be able to Enter Text that will appear on the window and then if I were to re-size the window then the text could change with its size. ...

11. Java slow 2D performance - Resizing    stackoverflow.com

I am using Windows 7 with Aero, and have a very fast graphics card (Radeon 6870) that I use for gaming. I have some issues when resizing very simple programs I make ...

12. How can I resize and paintComponent inside a frame    stackoverflow.com

Write a program that fills the window with a larrge ellipse. The ellipse shoud touch the window boundaries, even if the window is resized. I have the following code:

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import ...

13. JFrame resize causes a flickering    stackoverflow.com

I'm writing a simply java interface using javax swing on Mac OS. My target is obtain a JFrame with two buttons that give users the possibility to switch between two JPanels ...

14. Proportional resizing of JFrame    stackoverflow.com

I'm trying to make a JFrame re-sizable in an unusual way: the ratio of width to height of the frame must be constant. I have written this simple code; in this ...

15. Prevent Window resizing on Java (Netbeans)    stackoverflow.com

im using Netbeans 7 for make a desktop application. But i can't find how to disable Window Resizing or Maximizing in the Gui Builder!, someone can help me?

16. JFrame resizing problem    forums.netbeans.org

hi, i have developed a gui using netbeans gui designer, having textarea, buttons,etc. and it's working fine ,but the problem comes when i maximise the frame, ie. the elements are not resized accordingly. the layout i am using is free design . please could someone help me on this. Thanks .





17. Problem in resizing JFrame    forums.netbeans.org

hi, i have designed a gui in netbeans 6.8 gui designer, all seems to work well but the problem comes when i try to resize the frame. The elements should adjust themselves but it's not happenning.How should i overcome this problem?

18. How to avoid Resizing a JFrame.    forums.netbeans.org

I have written a Java Desktop Application in NetBeans. I want to avoid resizing the main GUI window.For that, I tried: MyApp.getApplication().getMainFrame().setResizable(false); in the main Class' constructor. But this did not work. Please help ASAP. Thank You in advance.

19. Cannot resize a JFrame from the UI    forums.netbeans.org

I have created a Java Desktop Application through the wizard, and, noted that although I am resizing the frame from the UI to fit the requirements that I design, when I run the application it still appears to hold some "standard size". Is this a bug? How do I go about it? NOTE: Submitting a bug to NetBeans is a bit ...

20. Why is the GUI Builder resizing my JFrame?    forums.netbeans.org

I designed a JFrame containing text entry areas and buttons, and I modified it several times. Now, it has too much empty space on the right side. So, I tried to drag the edge of it to the left, to reduce the empty space When I do this, the JFrame goes back to the original size when I release the mouse ...

21. preventing resizing of frames    coderanch.com

22. window resizing in JFrame    coderanch.com

23. Resizing my frame    coderanch.com

24. Frame resizing    coderanch.com

I have a frame which contains some text components, which takes in values and validates (a database connection). After validations a different set of components has to be displayed with the window size maximized. I could do everything except the maximizing part. The frame remains the same size with the new contents in it. How can i do this? I tried ...

25. visualising the contents of the frame without resizing[urgent]    coderanch.com

hi Netharam, call setSize()/setVisible/pack() after laying out the components. I think I read once about something like: the components are actually layed out when calling one of these methods. on second thought: why calling setSize() etc. in your code anyway, your extending JFrame. it's not the task of the JFrame to set its own size or visibility (consider the JFrame API!). ...

26. no resize for JFrame    coderanch.com

27. How to a frame with no ability to resize the content pane    coderanch.com

Magic Draw the uml java tool has a main frame which consists of a menu bar and tool bars. There are no panels or container in the content pane. In addition, the content pane cannot be resized. if you attempt to drag the bottom edge of the frame down the page, when you release it, the panel snaps back like a ...

28. Resizing a frame    coderanch.com

29. resizing window scrollpanes    coderanch.com

30. Resizing JFrame with ChangeListener    coderanch.com

I don't know about all the processing you're doing in response to the change event, but you might try using SwingUtilities.invokeLater() to do your frame resize and see if that helps. Are you sure you want to change the size of the window when the user clicks a tab? Sounds like it be could annoying to the user. [ June 11, ...

31. Resizing a frame    coderanch.com

32. window resizing    coderanch.com

I am creating a GUI application using Java and Swing. The GUI portion of the application consists of two panels, one above the other. The frame is given a border layout so that the top panel can be placed in the NORTH section and the bottom panel can be placed in the WEST section. The top panel contains a text field ...

33. Resizing Widgets in Frame    coderanch.com

34. How to resize JFrame programmatically?    coderanch.com

works OK, doing it this way import java.awt.*; import javax.swing.*; import java.awt.event.*; class Testing extends JFrame { JPanel panel1 = new JPanel(); JPanel panel2 = new JPanel(); JSplitPane spt = new JSplitPane(JSplitPane.VERTICAL_SPLIT,panel1,null); JToggleButton btn = new JToggleButton("Show/Hide panel2"); public Testing() { setLocation(400,300); setDefaultCloseOperation(EXIT_ON_CLOSE); panel1.setPreferredSize(new Dimension(100,100)); panel2.setPreferredSize(new Dimension(100,100)); panel1.add(new JLabel("Panel 1")); panel2.add(new JTextField("Panel 2")); getContentPane().add(spt,BorderLayout.CENTER); getContentPane().add(btn,BorderLayout.SOUTH); pack(); btn.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ...

35. Frame resizing    coderanch.com

hi, i developed a chatting application.. i want to know three things in the Frame Resizing. 1. i tried to restrict the user cann't resize the frame less than (300,600) by setPreferedSize(). it works. but the user can resize upto 0,0 .. when the user leave the mouse button for resize, then it comes to the preferedsize. i want to restrict ...

36. JFrame resize    coderanch.com

Originally posted by Michael Dunn: call your getWidth() getHeight() after setting the frame's visibility to true I was going to suggest that but wanted to do a bit more research on when the size actually gets set. It seems odd to me that setting the frame visible is when that happens. To me it makes more sense for it to be ...

37. resize window distorts view    coderanch.com

I am assuming that you use a GridBag Layout and trying to resize the Window. Most other layouts are simple and have pre-designed UI behaviour. The widgets are getting distorted because they themselves are getting resized. A text field can only shrink so much without losing its form. The things to consider are the spacing between UI controls, weights etc to ...

38. JFrame is flickering while resizing.....    coderanch.com

I have had rather similar problems before, but with a different sort of app. The Java tutorial has a "common problems" page, so I looked there. I tried things to speed up processing, as suggested in the tutorial, including changing all my doubles to floats. I tried opacifying the content pane, but still had problems. I tracked it down to a ...

39. Change JFrame content pane without window resizing    coderanch.com

can you post a sample program, similar to below, showing the problem. simple demo from your description, seems to work OK import javax.swing.*; import java.awt.*; import java.awt.event.*; class Testing { public void buildGUI() { JPanel p = new JPanel(new BorderLayout()); final JScrollPane sp = new JScrollPane(new JTextArea("Hello World",10,10)); JButton btn = new JButton("Change scrollPane"); p.add(sp,BorderLayout.CENTER); p.add(btn,BorderLayout.SOUTH); JFrame f = new JFrame(); ...

40. don't want to resize my frame    coderanch.com

41. Implementing Window Resizing    coderanch.com

Good Afternoon all, I've been diving into the wealth of components offered in the SwingX releases (0.9.2), and I've been implementing the very cool JXStatusBar component in an application. On Windows platforms (XP, at least), it provides the graphic of a resize "gripper". It does not, however, provide the functionality to actually mouse-over, change cursor icon, and click-and-hold to resize the ...

42. JFrame resize problem    coderanch.com

// Get the original dimensions of this window when the JFrame initializes : int originalHeight = this.getHeight(); int originalWidth = this.getWidth(); private void frameResized(java.awt.event.ComponentEvent e) { int newHeight = e.getComponent().getHeight(); int newWidth = e.getComponent().getWidth(); int diffHeight = newHeight - originalHeight; int diffWidth = newWidth - originalWidth; button1.setLocation( button1.getX() + diffWidth, button1.getY() + diffHeight ); originalHeight = newHeight; originalWidth = newWidth; } ...

43. Resize JFrame    coderanch.com

44. Resizing JFrame    coderanch.com

45. JFrame Resizing    coderanch.com

46. Resizing JFrame    coderanch.com

47. Problem with JEditor Pane while resizing the frame    coderanch.com

Hi , i am new to java GUI programming. i am adding a JEditor pane (with HTML text ) inside a JScrollPane and added the scroll pane to a JFrame.The problem is when i re size the frame the JEditor pane vanishes. Any one help me ? Following is the code : public class GridBagWithJEditorPane extends javax.swing.JFrame { public GridBagWithJEditorPane() { ...

48. Auto Resizing problem with JFrame    coderanch.com

ArrPtr = 1; int nSize = 20; // minimum size if no attendees while (ArrPtr < 6) // max is 6 people displayed at a time, JScrollPane does the rest { if (ArrPtr > nCtPR) // nCtPR is number of attendees in class ArrPtr = 6; else nSize = nSize + 60; // size of each display entry ArrPtr++; } int ...

49. restrictions on resizing JFrame    coderanch.com

> what i want to know is, how can i restrict the frame from resizing when it reaches 800 x 600? presume you mean resize smaller the only way I've seen possible do do what you want is to add this line (prior to creating the frame) JFrame.setDefaultLookAndFeelDecorated(true); then frame.setMinimumSize(new Dimension(800,600)); problem is java's default L&F is not the best looking. ...

50. JFrame resizing -- what is normal behavior?    coderanch.com

Hi, If I instantiate a JFrame that is about 60% of the screen and do nothing else, the content pane is nothing more than the CENTER of a BorderLayout set to default background color. Now, if I QUICKLY resize the window, I can observe black areas which are then filled with background color as appropriate. If I add more items to ...

51. image scaling on window resize    coderanch.com

52. frame resize    coderanch.com

53. Resize JFrame to fit image    coderanch.com

import java.awt.Graphics; import java.awt.Image; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JPanel; public class ImageTest extends JPanel{ @Override public void paintComponent(Graphics g){ Image image = new ImageIcon("can.jpg").getImage(); g.drawImage(image, 0, 0, this); } public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ImageTest it = new ImageTest(); frame.add(it); frame.pack(); frame.setVisible(true); } }

54. Resizing window erases content of Graphics2d    coderanch.com

Maneesh Godbole wrote:Most probably you are missing the call to super.paintComponent() If that doesn't fix the problem post your SSCCE code like Campbell suggested. public class GMI_JFrame extends javax.swing.JFrame { /** Creates new form GMI_JFrame */ public GMI_JFrame() { initComponents(); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this ...

55. Jframe , on resize throws exception    coderanch.com

Hi On reszie of jframe i.e. my masterframe , throws the following exception and main components ( jtable inside the jframe ) does not resize anymore and i get the following messages. Please give me clue , to look for a solution Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 0 >= 0 at java.util.Vector.elementAt(Unknown Source) at javax.swing.DefaultComboBoxModel.getElementAt(Unknown Source) at javax.swing.plaf.basic.BasicComboBoxUI.getDisplaySize(Unknown Source) at javax.swing.plaf.metal.MetalComboBoxUI.getMinimumSize(Unknown ...

56. JFrame resizing problem    java-forums.org

I've made a couple games in Java using Swing/AWT, using the following method: Use a JComponent (not a subclass) to draw graphics to. Call the add() method of the JFrame's content pane to add my JComponent. Create a loop for game math and repaint(), etc. The only problem is, I can't call the JFrame's pack() method, even when I call setPreferredSize(), ...

57. Window Resizing issue    java-forums.org

58. Resize frame    java-forums.org

Hi, For a program we have to have a frame, with a JComponent inside it, and then a few objects drawn on it. All of which is no problem but the last thing that is needed, is when the entire frame is resized, all of the pieces inside it need to stretch out as well. This is where my problem is, ...

59. JFrame resize control    java-forums.org

Hi I want to have a control over the user resize in a JFrame. For example i want width will always 300 pixel higher than height. I try this code : Java Code: public class Test extends JFrame { private static final long serialVersionUID = 1L; private JPanel jContentPane = null; private static int con = 300; /** * This is ...

60. resize image in java form    java-forums.org

61. JFrame resizing question    java-forums.org

62. JFrame resizing    java-forums.org

63. Resizing a JFrame?    forums.oracle.com

Which still doesn't really resize the frame, does it? It centers it and makes the textArea take up pretty much all the available room, and adds a scrollbar and all that stuff, but doesn't actually change the size of the JFrame at all. You're still stuck with whatever you set the size of the JFrame to. The amount of text involved ...

64. resizing a Jframe    forums.oracle.com

In GameDisplay constructor you call super() which invokes JPanel's default constructor which initializes the panel to use FlowLayout as it's layout manager. If you want to use absolute positioning you can try calling super(null) instead, effectively using no layout manager. This however forces you to position all components on that panel absolutely.

65. Having to resize a JFrame    forums.oracle.com

66. Resizing elements on JFrames.    forums.oracle.com

67. Resizing elements on JFrames.    forums.oracle.com

68. resize with jframe?    forums.oracle.com

im still a noob with java programming. Also apparently at asking questions. 1) In the future Swing related questions should be posted in the Swing forum. 2) What is a flag? Did you do custom painting of some kind. Did you display an image of a flag? What component did you use. We are not mind readers, we can't guess what ...

70. Swing GUI isn't showing up properly without resizing window    forums.oracle.com

I am developing a Java GUI with Swing. I have not used any paintComponents or paint commands for anything - all Swing. Every time I run the code, I get the JFrame to come up, but all I can see is the background. Only after I resize the window (manually, with the mouse) do I see the boxes and JComboBox, etc. ...

71. JFrame Netbeans & resizing    forums.oracle.com

So, I am using Netbeans to create a simple game, I am not familiar with coding layouts by hand which is where I am having a problem. The first level of the game has a grid of cards with dimensions 4 x 4. Level two has a grid of cards with dimensions 4 X 8. There is a container on the ...

72. Netbeans wont allow JFrame resize    forums.oracle.com

Hi Guys, I have just started using Netbeans 6.1 and am new to the netbeans environment for Java. I have been writing a simple GUI and it has been working fine until now. The GUI displays a JFrame which consists of a few panels, etc and some painted components. All was fine until today when I modified one of the panels ...

73. java frame resize in GUI    forums.oracle.com

how about re-pack(); the jframe? In fact, I don't see that you call pack() once? Or maybe I'm missing it. Also, rather than setSize(), should you use setPreferredSize()? Message was edited by: petes1234 Nevermind,... This is not what you are looking for. There is an event (windowevent?) that you must look for (I think) and adjust size accordingly. Message was edited ...

74. JFrame resize    forums.oracle.com

My question is: Is there a way to only define my public void componentResized(ComponentEvent e){} method without define the other ones: public void componentHidden(ComponentEvent e) {} public void componentShown(ComponentEvent e) {} public void componentMoved(ComponentEvent e) {} I do an implment of the ComponentListener class and i know I must "implement" all his methods, but i think (i am not sure if ...

75. JFrame and composants resize    forums.oracle.com

76. Restrict resizing of jframe.    forums.oracle.com

77. JFrame resizable ratio    forums.oracle.com

78. JFrame resize restriction    forums.oracle.com

The ComponentResized approach is what I currently have, but I don't like that it allows the users to drag the window larger and then snaps back. I've also tried using a Timer that constantly checks for the size of the frame and resizing if it's been dragged larger, but that causes flickering and also doesn't get rid of the resize cursor ...

79. Jframe resize "sensing"....    forums.oracle.com

I need to be able to resize everything in my jframe according to its height/width. I need to be able to get the w/h at runtime, and if it is changed durring runtime, sense it there too. I have tried searching but all i get is how to resize jframes. Thank you for your help .dok

80. Resizing JFrame Question    forums.oracle.com

are there any event listeners that i can use to check to see if the window has been resized, i want to modify a BufferedImage i have local to an applet in my JFrame by remaking it with the new windows dimensions. anyways, when the window size is modified i want to be able to trigger a method that does this ...

81. Resizing JFrame    forums.oracle.com

I have a JFrame using a border layout and some stuff inside it (a JTabbedPane, a menu, a JToolBar and a home-made status bar). Two questions (may be the same): 1) When dragging the sizing border of the JFrame the controls won't update their size/location until I release the mouse button. Is this default behaviour? How can I resize thechild controls ...