Results 1 to 8 of 8
  1. #1
    Addez is offline Senior Member
    Join Date
    Aug 2009
    Posts
    294
    Rep Power
    0

    Default GridBagLayout is centerd and I cant change it :(

    Hai!
    I try to make my grid to start from the top of the JInternalWindow and
    then when I add a row, then that row is added below all the other rows.

    Now that doesnt happen!
    All rows are centerd in the middle and if I add a line, it still makes em fit in the middle!!
    I'v set:
    the GridBagConstraints c
    c.anchor = GridBagConstraints.NORTH;
    Doesnt help.
    c.fill = GridBagConstraints.NORTH;
    doesnt help either..
    What am I doing wrong?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    I think that you'll need to show us more code, hopefully a small compilable and runnable bit of code, an SSCCE.

    edit: also as far as I recollect, fill shouldn't be NORTH but rather HORIZONTAL, VERTICAL, BOTH, or NONE. Also, when I hear of things bunching up in the center of a GBL component, the first thing I think of is that the weights haven't been properly set. But again, we'll need to see what you're doing with all the constraints to know how to fully help you.

    Best of luck
    Last edited by Fubarable; 08-28-2010 at 04:05 PM.

  3. #3
    Addez is offline Senior Member
    Join Date
    Aug 2009
    Posts
    294
    Rep Power
    0

    Default

    Okej.. Well, nvm that then..
    Because my Gui is splitted and got LOADS of classes that would need to be combined..

    I'm almoste lost in my own scripts :P

    Well, the program is soon done so it doesnt mather..

    BUT!
    I would need help with this:
    Java Code:
    public static String getString(String q){
    		
    		String someString = JOptionPane.showInputDialog(q);
    		return someString;
    	}
    That method returns a string yes, but not the last typed in string!

    Idk why but for some reason, I run this and it works.
    Then I shutdown down and then use that function writing another string.
    Then it returns the first string I wrote in the first debug test!

    Idk why but I always get the value I typed the debugtest before!

    Anyy ideas why?
    T

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by Addez View Post
    Okej.. Well, nvm that then..
    Because my Gui is splitted and got LOADS of classes that would need to be combined..
    OK, and hopefully this means that you've solved this issue, but if not and you're still stuck, all you would need to do is extract out the relevant parts into a small GUI that creates rows of components and adds a row on button push.

    BUT!
    I would need help with this:
    Java Code:
    public static String getString(String q){
    		
    		String someString = JOptionPane.showInputDialog(q);
    		return someString;
    	}
    That method returns a string yes, but not the last typed in string!

    Idk why but for some reason, I run this and it works.
    Then I shutdown down and then use that function writing another string.
    Then it returns the first string I wrote in the first debug test!

    Idk why but I always get the value I typed the debugtest before!

    Anyy ideas why?
    T
    I don't know, as it works fine for me. I suspect that your error lies elsewhere in your code. Again, an SSCCE would greatly aid us in helping to solve this.

    Luck!

  5. #5
    Addez is offline Senior Member
    Join Date
    Aug 2009
    Posts
    294
    Rep Power
    0

    Default

    Okej, Ill do that if I cant find a solution soon enough.
    But for the getString method error, I figured out thats not the problem.

    The problem is here:
    Java Code:
    Statement statement = conn.createStatement();
    		statement.execute("ALTER TABLE "+dbName+" ADD COLUMN "+ColumnName+" VARCHAR(30)");
    dbName = Database name
    Now what this is suppose to do is add a column.
    It does, if you execute it twice :P

    I think I might know why, but Dunno how to fix it..
    I think I have to, sorta, reinitiate the database?

    To get the Database I do this:
    Java Code:
    public static SqlManager getDB(String name) throws ClassNotFoundException{
    		setDBSystemDir();
    		Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
    		Connection dbConnection = null;
    		String strUrl = "jdbc:derby:DefaultAddressBook;create=true";
    
    		try {
    		    dbConnection = DriverManager.getConnection(strUrl);
    		    System.out.println("Got database");
    		    createTables(dbConnection,name);
    		} catch (SQLException ex) {
    		    ex.printStackTrace();
    		}
    Something there that needs to be done again for each time I add a column?

  6. #6
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default

    Quote Originally Posted by Addez View Post
    Hai!
    I try to make my grid to start from the top of the JInternalWindow and
    then when I add a row, then that row is added below all the other rows.

    Now that doesnt happen!
    All rows are centerd in the middle and if I add a line, it still makes em fit in the middle!!
    I'v set:
    the GridBagConstraints c
    c.anchor = GridBagConstraints.NORTH;
    Doesnt help.
    c.fill = GridBagConstraints.NORTH;
    doesnt help either..
    What am I doing wrong?
    weight method might be your friend here

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

  8. #8
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default

    Quote Originally Posted by Fubarable View Post
    as mentioned in post #2.
    Sorry fubarable just read your post now.

Similar Threads

  1. [AWT] GridBagLayout Help.
    By Sandia_man in forum AWT / Swing
    Replies: 2
    Last Post: 05-23-2010, 09:54 PM
  2. help with gridbaglayout
    By robertbob in forum AWT / Swing
    Replies: 5
    Last Post: 05-18-2010, 05:14 AM
  3. GridBagLayout
    By newtojava7 in forum New To Java
    Replies: 2
    Last Post: 03-07-2008, 01:16 AM
  4. GridBagLayout...please help
    By newtojava7 in forum Advanced Java
    Replies: 1
    Last Post: 02-17-2008, 02:16 AM
  5. gridbaglayout
    By newtojava7 in forum New To Java
    Replies: 4
    Last Post: 01-27-2008, 09:03 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •