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

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 ...

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.

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();



        }
    });

    }
}
View Answers









Related Tutorials/Questions & Answers:
delete app from iphone
delete app from iphone  How to delete an existing app from itunes
Radio Buttons - Java Beginners
Radio Buttons  Hello Sir, How to create the code for the password recovery page(like forgot gmail password question and answer page)using the radion buttons in display the same page in jsp.I need only how to make the question
Advertisements
buttons in netbeans,java
buttons in netbeans,java  respected sir, i would like to known how to make coding on a button while working on netbeans, so that a new window will open after clicking on that button? thank you   import java.awt.
Buttons
Buttons  I have created a web page with radio button group with two radio buttons for accepting the home appliances categories,Kitchen appliances and other appliances.I want to check for the appliance chosen when the required
Java duplicate elements
Java duplicate elements  Which class has no duplicate elements
Multiple buttons in struts using java script
Multiple buttons in struts using java script  Multiple buttons in struts using java script
Java delete file if exists
Java delete file if exists  Hi, Hi how to delete file if exists? I need example code of java delete file if exists. Thanks   Hi, following code can be used: String tempFile = "C:/mydir/myfile.txt"; //Delete
java list program for common elements
java list program for common elements  hi I want program using java collections list which takes two array list elements and display common elements in both the list as an output   Please visit the following link
Java arraylist duplicate elements search
Java arraylist duplicate elements search  hi, please help me finding the no of duplicates elements in an arraylist example an arraylist contains elements like: mac raj mohan frank mac tom raj mohan frank result: mac 2 raj
ModuleNotFoundError: No module named 'django-reorder'
ModuleNotFoundError: No module named 'django-reorder'  Hi, My... named 'django-reorder' How to remove the ModuleNotFoundError: No module named 'django-reorder' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'pytest-reorder'
ModuleNotFoundError: No module named 'pytest-reorder'  Hi, My... named 'pytest-reorder' How to remove the ModuleNotFoundError: No module named 'pytest-reorder' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'django-reorder'
ModuleNotFoundError: No module named 'django-reorder'  Hi, My... named 'django-reorder' How to remove the ModuleNotFoundError: No module named 'django-reorder' error? Thanks   Hi, In your python
What are Basic Java Language Elements?
What are Basic Java Language Elements?  Hello, I have learned... Elements. What are Basic Java Language Elements? Which is good tutorials of Java Language Elements? Thanks   Hi, Here are the details of Basic Java
ARRAY ELEMENTS - Java Interview Questions
ARRAY ELEMENTS  How To Find Out Missing Elements {1,2,3,4,5,to 100}?I Want Source Code
How to delete file in Java code?
How to delete file in Java code?  Hi, From my Java program I have to delete a file. How to delete file in Java code? Thanks   Hi, Java API provides methods for deleting a file in Java. You can use the delete
DELETE
DELETE   I AM DOING IT IN MYSQL. DELETE FROM EMP WHERE SAL>(SELECT SAL FROM EMP WHERE ENAME='MILLAR') AND ENAME='ALLEN'; THIS IS GIVING THE FOLLOWING ERROR Error Code : 1093 You can't specify target table 'EMP
Java radio buttons and button groups two values
Java radio buttons and button groups two values  hi i have a problem. i have a system to input data from a jform to a mysql database. i have made all of it except the gender radiobuttons. how do i do this? i need when register
Java radio buttons and button groups two values
Java radio buttons and button groups two values  hi i have a problem. i have a system to input data from a jform to a mysql database. i have made all of it except the gender radiobuttons. how do i do this? i need when register
java - file delete - Java Beginners
java - file delete  I will try to delete file from particular folder... will try to delete these files. But it doesn?t delete from this folder. My code...){ try { File delete = new File (incurrentFile); System.out.println
java - file delete - Java Beginners
java - file delete  I will try to delete file from particular folder... will try to delete these files. But it doesn?t delete from this folder. My code...){ try { File delete = new File (incurrentFile); System.out.println
ModuleNotFoundError: No module named 'reorder-python-imports'
ModuleNotFoundError: No module named 'reorder-python-imports'  Hi...: No module named 'reorder-python-imports' How to remove the ModuleNotFoundError: No module named 'reorder-python-imports' error? Thanks   Hi
ModuleNotFoundError: No module named 'django-modeladmin-reorder'
ModuleNotFoundError: No module named 'django-modeladmin-reorder'  Hi...: No module named 'django-modeladmin-reorder' How to remove the ModuleNotFoundError: No module named 'django-modeladmin-reorder' error? Thanks  
How to delete file in java ?
How to delete file in java ? In this section we will learn how to write a program to delete a file in java. You can delete the file or folder, java File..._TO_REPLACE_1 Now, here is the code to delete a file in java. import
delete
delete  how delete only one row in the database using jsp.database...;td><input type="button" name="edit" value="Delete" style="background-color..."); Statement st = conn.createStatement(); st.executeUpdate("DELETE FROM employee
Interview Questions - What are important Java Language Elements?
Interview Questions - What are important Java Language Elements?  Hi, What are important Java Language Elements? Thanks   Hi, Java... Static Members Example of all these can be seen at Basic Java Language Elements
How to delete .xlsx file in java?
How to delete .xlsx file in java?  Hello Sir, I am unable to delete .xlsx file using below code, What is wrong here? if(myFile != null && myFile.exists()    && myFile.canRead() &&
Delete Internet Explorer History in java program
Delete Internet Explorer History in java program  code for Delete Internet Explorer History in java program
J2ME delete file - Java Beginners
J2ME delete file  How do i delete a textfile on a mobile phone using j2me?  Hi Friend, Please visit the following link: http://www.roseindia.net/j2me/ Hope that it will be helpful for you. Thanks
How to delete files in Java?
Delete a File using File Class Object       Delete a File using File Class Object In this section, you will learn how to delete a file. 
Delete specific lines from text in Java
Delete specific lines from text in Java  Hi, beginning in java, i'm trying to delete specific line from a text file. Ex: i want to delete data... number that i want to delete. how could it be possible with java. thanks a lot
Multiple submit buttons in single xhtml form - Java Server Faces Questions
Multiple submit buttons in single xhtml form  Hi all, Here I am attaching the source of the page , which containig two submit buttons. Somebody suggested to keep eaxh button in different form. I am new to JSF, can anyone split
Client Server Java app
Client Server Java app  I developed a client server based java networking Instant Messaging app. The client program is needed to be run on the client... heroku techniques for java but its hard for me to understand
Java file delete
Java file delete In this section, you will learn how to delete a file. Description of code Java makes file manipulation easier by providing many useful... we are going to delete a file. For this, we have created an object of File
java buttons - Swing AWT
java buttons  There are 3 buttons in a window....A,B,C.If a user clicks button A ,a clue is given to him leading to button B.After the user clicks...); f.getContentPane().add(p1); final JPanel p2 = (JPanel) f.getGlassPane
How to delete line starting with a letter in java Regex?
How to delete line starting with a letter in java Regex?  Hi, i 'm trying to code with regex and java. i want to know how it's possible to delete lines which starts with a letter like G or g in a text. i tried
delete a node from singly linked list in java
delete a node from singly linked list in java  Write a program(in java), if given a pointer to a node (not the tail node) in a singly linked list, delete that node from the linked list.   could you tell your question
Shift Array Elements in Java
Java Shift Array Elements This section illustrates you how to shift the array elements in a circular way. For this, first of all, we have allowed the user to enter the array elements,  the direction of shifting (Right or Left
How can I Define a JFrame subclass that has four vertically positioned buttons. - Java Beginners
How can I Define a JFrame subclass that has four vertically positioned buttons... positioned buttons. The labels for the four buttons are Senior, Junior, Sophomore...; public DisplayButtons(){ JButton[] buttons = new JButton[4]; panel=new JPanel(new
ModuleNotFoundError: No module named 'odoo8-addon-account-invoice-reorder-lines'
ModuleNotFoundError: No module named 'odoo8-addon-account-invoice-reorder-lines...: ModuleNotFoundError: No module named 'odoo8-addon-account-invoice-reorder-lines...-invoice-reorder-lines' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'odoo8-addon-account-invoice-reorder-lines'
ModuleNotFoundError: No module named 'odoo8-addon-account-invoice-reorder-lines...: ModuleNotFoundError: No module named 'odoo8-addon-account-invoice-reorder-lines...-invoice-reorder-lines' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'odoo8-addon-purchase-order-reorder-lines'
ModuleNotFoundError: No module named 'odoo8-addon-purchase-order-reorder-lines...: ModuleNotFoundError: No module named 'odoo8-addon-purchase-order-reorder-lines' How...-order-reorder-lines' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'odoo8-addon-stock-picking-reorder-lines'
ModuleNotFoundError: No module named 'odoo8-addon-stock-picking-reorder-lines...: ModuleNotFoundError: No module named 'odoo8-addon-stock-picking-reorder-lines' How...-reorder-lines' error? Thanks   Hi, In your python
Displatying java script form submitted elements in another page
Displatying java script form submitted elements in another page   hi I want java script and html code for displaying the values in other pager after submitting the registration form. I want to get the values after submitting
How to Display Duplicate elements from more than one List in java?
How to Display Duplicate elements from more than one List in java?  How to Display Duplicate elements from more than one List in java? //I mean common elements from two List? Ex: List a1=new ArrayList(); a1.add(50
Remove multiple elements in arraylist
Remove multiple elements in arraylist   how can we remove multiple values in arrayList? only remove method we used for single remove.but i want to delete multiple value in arrayList
Delete Account
Delete Account  How to delete account
ModuleNotFoundError: No module named 'buttons'
ModuleNotFoundError: No module named 'buttons'  Hi, My Python... 'buttons' How to remove the ModuleNotFoundError: No module named 'buttons... to install padas library. You can install buttons python with following command
Maven dependency for net.e6tech - elements-common version 2.6.37 is released. Learn to use elements-common version 2.6.37 in Maven based Java projects
use this version ( net.e6tech - elements-common version 2.6.37 ) in their Java...Maven dependency for  net.e6tech  - Version 2.6.37 of elements-common released The developers of   net.e6tech - elements-common project
Maven dependency for net.e6tech - elements-common version 1.8.10 is released. Learn to use elements-common version 1.8.10 in Maven based Java projects
use this version ( net.e6tech - elements-common version 1.8.10 ) in their Java...Maven dependency for  net.e6tech  - Version 1.8.10 of elements-common released The developers of   net.e6tech - elements-common project
Maven dependency for net.e6tech - elements-common version 2.6.36 is released. Learn to use elements-common version 2.6.36 in Maven based Java projects
use this version ( net.e6tech - elements-common version 2.6.36 ) in their Java...Maven dependency for  net.e6tech  - Version 2.6.36 of elements-common released The developers of   net.e6tech - elements-common project

Ads