Results 1 to 4 of 4
  1. #1
    alibm's Avatar
    alibm is offline Member
    Join Date
    Mar 2011
    Posts
    28
    Rep Power
    0

    Red face Java App - Add, Delete, Reorder elements of the buttons

    Hello,

    I'm developing a Java application.

    I created this interface with MockupScreens.
    Please look at these pictures.






    At first time, there's only one element, the user have to enter informations (title and description) then he starts adding elements as he needs. He can edit element infomrations at any time by clicking on "Element N" Button.
    He can too delete an element or change the order of these elements ...

    How can I do to create something like the pictures up????? :(:(:(:confused::confused:

    Thanks in advance. Best regards, Ali.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,041
    Rep Power
    10

    Default

    Which part of this are you stuck on? The layout looks like a job for a BoxLayout. Just keep a List of JPanels or elements or whatever, and add them to the JPanel in the order you want them.

    Asking "how do I do this" isn't really a question we can answer. If you want help, you'll have to ask a more specific question that has to do with one part of this problem.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    alibm's Avatar
    alibm is offline Member
    Join Date
    Mar 2011
    Posts
    28
    Rep Power
    0

    Red face

    I get an idea,


    Let us put these buttons in a JPanel called btnsUnit, then manipulate it by adding, removing and reodering... So a Grid Layout will be efficient to add each panel after each one ..

    Thats why I created a new JPanel which will contain an unknown number of ListbtnsUnit JPanel, I fixed 10 as the max number.

    I'm just doing these steps when you reply me.
    I didn't arrived to add btnsUnit JPanel in ListbtnsUnit JPanel.



    Java Code:
     
    import java.awt.BorderLayout;
    import java.awt.EventQueue;
    
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.border.EmptyBorder;
    import java.awt.Color;
    import java.awt.GridLayout;
    import javax.swing.JButton;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import javax.swing.JTextField;
    
    
    public class setupDeviceList extends JFrame {
    
    	private JPanel contentPane;
    
    	/**
    	 * Launch the application.
    	 */
    	public static void main(String[] args) {
    		EventQueue.invokeLater(new Runnable() {
    			public void run() {
    				try {
    					setupDeviceList frame = new setupDeviceList();
    					frame.setVisible(true);
    				} catch (Exception e) {
    					e.printStackTrace();
    				}
    			}
    		});
    	}
    
    	/**
    	 * Create the frame.
    	 */
    	public setupDeviceList() {
    		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		setBounds(100, 100, 742, 335);
    		contentPane = new JPanel();
    		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    		setContentPane(contentPane);
    		contentPane.setLayout(null);
    		
    		 final JPanel ListbtnsUnit = new JPanel();
    		ListbtnsUnit.setBackground(Color.RED);
    		ListbtnsUnit.setBounds(55, 56, 243, 191);
    		contentPane.add(ListbtnsUnit);
    		ListbtnsUnit.setLayout(new GridLayout(10, 0));
    		
    		
    		final JButton btnAdd = new JButton("Add");
    		btnAdd.setBounds(161, 11, 56, 23);
    		btnAdd.setVisible(true);
    		
    		
    		btnAdd.addActionListener(new ActionListener() {
    			public void actionPerformed(ActionEvent arg0) {
    				
    				final JPanel btnsUnit = new JPanel();
    				btnsUnit.setBounds(343, 71, 243, 147);
    				contentPane.add(btnsUnit);
    				btnsUnit.setBackground(Color.ORANGE);
    				btnsUnit.setLayout(null);
    				btnsUnit.add(btnAdd);
    				
    				ListbtnsUnit.add(btnsUnit);
    				ListbtnsUnit.revalidate();
    				ListbtnsUnit.repaint();
    
    
    				
    			}
    		});
    		
    		
    
    		 
    		
    	}
    
    }

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,041
    Rep Power
    10

Similar Threads

  1. Trigger cmd to delete a file in java program
    By hari.kr in forum Advanced Java
    Replies: 4
    Last Post: 04-28-2010, 08:37 PM
  2. Replies: 2
    Last Post: 04-20-2009, 09:00 AM
  3. [SOLVED] delete elements
    By kuhok in forum New To Java
    Replies: 3
    Last Post: 03-31-2009, 09:33 PM
  4. delete a line from a text file in Java
    By ddatta8 in forum New To Java
    Replies: 2
    Last Post: 01-24-2009, 06:08 AM
  5. Can I delete/uninstall older versions of Java?
    By LudwigKarl in forum New To Java
    Replies: 3
    Last Post: 03-19-2008, 11:23 AM

Tags for this Thread

Posting Permissions

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