How to set height of a JPanel ?

Hi.
My JPanel is a tad too high and I'd rather not use
mypanel.setPreferredSize(int xxx, int yyy)
because the breadth is alright.
How do I play around with the height only?
Something like
myjpanel.setHeight(int yyy);
would be nice but the method deoesn't exist.
:-)

Set the minimum size and maximum size as well, to force it to work no matter what the layout manager is. You can set the minimum width to something like 1 and the maximum to 2000 to ensure it works properly if the window is resized, but make sure the minimum height is the height you want. The dimensions are in pixels by the way.

Similar Messages

  • How to set height of JTable Header ?

    How to set height of JTable Header and set the text to another size ?

    You can set the font of the header as you can for any component. The font will dictate the preferred height of the header. If you don't like the preferred height, you can set that as well.
    // add table to a scroll pane or the header will not appear
    JTable table = new JTable(...);
    container.add(new JScrollPane(table));
    // get a reference to the header, set the font
    JTableHeader header = table.getTableHeader();
    header.setFont(new Font(...));
    // set the preferred height of the header to 50 pixels.
    // the width is ignored by the scroll pane.
    header.setPreferredSize(new Dimension(1, 50));Mitch Goldstein
    Author, Hardcore JFC (Cambridge Univ Press)
    [email protected]

  • How to set Width of a JPanel?

    I am overwirting paintComponent(Graphics g) method to
    draw some g2D in a JPanel.
    I want the drawing processing shown on screen (not flashed out after drawn because it is VERY SLOW).
    So that I CAN NOT use setsize() or setBound() because to change JPanle.width because this is NOT what I wanted(the graphics is shown AFTER is drawn).
    Everytime I call paintComponent(), the width of JPanel is changed.
    My question is : How can change JPanel.width without calling method like setsize() or setBound() .
    Thanks a lot!!

    My code too large, I just show some idea here:
    class caller (){
    myPanel p;
    Graphics2D g2 = (Graphics2D)p.getGraphics();
    //I nee to increase the p.width before call my_paint
    //I CAN NOT use setsize() or setBound()
    //because I want show the drawing process
    //on screen( and that is fast)
    p.my_paint(g2); // how to set p.width ??
    public class myPanel extends JPanel
    public void my_paint(Graphics2D g2)
    //Do my drawing here ,
    // I need to draw thousands of Line2D.
    public void paintComponent(Graphics g){
    Graphics2D g2 = (Graphics2D)g;
    my_paint(g2);

  • How to set height of XControl?

    Hello,
    I want to set the height of xcontrol,but there is a problem when I try to set it by property node of xcontrol container bounds height. Top  and bottom of my control show incomplete.
    So,how to set the height of XControl correctly?
    Thank you! 
    Solved!
    Go to Solution.

    Attached you can find a small example how to get it to work. Please note that i limit the smallest value to 40 because lower heights lead to graphical issues when resizing to larger values again.
    So you can see that there are limitations to resizing of XControls depending on the facade of the XControl.
    hope this helps,
    Norbert 
    CEO: What exactly is stopping us from doing this?
    Expert: Geometry
    Marketing Manager: Just ignore it.
    Attachments:
    Resize XControl.vi ‏10 KB

  • ADF Faces: how to set height of af:panelBorder to be % of screen height

    Hi,
    I am having hard time setting height of af:panel to be a percentage of screen height. Using inlineStyle, I tried the following but it doesn't work:
    <af:panelBorder inlineStyle="height:90.0%;">
    Any thoughts?
    Thanks
    Message was edited by:
    samsam

    Hi,
    not sure skinning can help here. There is no property on the dialog
    Frank

  • How to set height panelCollection

    hello all
    i have problem with UI, i can't set height panelCollection to full height in my page, and i have change StyleClass to AFStretchWidth/ AFStretchHeight
    this below structure in my project file
    template.jspx facet
    panelGroupLayout
    panelHeader
    panelCollection
    popup
    anyone help :)
    thx gan
    agungdmt

    Your PanelCollection is not stretched because neither PanelGroupLayout nor PanelHeader stretch its children. Either the PanelCollection has to be the root component or the whole hierarchy above it should be of components that stretch their children (for example, center facet of PanelStretchLayout, DecorativeBox, PanelSplitter, ShowDetailItem(stretch), etc.). Have a look here for more details:
    http://download.oracle.com/docs/cd/E14571_01/web.1111/b31973/af_orgpage.htm#CDEFAFGJ (See the last 2 columns in the table)
    http://download.oracle.com/docs/cd/E14571_01/web.1111/b31973/af_orgpage.htm#CDEECCJF
    http://download.oracle.com/docs/cd/E14571_01/web.1111/b31973/af_orgpage.htm#CACHIIAE
    Dimitar

  • How to set Tab ordering in JPanel

    hi all
    i add a JPanel on a JFrame and Various swing Controls on that JPanel. now i want to change tab ordering of components present in my JPanel.
    please guide me how can i do this. i have tried setFocusTraversalPolicy but it does not work with JPanel.

    You should read the article from Sun:
    "How to Use the Focus Subsystem"
    http://java.sun.com/docs/books/tutorial/uiswing/misc/focus.html
    Moshe

  • How to set height of af:inputListOfValues

    Is there any way I can set the height of af:inputListOfValues?
    Thanks,

    Hi,
    not sure skinning can help here. There is no property on the dialog
    Frank

  • How to set one row or node 's height in the jtree?

    How to set height of one row or node in the jtree?
    I found the method :jTree.setRowHeight(height);.
    But I want to set height of one row ,not all rows of a jtree.
    Thanks for help!

    Who can help me?

  • How to set image to JPanel

    Hi to all,
    How to set background image to panel in swing?
    If anyone knows tell me..

    Hi,
    Just modify and use this..
    import java.awt.BorderLayout;
    import java.awt.Component;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.image.BufferedImage;
    import javax.swing.JCheckBox;
    import javax.swing.JComponent;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JViewport;
    import RboJComponents.RboJEmailTextField;
    import RboJComponents.RboJPanel;
    public class ImagePanel extends JPanel
    public static final int TILED = 0;
    public static final int SCALED = 1;
    public static final int ACTUAL = 2;
    private BufferedImage image;
    private int style;
    private float alignmentX = 0.5f;
    private float alignmentY = 0.5f;
    public ImagePanel(BufferedImage image)
    this(image, TILED);
    public ImagePanel(BufferedImage image, int style)
    this.image = image;
    this.style = style;
    setLayout( new BorderLayout() );
    public void setImageAlignmentX(float alignmentX)
    this.alignmentX = alignmentX > 1.0f ? 1.0f : alignmentX < 0.0f ? 0.0f : alignmentX;
    public void setImageAlignmentY(float alignmentY)
    this.alignmentY = alignmentY > 1.0f ? 1.0f : alignmentY < 0.0f ? 0.0f : alignmentY;
    public void add(JComponent component)
    add(component, null);
    public void add(JComponent component, Object constraints)
    component.setOpaque( false );
    if (component instanceof JScrollPane)
    JScrollPane scrollPane = (JScrollPane)component;
    JViewport viewport = scrollPane.getViewport();
    viewport.setOpaque( false );
    Component c = viewport.getView();
    if (c instanceof JComponent)
    ((JComponent)c).setOpaque( false );
    super.add(component, constraints);
    protected void paintComponent(Graphics g)
    super.paintComponent(g);
    if (image == null ) return;
    switch (style)
    case TILED :
    drawTiled(g);
    break;
    case SCALED :
    Dimension d = getSize();
    g.drawImage(image, 0, 0, d.width, d.height, null);
    break;
    case ACTUAL :
    drawActual(g);
    break;
    private void drawTiled(Graphics g)
    Dimension d = getSize();
    int width = image.getWidth( null );
    int height = image.getHeight( null );
    for (int x = 0; x < d.width; x += width)
    for (int y = 0; y < d.height; y += height)
    g.drawImage( image, x, y, null, null );
    private void drawActual(Graphics g)
    Dimension d = getSize();
    float x = (d.width - image.getWidth()) * alignmentX;
    float y = (d.height - image.getHeight()) * alignmentY;
    g.drawImage(image, (int)x, (int)y, this);
    public static void main(String [] args)throws Exception
    BufferedImage image = javax.imageio.ImageIO.read(new java.io.File("c:\\final.jpg"));
    //ImagePanel north = new ImagePanel(image, ImagePanel.ACTUAL);
    //north.setImageAlignmentY(1.0f);
    //JTextArea text = new JTextArea(5, 40);
    //JScrollPane scrollPane = new JScrollPane( text );
    //north.add( scrollPane );
    ImagePanel south = new ImagePanel(image, ImagePanel.SCALED);
    south.setPreferredSize(new Dimension(490, 340));
    south.setLayout(null);
    RboJPanel buttons = new RboJPanel();
    buttons.setBounds(15, 105, 350, 50);
    RboJEmailTextField toAddress = new RboJEmailTextField(28);
    //toAddress.setBounds(20,20,20,20);
    //toAddress.setCaretColor ( toAddress.getBackground () ) ;
    buttons.add(toAddress);
    //buttons.add(new JButton("Two"));
    /*JPanel boxes = new JPanel();
    boxes.add( new JCheckBox("One"));
    boxes.add( new JCheckBox("Two") );*/
    south.add(buttons);
    //south.add(boxes, BorderLayout.PAGE_END);
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //frame.getContentPane().add( north, BorderLayout.NORTH );
    frame.getContentPane().add( south);
    frame.pack();
    frame.setVisible(true);
    }Regards,
    Anees

  • How to set a minimum width and height for a stage or scene?

    Hello,
    Does anyone how to set a minimum width and height for a stage or scene?
    I tried listening for width/height property value changes and then adjust the width/height if necessary, but that causes unpleasant flickering of the window.
    In JavaFX 2.1 beta SDK for Mac OS, the Stage class has setMinWidth() and setMinHeight() functions which work very well.
    I'm wondering what's the equivalent way to do that when using the FX SDK for Windows.
    Any help is appreciated!
    Thanks.

    I was wondering how to enforce a minimum stage size with JavaFX 2.0.3.The same flickering way you are currently doing it. See: http://javafx-jira.kenai.com/browse/RT-15200 "Need a way to set the minimum size of a window"

  • How to set  row height  for  each row

    Hi
    i am trying to set rowheight of row in a JTable using setRowHeight(row,rowheight)
    it is not affecting on Table.but if i use setRowheight(rowheight) it applying
    entire table ,please help me to solve this problem
    after setRowHeight(row,rowheight), i am calling firechanged() method also ,i t will not affecting please hemp me
    how to set row height at runtime in a JTable

    Ok fine... do one thing... post ur code here let me check and tell u....
    Ciya.....

  • How to set Panel height to browser height?

    I have a panel in a module in an application (App > Module > Panel). I would like the panel to take up the full height of the browser window. How can I achieve this? Trying to set height="100%" doesn't work, and makes the panel disappear. Setting the layout to absolute also doesn't work when setting top and bottom margins to 20.
    Any ideas welcome.
    Thanks!
    Mike

    There is something odd going on. I did what you suggested, but then the module doesn't display. However, when I remove the percentage-based height tags everything shows up.
    It seems that the Panel object is sensitive to height being percentage-based. As soon as I set its height to "500" instead of "100%" it displays.

  • How to set glasspane in Jpanel?

    I want to block all mouse/key input in JPanel, so how to set glasspane in jpanel?

    A glass pane is for the entire frame, not just a JPanel.
    Read the Swing tutorial on [How to Use Root Panes|http://java.sun.com/docs/books/tutorial/uiswing/TOC.html] which has an example on using Glass Panes.

  • Any one know how to set a picture background in JPanel

    I am study java at collage and need to know this for a project
    How to set a picture gif or bmp etc to a background in JPanel in Swing
    CAN ANYONE HELP!

    If you want to just add an image to a JPanel, create a JLabel and add the image to that, then add the JLabel to the JPanel. If you want it to be the background of the JPanel, check this out:
    http://manning.com/sbe/files/uts2/Chapter15html/Chapter15.htm
    15.2 is where you'll find your answer along with sample code. The whole book is useful, take a look through it if you're interested.

Maybe you are looking for

  • If i buy an iPhone 6 in Turkey can it be fixed/upgraded in The United States?

    I am currently living abroad in Istanbul, Turkey, but I am an American citizen. My American iPhone 5 has had hardware issues (I have gone through all of the troubleshooting issues many times with many people and we have all decided it truly is a hard

  • How can I type on a PDF file? Do I need a specific version of Adobe to enter a text box?

    I would rather type my information onto the page rather than hand write it and I don't have access to a type writer. How can I type my info onto the application?? Please help!

  • Synching 2 iphones to same itunes

    we have always had 2 iphones with sep profiles and a single iTunes account on 1 computer. Every time we connect a phone to the computer we get the message that the device is synched with a different iTunes library and the option is either to erase th

  • Help on IDOC -POST GOODS ISSUE

    Hi Folks,            I have requirement with me, but I don’t know where to start could you please help me regarding that.. Here is the scenario.... Requirement Specification: XYZ Company Mexico operations  uses third party systems Foursite) for their

  • My macbook turns on but doesn't boot up to log in screen

    I was using Ableton and sudenly my Mac just stopped working. I've rebooted, removed power, rest the smc but can't get it to reboot to the log in screen. It turns on but doesn't do anything but show me a white screen.