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

Ads
 

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

Ads









Related Tutorials/Questions & Answers:
delete app from iphone
delete app from iphone  How to delete an existing app from itunes
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.
Advertisements
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
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
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
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
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
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
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
Delete Internet Explorer History in java program
Delete Internet Explorer History in java program  code for Delete Internet Explorer History in java program
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.... Now, here is the code to delete a file in java. import java.io.File; public
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() &&
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
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
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
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
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 '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
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
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  
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
retrieve data from database in java swing form using prev n next buttons
retrieve data from database in java swing form using prev n next buttons  i have a database having columns id(int),path(text),width(int),height(int... shown. a delete button should also be there so as to delete certain record.after
retrieve data from database in java swing form using prev n next buttons
retrieve data from database in java swing form using prev n next buttons  i have a database having columns id(int),path(text),width(int),height(int... shown. a delete button should also be there so as to delete certain record.after
Basic Java Language Elements
Basic Java Language Elements       Java keyboards There are few keywords in Java programming... in the program.   Java Comments To comprehend any programming language
java app
java app  create an applet to display the Fibonacci numbers  ... numbers do you want in Series: "); label1.setBounds(20,20,250,20); add(label1); text=new TextField(20); text.setBounds(300,20,100,20); add(text

Ads