SetSize() doesn't resize inner components

hi!
I have a jframe with toolbars, tabbedpanes etc with initial sizes.
calling setSize(w, h) (after layout is done) to the frame resizes the window, but not inner components, not even the frame.
what's wrong?
thanks!

Layout and sizing in swing take some getting your brain arround. For the most the layout managers ask the child objects what size they want to be by calling a getPrefferedSize() method on the child. setSize on the parent won't influence what size the child is drawn.
What layout managers are you using?

Similar Messages

  • Auto-resizing all components

    Is there a method that auto resizes all components on a JFrame when it is maximised for example. I have got a JTable (in a scrollpane) and some other components on a panel. I have sized the frame to be approx 80% of the screen size. When the frame is maximised, the table and the other components retain their original size (understandably so!). Is there a method available that can resize the panel and its components to resize accordingly when the frame is maximised?...I know I can add the componentListener and implement a method in the componentResized() method...but I dont want to duplicate stuff that's already available. Thanx for your help.

    I don't know the specific needs.
    BorderLayout: simple Layout; Components are oriented NORTH, EAST, SOUTH, WEST
    FlowLayout: all components are added after the other
    GridLayout: components are oriented in a grid
    GridBagLayout: complex once
    See the Java Tutorial for more information.

  • Scaling / Resizing Catalyst Components in Builder

    Hi,
    I'm looking at setting up the proper workflow for a large project. We envision multiple developers and multiple designers on the project.
    The major sticking point now is scaling and resizing the components generated by Catalyst once they're in Builder. One would think that once you've skinned, for example, a scrollbar in Catalyst that you could then resize it in Builder to match different layouts.
    However, as I suspect you already know, the sizes do not change at all in Builder.
    We can get into the source code in builder and add in a bunch of width/height = 100% attributes, but these break down at the point that there are Paths defined in the code. The Path elements would need to be re-coded to scale.
    So, I really have two questions:
    1) What exactly does "Convert to Optimized Graphic" do? Will this recreate all Paths to standard shapes that will scale?
    2) Is there a better system coming in the next Beta? If so, can you describe it a bit?
    Thanks a lot,
    Kirk

    This morning I sat down to use catalyst for the first time. I am preparing for a talk at Flash on The Beach in Brighton this year and I was hoping to be able to show how a view build in Catalyst could be injected into an app using Robotlegs.
    I watched http://tv.adobe.com/watch/adc-presents/create-spark-component-skins-using-flash-catalyst and thought that looked cool.
    I also watched http://tv.adobe.com/watch/flash-catalyst-cs5-feature-tour/sending-your-project-to-a-develo per, and saw the component library output looked awesome.
    So I started to build an interface, first by creating a custom button component (much like the first video) and then distributing those buttons in a completely custom button holder component. It is this button holder that would be injected, and in the holder each button would have an id so that references to them could be obtained after injection into the application.
    From the videos above this looked eminently doable and quite a good workflow. Designer design and layout components that get built into a library, and developers use those components in an application without actually recoding the components.
    This sounded great, but imagine my dissapointment when I discovered
    1) A custom component can not be resized in the design view of Catalyst - you have to create another component class with a different size!
    2) A component/skin developed in Catalyst can not even resize when imported into Flash Builder unless you recode it.
    3) You can't name instances of components in the design view.
    So my plan was completely foiled. I mean, surely a button skin/component can not be considered a button skin/component unless it can be resized!
    I like Flex and I think Flex 4 is a big step forward, however I have never met a designer who liked it. Designers cannot effectively layout applications themselves using Flex. In fact where I work they are pushing to prevent ANY future flex development because of the problems with designers not being able to do this (we make and maintain some very highly skinned Flex 3 applications). I am the only front end Flex developer there and anytime I start to develop in Flex it is seen as very awkward and a problem.
    I hoped that Catalyst would solve some of these problems, but it unfortunately fails dismally because of the above problems that I mentioned.
    These three things would go a long way to improving developer design workflow for Flex and Catalyst. Any ideas for if/when this functionality might be included?

  • [svn] 4806: Fixes for Advanced CSS applying to inner components.

    Revision: 4806
    Author: [email protected]
    Date: 2009-02-02 21:01:18 -0800 (Mon, 02 Feb 2009)
    Log Message:
    Fixes for Advanced CSS applying to inner components. The changes involved three areas:
    1. mx.styles.StyleProxy needed updating to support IAdvancedStyleClient
    2. mx.styles.StyleProtoChain required refactoring so that advanced selector matching functionality could be shared outside of this class (see next). The main change is in StyleProtoChain.addProperties() which is recursively called to handle the case when styleName is set to another IStyleClient (instead of a String). The change concerns the order of building the proto chain for this special case. Before advanced CSS, it seems we recursively did the following in the addProperties() subroutine:
    - Find type selectors, add to proto chain
    - Examine styleName:
    - if a CSSStyleDeclaration, add it to the proto chain next
    - if a IStyleClient, recurse again by calling addProperties to this IStyleClient
    - if a String, apply class selectors to proto chain
    - Finally, add inline style declarations to proto chain
    Advanced CSS might involve other universal selectors that aren't necessarily class selectors (such as id selectors), or we could have type selectors that are more specific that class selectors. So the new logic for Advanced CSS is:
    - Examine styleName:
    - if a CSSStyleDeclaration, add it to the list of selectors
    - Get all matching selectors, sort by specificity, and add to the proto chain.
    - Then, if styleName was an IStyleClient, recurse again by calling addProperties to this IStyleClient
    - Finally, add inline styleDeclarations to proto chain
    A styleName pointing to an IStyleClient means that it has a very high specificity and will override any other selector. The only thing that continues to always win are inline style declarations which are added last to the proto chain.
    3. mx.core.UIComponent.initThemeColor() needed updating to support advanced CSS selectors. This required the use of a new utility method in StyleProtoChain to find matching selectors.
    QA: Yes, please watch styles test results closely. Take a look at descendant/id/class selectors on more advanced components like DataGrid.
    Doc: No
    Checkintests: Pass
    Reviewer: Glenn
    Bugs:
    SDK-17358 - [Advanced CSS] When using an id selector without a Type selector, styles are not passed onto sub components (e.g. the drop down of a ComboBox)
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-17358
    Modified Paths:
    flex/sdk/trunk/frameworks/projects/framework/src/mx/core/UIComponent.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/styles/StyleProtoChain.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/styles/StyleProxy.as

    Hi,
    you define a CSS class in the document, e.g.
    <style type="text/css">
    .myClass{color:red;}
    <style>
    The myClass names now is what you add to the class property
    Frank

  • Is it possible to make a fixed size page in muse, so it doesn't resize?

    I want to make a fixed size page (pic1),
    but there always an extra space on the bottom… pic2

    Thank you for reply - I will check it out…
    Date: Wed, 18 Dec 2013 09:07:46 -0800
    From: [email protected]
    To: [email protected]
    Subject: Is it possible to make a fixed size page in muse, so it doesn't resize?
        Re: Is it possible to make a fixed size page in muse, so it doesn't resize?
        created by Zak Williamson (Adobe) in Help with using Adobe Muse CC - View the full discussion
    Assuming the screenshots are of the same page, the one that's taller is either taller because the minimum page height has been changed or due to some page content (that's not marked as a Footer Item) being located in the new space. This may be an empty text frame or the transparent area of a widget, text frame or other object.
         Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at http://forums.adobe.com/message/5941664#5941664
         Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/5941664#5941664
         To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/5941664#5941664. In the Actions box on the right, click the Stop Email Notifications link.
               Start a new discussion in Help with using Adobe Muse CC at Adobe Community
      For more information about maintaining your forum email notifications please go to http://forums.adobe.com/thread/416458?tstart=0.

  • Finder, Icon Slider bottom doesn't resize

    hi, i have a small bug with my icon slider of Finder. it doesn't resize with the small slider at right bottom of a Finder window.
    as you can see: the icons in the Finder window are very small (set by the slider right), but the slider left is set to the biggest icon size.
    but
    if i go to a higher Finder level, change there the size of the icons (possible), return to the old Finder window (picture above), then:
    the functionaltiy is actually, that the sliderposition left and right is synchronous.
    that well running disappearing after couple of clicks or minutes.

    I have the same issue. If I switch from a non-icon view to the icon view, the slider doesn't work. However, if I select icon view for a folder, then close the folder and re-open again, the slider works. I think the invisible database file for the folder display isn't getting updated correctly / at the right time.
    Permission repair doesn't help, so I suspect a minor Finder bug. Hopefully 10.7.2 will fix.
    K@

  • I installed a mxp and it doesn't appear in components panel

    Hi,
    I have a new Mac Pro, an Adobe Master Suite and when I installed a mxp component it doesn't appears in components panel.
    The Adobe Extension Manager is the latest too.
    All is in engliish.
    I installed also the Flex Component Kit and the same occurs.
    Teoricly it is so simple.... just double click the mxp file and Adbe Extension Manager opens and register.
    How can I fix it?

    What book?
    An ibook?
    Or an audiobook?

  • How to resize painted components

    Hi All,
    I am working on a simple project called "WhiteBoard" which is veryu similar to MS-Paint. Could anyone please tell me how to resize the components which I have drawn on the panel. Thanks in advance.
    Regards,
    Shankar.

    Cast the Graphics instance passed to the paintComponent() method of your board to a Graphics2D.
    Then use the scale(double sx, double sy) method of the Graphics2D instance to zoom
    your board in or out.
    IMPORTANT NOTE: If you use a mouse listener on the board, you'll have to convert the mouse
    coordinates according to the zoom factor.

  • Simple_list() doesn't resize

    I started converting a plugin to use simple_list(), and unfortunately it doesn't resize properly like the other controls:
    http://feedback.photoshop.com/photoshop_family/topics/sdk_simple_list_does_not_resize

    Hi, I'm having the same issue. I'm trying to get the list to
    scroll by pixels instead of row height. This is because one row may
    be larger than the screen and thus you won't be able to view all
    the text. Did you ever find a solution?

  • How to resize the components in a JFrame when the JFrame Resizes?

    Hi all,
    i have some problems with my app. I have set the JFrame resizable and that works fine for the JFrame but not for the components in the JFrame.
    So my question is how can i set the components in a JFrame to resize automatically when the JFrame resizes?
    Here are the important things from my code,...if you need more, just let me know, its my first post in a forum .
    Its a JFrame with a JTabbedPane and on the Tabs are Panels with buttons and Tables.
    Thank you in advance!
    public class MainMonitor extends JFrame {
    public MainMonitor() {
              super();
              initialize();
              setVisible(true);
         private void initialize() {
              this.setSize(1145, 785);
              this.setIconImage(Toolkit.getDefaultToolkit().getImage("Images/c.gif"));
              this.setContentPane(getJContentPane());
              this.setTitle("Company Manager");
              this.setResizable(true);
              this.setLocationRelativeTo(null);
         private JPanel getJContentPane() {
              if (jContentPane == null) {
                   jContentPane = new JPanel();
                   jContentPane.setLayout(null);
                   jContentPane.setOpaque(true);
                   jContentPane.add(getJTabbedPane(), null);
                   jContentPane.add(getJPanel11(), null);
              return jContentPane;
         private JTabbedPane getJTabbedPane() {
              if (jTabbedPane == null) {
                   jTabbedPane = new JTabbedPane();
                   jTabbedPane.setLocation(new Point(6, 69));
                   jTabbedPane.setSize(new Dimension(1120, 684));
                   jTabbedPane.addTab("P", null, getJPanel(), null);
                   jTabbedPane.addTab("K", null, getJPanel1(), null);
                   jTabbedPane.addTab("B", null, getJPanel2(), null);
              return jTabbedPane;
         

    Giasaste wrote:
    Thanks a lot, i didnt knew that the Layout Manager is a must.It's not a must, but it is the way to allow your app to be resized nicely and makes it much easier to maintain and enhance your program. Imagine creating a complex gui then later decide that you want another radiobutton and to remove a jlabel / jtextfield pair. with layout managers a chore becomes easy.

  • JtoggleButton ...setSize doesn't seem to work

    Hi.
    I try to make a game and i want to have two kind of JToggleButtons
    The first i want to look like ||||||||||| (horizontal alligmnent )
    the socond one i want to be vertical
    i have tried to use the setSize () ,setMinimumSize() and setMaximumsize to order to accomplish this but even if i change the dimensions the button's shape doesn't change... What have i done wrong?
    Thank you in advance...
    here is the code
    import java.awt.FlowLayout;
    import java.awt.event.MouseAdapter;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JToggleButton;
    public class TestClass1 {
         //the Class Wall is an extended JToggleButton
         private Wall wall1;
         private Wall wall2;
         private JFrame frame;
         TestClass1(){
              wall1 = new Wall(Wall.HORIZONTAL);
              wall2 = new Wall(Wall.VERTICAL);
              wall1.addMouseListener(new MyMouseListenr(this));
              wall2.addMouseListener(new MyMouseListenr(this));
              JPanel panel = new JPanel(new FlowLayout());
              frame = new JFrame();
              frame.setLayout(new FlowLayout());
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              panel.add(wall1);
              panel.add(wall2);
              frame.add(panel);
              frame.pack();
              frame.setVisible(true);
          * @param args
         public static void main(String[] args) {
              new TestClass1();
         public JToggleButton getButton1() {
              return wall1;
         public JToggleButton getButton2() {
              return wall2;
         class MyMouseListenr extends MouseAdapter{
              MyMouseListenr(TestClass1 testClass){
                   //Do things
    import java.awt.Dimension;
    import javax.swing.JToggleButton;
    public class Wall extends JToggleButton {
         public static final int VERTICAL = 1;
         public static final int HORIZONTAL = 0;
         //don't bother.....
         private boolean isRaised;
         //is used to determine if the button is vertical or horizontal
         private int allignment;
         Wall(int allign){
              super();
              isRaised = false;
              allignment = allign;
              setSize(allign);
          * setSize (hypothetically) resizes the buttons to be
          * vertical or horizontal
         private void setSize(int allign) {
              Dimension d;
              if (allign == VERTICAL) d = new Dimension(10,25);
              else d = new Dimension(25,10);
              setMinimumSize(d);
              setMaximumSize(d);
              setSize(d);
          * some other functions ....
         public boolean isRaised() {
              return isRaised;
         public void setRaised(boolean isRaised) {
              this.isRaised = isRaised;
              this.setSelected(isRaised);
    }

    Thank you for answering!
    i added the line setPrefferedSize(d) and it worked fine
    but i still wonder why this happens.....i mean, setSize is not applicable for the flowlayout but setPrefferedSize is..
    (and propably setPrefferedSize is not applicable for other layouts?)
    it seems kind of odd...
    The isRaised has it's own use but in the code does's show up because i have removed many lines in order to make it simplier to read. Thanks for your suggestion though!
    I hadn't noticed the there was a swing forum ....sorry

  • Aterm doesn't resize contents properly

    I've been on holiday for a while so recently did a large update (300+ packages). After doing it aterm has stopped resizing its contents correctly.
    It is hard to explain but if I stretch an aterm window larger the content (usually just a shell) doesn't always resize to fill the new window. Sometimes there is at least 5-6 blank lines at the bottom of the window that the content doesn't go in to. If I play with the size I can get the content into it but it seems to snap to a certain size before the content will fit.
    I'm running aterm version 1.00.01 on fluxbox and the shell is either bash or bash in screen.
    Has anyone else seen this kind of problem?

    If you open the brush dialog, there is a dual brush setting on the left that can be enabled. If you click on it, the dual brush diameter is the first option that can be changed and it is in pixels not %. If you resize your brush size with bracket keys or right click and drag the slider, photoshop adjusts this setting automatically, but the new drag resize leaves this setting intact.

  • Resizing media components dynamically

    Does anyone know of a way to resize the MediaController
    component dynamically based on the size of the stage? When I just
    change its height/width properties, it stretches it. Not quite what
    I'm looking for.
    If I resize it manually by changing the dimensions in the
    property inspector, it adjusts nicely. What I want is for the
    player to scale, but the buttons and icons to stay the same size.
    Thanks in advance.
    Sean

    Thats how it is designed.
    To change the size use copy the styles from the component
    template fla file provided with flash. These are open movie clips.
    you can edit the size manually and the effect will be reflected in
    the embedded components.

  • Adobe Acrobat CS3 window doesn't resize

    Hello,
    I'm currently using Adobe CS 3 on a Lenovo X200T with Windows 7 installed.  I have a problem with Acrobat CS3 which I have not had with prior computers.  I find that whatever size the window is when I open an acrobat document, it stays that size.  I mean, I can resize the borders and all, but the document doesn't follow it.  For example, if I open the document and it is windowed and in a corner of the page, and I maximize it, acrobat will maximize but the document stays the same just with a larger grey border to fill up the space.  The scrollbars don't move either, so when I make the window small, they just disappear sometimes and I can't navigate easily.  The only way to get the window size I want is to resize the window, close adobe, then open the document again.
    Is there anything I can do to fix this?
    Eric

    I think that CS3 is related to AA8. If it is, you will likely have to upgrade for Win 7. AA9 is the only version currently certified for WIn 7.

  • Component.setSize() doesn't seem to work.

    I've been having trouble making a JFrame that holds a JTable in a JScrollPane, where I set the size of the JTable to be close to the size of the JFrame. Basically, I thought I would be able to listen for the event of resizing, get the new height and width and set the table to that width and that height, minus a little bit for an okay button on the bottom of the panel. However, while I am able to find the size of the window as it resizes, it simply seems that setSize and the assoicated methods do not have the intended effect on my JTable. I've tried a number of things, but it just resizes it to the incorrect number. That is, I can table.setSize(x, y) and then table.getSize() returns values different from the x and y I just found!!
    I've written a really simple program that demonstrates the problem. It does occur in this code, but it isn't nearly as severe:
    package src;
    import java.awt.Component;
    import java.awt.Container;
    import java.awt.Dimension;
    import java.awt.GridBagConstraints;
    import java.awt.GridBagLayout;
    import java.awt.Insets;
    import java.awt.event.ComponentEvent;
    import javax.swing.JFrame;
    import javax.swing.JTable;
    public class Test extends JFrame {
        public static void main(String args[]) {
            new Test();
        private Container c;
        private GridBagConstraints constraints = new GridBagConstraints();
        private GridBagLayout layout = new GridBagLayout();
        private JTable table;
        public Test() {
            setSize(300, 400);
            constraints.insets = new Insets(4, 4, 4, 4);
            constraints.fill = GridBagConstraints.BOTH;
            c = getContentPane();
            c.setLayout(layout);
            setTitle("table.setSize() does not work as expected. Resize this window to see.");
            table = new JTable();
            addComponentListener(new java.awt.event.ComponentAdapter() {
                public void componentResized(ComponentEvent event) {
                    System.out.println("Window resized to " + getWidth() + " , " + getHeight());
                    Dimension size = new Dimension(getWidth() - 20, getHeight() / 2);
                    //table.setMaximumSize(size);
                    //table.setPreferredSize(size);
                    //table.setMinimumSize(size);
                    table.setSize(size);  //toggle some of these on and off to get closer to having it do what it should.
                    validate();
                    System.out.println("Tried to set to " + size + " but is now " + table.getSize());
            addComponent(table, 0, 0, 4, 3);
            pack();
            show();
        private void addComponent(Component component, int row, int column, int width, int height) {
            constraints.gridx = column;
            constraints.gridy = row;
            constraints.gridwidth = width;
            constraints.gridheight = height;
            layout.setConstraints(component, constraints);
            c.add(component);
    }Thanks in advance!
    Andy

    @james91 : setSize has two different signature
    - setSize(int width, int height)
    - setSize(Dimension size)
    @OP : You are using a LayoutManager for your contentPane. Calling setSize on your JTable is useless as you call validate afterwards. validate() will cause the LayoutManager to call layoutContainer(...). In the layoutContainer() method, table.setBounds(...) is called so setting the table's size is completely useless.
    If you really want to use a GridBagLayout, you'll have to use :
    constraints.weightx = 1.0;
    constraints.weighty = 1.0;
    Don't forget to add your table to a JScrollPane if you want the header to appear.

Maybe you are looking for

  • Stock Report for Individual Stock Segments

    Is there a report similar to MCBZ, but very specifically showing individual stock segments like sales order stock?

  • Mismatching of vat amount

    Hi Guru,     my client is asking mismatching of vat amount that is -                                                              When generate annual VAT report containing assessable value along with tax values for a particular year which should mat

  • Web Service Client, BindException, Address already in use, saaj.SOAPExcepti

    Hello, Am caught up with an error and i can't get past it, need some help here. My application is a batch processing web service client, reads some input rows, sends web service requets, processes the responses and logs it. The application runs well

  • Authorization Control on Transaction Type Fields

    Hi Friends, I have created 4 customised fields in Complaint Transaction Type. Lets say A1,A2 and B1,B2. Now the requirement is to control the fields based on roles or users. Is this Possible? if yes how? I mean UserA will be able to see and edit fiel

  • Essbase studio data loading

    Hi Friends, I need some help in cube deployment using Essbase studio and oracle as my source. I am trying to deploy a cube, my dimensions are loaded properly but data loading fails and gives following error. *"Cannot get async process state. Essbase