Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Java App - Add, Delete, Reorder elements of the buttons
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Ali
Java App - Add, Delete, Reorder elements of the buttons
0 Answer(s)      3 years and 10 months ago
Posted in : Java Beginners


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



        }
    });

    }
}

Advertisement
View Answers

Related Tutorials/Questions & Answers:
delete app from iphone
delete app from iphone  How to delete an existing app from itunes
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
Advertisements
Java duplicate elements
Java duplicate elements  Which class has no duplicate elements
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
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
Multiple buttons in struts using java script
Multiple buttons in struts using java script  Multiple buttons in struts using java script
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 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
ARRAY ELEMENTS - Java Interview Questions
ARRAY ELEMENTS  How To Find Out Missing Elements {1,2,3,4,5,to 100}?I Want Source Code
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 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
Help needed on java standalone app and default browser interaction.
Help needed on java standalone app and default browser interaction.  Hi Developers and tutors, Is anyone able to guide on how am i able to extract the url thats displaying on my default browser to my java standalone application
how to establish connection b/w java app and mobile phone
how to establish connection b/w java app and mobile phone  hello... to send SMS from our phone to a java application situated on a remote server... i.e.., we don't know how to send and receive SMS to java server.We don't know what
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() &&
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
Java Shapes Bouncing App
Java Shapes Bouncing App  hi guys, im trying to implement the following into my java app code: Here's my code: first ill post the main class... contains start and stop * buttons that starts animation and stops animation
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
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
How to delete and update from Jtable cell in swing app
How to delete and update from Jtable cell in swing app  Hii Sir, I am developing a swing app for adding,updating and deleting from jtable... on delete button on selecting particular row which has to be deleted then last row
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. 
How can I open my Java desktop app by clicking on its file?
How can I open my Java desktop app by clicking on its file?  How can I open my Java desktop app by clicking on the file it creates? This app creates... for this app. For instance, imagine I create an editor app called BlueSky
delete
delete  how delete only one row in the database using jsp.database... type="button" name="edit" value="Delete" style="background-color:red;font-weight... = conn.createStatement(); st.executeUpdate("DELETE FROM employee WHERE empid
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
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
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
 

 

 

DMCA.com