Results 1 to 7 of 7
  1. #1
    bigj is offline Member
    Join Date
    Dec 2009
    Posts
    68
    Rep Power
    0

    Default shrinking components when a JSplitPane moves or slided

    Java Code:
    package xxTestxx;
    
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.table.TableModel;
    
    @SuppressWarnings("serial")
    public class InventoryTEST2 extends JFrame {
    
      private JTable inventoryTable;
      private JPanel lowerPanel;
      private JPanel upperPanel;
      private JScrollPane scroll;
      private JSplitPane split;
      private JButton btn;
      
      public InventoryTEST2() {
          
        initializeInventory();
      }
    
    
      private void initializeInventory() {
    
          btn = new JButton();
    
          lowerPanel = new JPanel();
          upperPanel = new JPanel();
    
          
          upperPanel.setLayout(null);
          lowerPanel.setLayout(null);
    
          final String[] columnNames = {"Item Csode", "Item Desciption", "Item Quantity", "Item Cost",
                                          "Cost Extension", "Retail", "Retail Extension", "Expiration Code"};
    
          final Object[][] data = new Object[100][columnNames.length];
    
          inventoryTable = new JTable(data, columnNames);
          inventoryTable.setOpaque(false);
    
          scroll = new JScrollPane(inventoryTable);
          scroll.setBounds(0, 0, 1395, 400);
    
          btn.setBounds(150, 150, 250, 100);
    
          lowerPanel.add(scroll);
          upperPanel.add(btn);
    
          split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, upperPanel, lowerPanel);
          split.setDividerLocation(500);
    
          getContentPane().add(split);
    
          setDefaultCloseOperation(EXIT_ON_CLOSE);
          setTitle("Inventory Window");
          setSize(1400, 800);
          setLocationRelativeTo(null);
          setVisible(true);
      }
    
      public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
          public void run() {
            new InventoryTEST2();
          }
        });
      }
    }
    I presume that is not an easy task to do.. I tried to search at google but I dont see any appropriate or good results in my problem.

    how can I resolve this one..? any help would be appreciated... thank you :o

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,574
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Fubarable View Post
    How can you resolve what? Please provide a little bit of a description of your problem, perhaps a paragraph or two. Details can be important.
    Luck.
    Maybe it's about that button in the north JPanel; it doesn't move nor resizes when the panel is resized which doesn't surprise me because that panel doesn't have a layout manager. Even a simple BorderLayout with the JButton in the center position and surrounded by, say, struts can solve this.

    kind regards,

    Jos

  3. #3
    bigj is offline Member
    Join Date
    Dec 2009
    Posts
    68
    Rep Power
    0

    Default

    oh no , im not using any layout manager, its very complicated to me for me to use any layout managers, i use to set the properties and locations of my component manually, oh no.... anyway sir thank you sir , It helped me.. :o

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

    Default

    Quote Originally Posted by bigj View Post
    oh no , im not using any layout manager, its very complicated to me for me to use any layout managers, i use to set the properties and locations of my component manually, oh no.... anyway sir thank you sir , It helped me.. :o
    Then that's your problem. If you want to have components do complex layout type actions, then you'd best start studying the layout manager tutorials. Kind of makes sense, no?

  5. #5
    bigj is offline Member
    Join Date
    Dec 2009
    Posts
    68
    Rep Power
    0

    Default

    oh sir,, as a beginner with Layout managers, what layout would you suggest to me to study and suits my needs In my level right now? just want to ask for some opnion.

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

    Default

    Start with:

    FlowLayout
    BorderLayout
    GridLayout
    BoxLayout

    Then later check out:
    GridBagLayout
    MiGLayout (you need to download this one, but it's worth it).

  7. #7
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,574
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by bigj View Post
    oh sir,, as a beginner with Layout managers, what layout would you suggest to me to study and suits my needs In my level right now? just want to ask for some opnion.
    Did you read Sun's Swing Tutorial? It has quite a bit of (runnable) code to play with and it carefully explains the different layout managers, simple and complex ones.

    kind regards,

    Jos

Similar Threads

  1. Bishops moves
    By michail in forum New To Java
    Replies: 5
    Last Post: 01-28-2010, 09:33 PM
  2. JSplitPane Arranging Components(JTree) Doubt
    By hemanthjava in forum AWT / Swing
    Replies: 0
    Last Post: 08-03-2008, 08:29 AM
  3. JSplitPane nightmare
    By SwinGirl in forum SWT / JFace
    Replies: 1
    Last Post: 05-01-2008, 08:24 PM
  4. Replies: 1
    Last Post: 02-16-2008, 11:22 PM
  5. I need create a JSplitPane
    By Daniel in forum AWT / Swing
    Replies: 1
    Last Post: 07-05-2007, 06:12 AM

Posting Permissions

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