How to put Panel with GridBagLayout to top left edge

Morning everybody!
So, i got a small question. When i have a panel with a GridBagLayout, the components are always aligned to the center of the panel... Is there a posibility to align them to the top left edge?
Regards, michael

Thanks!
But i solved the problem myself. I just put the panel with the GridBagLayout into on with BorderLayout.
Now it's okay. Maybe this solution is a dirty one, but it works!
I wasn't able to make any changes with anchor. No matter which value, nothing changed....
Regards, Michael

Similar Messages

  • Fill space in panel with GridBagLayout

    Hello,
    I have a class that extends JPanel and uses a GridBagLayout.
    I would like the contents of this panel to occupy the whole available space.
    However, I don't find how to do it with GridBagLayout (I know this is automatically done with BorderLayout but I want to use GridBagLayout for organizing internal components).
    I have this small program to show the problem.
    In this example, how could the button fill all the available space with GridBagLayout?
    Note that setting GridBagConstraints fill to BOTH doesn't solve the issue.
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.GridBagConstraints;
    import java.awt.GridBagLayout;
    import java.awt.LayoutManager;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    public class TestBlankSpace {
        private static int x = 200;
        public static void main(String[] args) {
         testPanel(new BorderLayout(), BorderLayout.CENTER);
         testPanel(new GridBagLayout(), createGridBagConstraints());
        private static void testPanel(LayoutManager manager, Object constraints) {
         JPanel panel = new JPanel(manager);
         JButton button = new JButton("button");
         button.setBackground(Color.ORANGE);
         panel.setBackground(Color.WHITE);
         panel.add(button, constraints);
         JFrame window = new JFrame("Test Panels");
         window.add(panel);
         window.setLocation(x, 200);
         window.setSize(400, 300);
         window.setVisible(true);
         window.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
         x += 400;
        private static GridBagConstraints createGridBagConstraints() {
         GridBagConstraints c = new GridBagConstraints();
         c.fill = GridBagConstraints.BOTH;
         return c;
    }Thank you

    Hi,
    For better understanding the grid bag layout read this tutorial :
    [http://java.sun.com/docs/books/tutorial/uiswing/layout/gridbag.html|http://java.sun.com/docs/books/tutorial/uiswing/layout/gridbag.html]
    Olek

  • AS3 how to put the buttons always on top of the external swf in the code below?

    how to put the buttons always on top of the external swf in the code below?  I am  beginner use to as3, can someone help me?
    thanks, for all!!
    var Xpos:Number = 110;
    var Ypos:Number = 180;
    var swf:MovieClip;
    var loader:Loader = new Loader();
    var defaultSWF:URLRequest = new URLRequest("swfs/eyesClosed.swf");
    loader.load(defaultSWF);
    loader.x = Xpos;
    loader.y = Ypos;
    addChild(loader);
    // Btns Universal function
    function btnClick(event:MouseEvent):void {
    removeChild(loader);
    var newSWFRequest:URLRequest = new URLRequest("swfs/" + event.target.name + ".swf");
    loader.load(newSWFRequest);
    loader.x = Xpos;
    loader.y = Ypos;
    addChild(loader);
    // Btn listeners
    eyesClosed.addEventListener(MouseEvent.CLICK, btnClick);
    stingray.addEventListener(MouseEvent.CLICK, btnClick);
    demon.addEventListener(MouseEvent.CLICK, btnClick);
    strongman.addEventListener(MouseEvent.CLICK, btnClick);

    use:
    var Xpos:Number = 110;
    var Ypos:Number = 180;
    var swf:MovieClip;
    var loader:Loader = new Loader();
    var defaultSWF:URLRequest = new URLRequest("swfs/eyesClosed.swf");
    loader.load(defaultSWF);
    loader.x = Xpos;
    loader.y = Ypos;
    addChild(loader);
    // Btns Universal function
    function btnClick(event:MouseEvent):void {
    removeChild(loader);
    var newSWFRequest:URLRequest = new URLRequest("swfs/" + event.target.name + ".swf");
    loader.load(newSWFRequest);
    loader.x = Xpos;
    loader.y = Ypos;
    addChildAt(loader,0);
    // Btn listeners
    eyesClosed.addEventListener(MouseEvent.CLICK, btnClick);
    stingray.addEventListener(MouseEvent.CLICK, btnClick);
    demon.addEventListener(MouseEvent.CLICK, btnClick);
    strongman.addEventListener(MouseEvent.CLICK, btnClick);

  • TS1718 trying to watch repeats of itunes festival 2012, all I get is a black box with x in top left corner. any ideas? thanks

    trying to watch repeats of itunes festival 2012, all I get is a black box with x in top left corner. any ideas? thanks

    Thanks so much.  I saw this on "desktop strangeness" immediately after I posted and tried to retract my question.  It worked perfectly.  I'm not sure how VoiceOver got turned on unless something happened when I was trying to wake up the computer.  I open the lid and it flashes whatever is open and then the screen goes black and I can't wake it up.  Still looking for the resolution to this.

  • How to get tabs into a column on left edge of Firefox window?

    How to get tabs into a column on left edge of Firefox window?
    I've looked extensively for the answer but haven't found it yet.

    I found the Tree Style Tab ad-on does this.
    Mike

  • How to have ICWeb Identification screen on top left show premise zip code

    Previously in one of our training environments anytime a Business Partner and Premise were confirmed the top left hand screen in the ICWeb would show the BP first and last name as well as the premise and the premise zip code.  In our production environment the top left hand screen shows everything except for the premise zip code.
    Can somebody please explain how this field can pick up on the premise zip code whether it is done through SPRO or coding?
    Thanks
    Dave

    Hi David,
    This is proper coding issue. As you want  premise zip code to display in the contact information box. If I am not wrong. You can do it in Component CRMCMP_IC_FRAME. In the custom controller there is method SET_CALLER_DISPLAY_BPNAME where you need to get the premise zip code data and concatenate it to caller_display_name variable.
    Hope this will solve your issue.
    Thanks,
    Albert

  • How to put a JFrame on the top of all other applications

    when some message is received, I want to put an existing JFrame on the top of all other applications. So that the user knows that some message has arrived.
    I tried toFront(), but it blinks the JFrame on the taskbar never comes on the top of other application.
    Any ideas.
    Rajesh

    On Windows 98 the toFront() method works, but maybe not exactly how you expected.
    There seems to be a delay of about 20 seconds.
    If your frame has not been active within the last twenty seconds then the frame is displayed when the toFront() is used.
    If the frame has been active within the last 20 seconds then the icon will flash.
    I believe this behaviour is to prevent frames from poping up all the time. Here is a simple program that shows this behaviour:
    import java.awt.*;
    import java.awt.event.*;
    import java.util.Date;
    import javax.swing.*;
    public class FrameToFront
        public static void main(String[] args)
            final JFrame frame = new JFrame();
            frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
            frame.setSize(200, 200);
            frame.setLocationRelativeTo( null );
            frame.setVisible(true);
            int delay = Integer.parseInt(args[0]);
            final Timer timer = new Timer(delay, new ActionListener()
                public void actionPerformed(ActionEvent e)
                    System.out.println(new Date());
                    frame.toFront();
            timer.start();
    }After you start the program click on the dos window to hide the frame. Try the following two cases:
    java FrameToFront 5000
    java FrameToFront 20000

  • How to put audio with s-video cable

    heyas. i am using a svide cable and i have no sound. then i put another cable in the s-line out (the one i use with my amplifier and it is ok)and cnnectect to the tv but no sound! i have all the updates. tahnks

    pbc pt
    You need to use audio cables left and right from the dock or headphone jack to audio input on tv, as s-video cable does not carry audio signal. If you are using the Apple A/V kit or cable hook up is simple red to red... white to white yellow to nothing as you are using S-video but if a non-apple A/V cable the plugs may have to be swithced to yellow to red....white to white and red to yellow (or in your case red to nothing as you are using "s" video.
    Rick

  • Pb of resizing panels with GridBagLayout

    Hi !
    I've got three panels one under each other (A, B and C) and use GridBagLayout as layout.
    I'd like to resize only the center one (B) and conserve the height of other ones (A, B).
    When I fix the size, the preferred, minimum and maximum sizes to the same number for A and C, it doesn't work.
    Has someone got an idea, please :(
    delph

    Are you also setting fill for the constraints on the middle panel to GridBagConstraints.BOTH?
    For this requirement you'd be bettter using a BorderLayout though - it does just what you describe (if you use NORTH, CENTER, SOUTH for A, B, C) and its a lot lighter in its footprint.

  • How to put title or labels on top of row headding of Cross Tab

    Hello..
                 I created one cross tab.I put labels in the top row,these labels are coming only in first page only,I tried repeat row label also,But not working....I need all the labels in all pages..

    Hi,
    In XI r3 - on a  cross-tab table under the page layout properties there is a  "Repeat header on every page" option. Is this checked?
    Regards
    Alan

  • How to put JTable checkbox on the top of its cell

    my JTable only had 2 columns, one data type is boolean, display as checkbox, one data type is String,cell Renderer is JTextPane which data had large size ,and each row had different height depended on data size.
    now the checkbox is displayed at the centre of each row, i hope it can be displayed on the top of this row, how i can set it. please help guide.
    Many Thanks
    Susan

    Camickr,you are excellant, it's resolved as you said as following:
    private JTable tblMain = new JTable(){
            public Component prepareRenderer(
                TableCellRenderer renderer, int row, int column) {
                Component c = super.prepareRenderer(renderer, row, column);
                if (c instanceof JCheckBox)
                    ( (JCheckBox) c).setVerticalAlignment(JCheckBox.TOP);
                return c;
            public Component prepareEditor(
                TableCellEditor editor, int row, int column) {
                Component c = super.prepareEditor(editor, row, column);
                if (c instanceof JCheckBox){
                    ( (JCheckBox) c).setVerticalAlignment(JCheckBox.TOP);
                    c.setBackground(Color.white);
                return c;
        };

  • How to put String with html tags as it is into xml

    I am using apache dom API to create xml from java.
    I have a string with html tags in it .when I add the string to xml, its replacing all the "<"; with &lt and ">" with > I would like the html tags to look as it is instead of the > and & lt;. How can I acheive that
    this is the code snippet of what I am doing
    In java class
    String titleString = "<font color=red>This Is an Example of a Red Subject</font>"
    Document doc = new DocumentImpl();
    Element root = doc.createElement("bulletin");
    Element item = doc.createElement("title");
    item.appendChild(doc.createTextNode(titleString));
    In Xml it looks like below
    <title><font color=red>This Is an Example of a Red Subject</font></title>
    but I would like to have the xml like below
    <title><font color="red">This Is an Example of a Red Subject</font></title>
    Can you please suggest me whats the best way to acheive this.
    I appreciate all your help
    Thank you
    Suma

    One problem is that you don't understand escaping. If you re-read what you posted you'll see that what you say you get, and what you say you want, are identical. That's because you didn't escape one of the two properly. So your first step should be to find the section about escaping in Chapter 1 of your XML book and read it carefully. Figure out what you should have done here (yes, the same rules apply).
    However, to attempt to answer what I think your question is: if you have a String which contains markup, and you want to convert that String to XML elements, then you have to feed the String into an XML parser.

  • How to put vertical Scroll Bar on the LEFT side of a VBox?

    The default is on the RIGHT side. It seems no easy solution on this question.

    Hi Darren,
    Thanks for your reply. I've narrowed the problem down to this strange behavior only happening when the viewport component is a tree-table (a JTable with a JTree for a column renderer). The tree-table works okay in JDK 1.3, but not in JDK 1.4. When I remove the JTree column renderer, the table draws correctly, but without the tree. It looks like the viewport position is being set wrong somewhere.
    When a column is resized, an AdjustmentEvent is created. So that's why resizing the column looked like it had the same effect as the horizontal scroll bar.
    If you're interested, then I will be happy to let you know how I fixed it, if I can.
    The complete code that creates the scroll pane with the vertical scroll bar on the left is below. There's too much code to post the JTree column renderer.
    Thank you,
    Don
    m_leftScrollPane = new JScrollPane(m_sourceTable,
    JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
    JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    m_leftScrollPane.setComponentOrientation
    (ComponentOrientation.RIGHT_TO_LEFT);

  • HPC309 - phantom printing paper with "ATEOV1" at top left of paper

    I just got and set up a new HPC309 all in one printer/fax, scanner and copier. It seems to be working fine with one exception.
    At random times, it will auto-print a paper with only the following in the upper left corner of the paper:
    ATEOV1
    i am losing a lot of paper to this. i called HP TO NO AVAIL - THEY HAD NO IDEA And didn't really try to help much.
    It seems to happen (but not always) when my iMac is "awakened". the printer is connected by Bluetooth to my iMac, but i don't have it connected wirelessly.
    any ideas?
    thank you,

    I am having the same exact problem and have just purchased and hooked up the same HPC309 printer. Did you ever get resolution?  This is SO annoying and eating up all my paper.

  • G4 Dual 800 Freezes At Desktop Screen With Cursor In Top Left Corner...

    At OSX 10.4 startup my screen freezes as mentioned above. The clock is still accurately working and the usual startup sound occurs but the grey screen with logo takes longer than usual to reach the blue screen with icons and screentop info.
    Problem occurred whilst selecting Safari icon to go on line. Until then the cursor had freely moved. The light on a wireless mouse shows power from the batteries and I know they're OK but the light on the signal source plugged into the screen rear USB point does not now light up (green - it's a Microsoft one).
    I've got three different mouses and each indicates a lack of power to the system at that point. However, until the static cursor is reached on the desktop everything else seems to be working.
    I've been through the usual keyboard steps in an effort to solve the problem and I've followed the previous comments earlier on in the year but my circumstances don't appear to be exactly the same....
    Any A to B advice would be appreciated - thanks.

    Thanks for that Tom.
    Should have said.....When I first succeeded in gaining Safe Mode (after a number of attempts) I found that moving the cursor to the Dock, to the first icon it came across, the Finder one, it immediately froze the screen again, the same as when I selected Safari in the Dock first of all.
    I'm still in the process of trying to get the Safe Mode to come up again but haven't yet succeeded with the required precision in selecting after the startup sound (well, I think that's what I'm about!). I'll call back again on progress shortly. If I manage it I'll try selecting the Tray operation.

Maybe you are looking for

  • Mac mini: Can I downgrade to OS X 10.8.5?

    Simple question: Since the "current" Mac mini is the Late 2012 model, which originally shipped with OS X 10.8.x, is it possible to purchase a new unit today, wipe the drive, and install OS X 10.8.5? I have a 10.8.x installer. Reason for this question

  • A Bug in iOS7 Using Siri with in Car Bluetooth

    I have a near new Hyundai SanteFe with built in bluetooth.  Under iOs6 it worked fine when listening to CD, Radio or Music from the iPhone. Now, if I use Siri when using Radio or CD it still works fine.  However if I am listening to Music app on the

  • XML as result from webService call from JSP

    I have a jsp page, where I will invoke a WebService call, which will return           a big XML object back to me, of which I need to select few key-value pair as           display item in a table only as result.           Any idea how to achieve thi

  • How many films can I put on an ipad 2 64 gb

    How many films can you fit on a ipad 2 64 gb, what is the best method of putting your dvds onto it?

  • Why does "autofill from playlist" not work?

    I have tried to autofill music onto my iphone from a playlist, but it will not allow me to, and gives a really unhelpful error message: "iTunes cannot add any songs to the iPhone "x" because no songs in the playlist "x" can be copied to this iPhone."