adding the delete code
hello sir...
i need to add a delete button to my code but i didn't know where can i put it..
i've tried but still not working..
please help me...this is the code..
package newproject1;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
import javax.swing.*;
public class DisplayInfo extends JFrame implements ActionListener
{
private String fileName;
private Scanner input = null;
private Container container;
private JPanel panel1, panel2, panel3;
private JButton sortBut,delBut;
private FlowLayout panel1L, panel2L, panel3L;
private BorderLayout containerL;
private JTextArea ta1, taUN, taPWD, taAPP;
private JScrollPane pane;
private JMenuBar menuBar;
private JMenu menu;
private JMenuItem menuSort, menuBack;
private Font displayFont;
//constructor
public DisplayInfo ()
{
//set frame title
setTitle("EASY ACCESS");
//set size
setSize(510,620);
//set frame close operation
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//set frame to be visible
setVisible(true);
//Create Font
displayFont = new Font("Serif", Font.BOLD, 14);
//Create text field
taUN = new JTextArea(1,13);
taPWD = new JTextArea (1,13);
taAPP = new JTextArea(1,13);
taUN.append("USERNAME");
taPWD.append("PASSWORD");
taAPP.append("APPICATION");
//Create Button
sortBut = new JButton ("Sort by UserName");
delBut = new JButton ("Delete");
//create text area
ta1 = new JTextArea(30, 43);
//Create Panel
panel1 = new JPanel();
panel2 = new JPanel();
panel3 = new JPanel();
//Create Layout
panel1L = new FlowLayout();
panel2L = new FlowLayout();
panel3L = new FlowLayout ();
containerL = new BorderLayout();
//create JScrollPane
pane = new JScrollPane(panel2);
//Create menu bar
menuBar = new JMenuBar();
menuBar.setBackground(Color.cyan);
//Create menu
menu = new JMenu("File");
//Create menu item
menuSort = new JMenuItem("Sort By UserName");
menuSort.setBackground(Color.CYAN);
menuBack = new JMenuItem("Back to InsertData");
menuBack.setBackground(Color.CYAN);
//set editable false to all text areas
ta1.setEditable(false);
taUN.setEditable(false);
taPWD.setEditable(false);
taAPP.setEditable(false);
//set background to text areas
taUN.setBackground(Color.yellow);
taPWD.setBackground(Color.BLUE);
taAPP.setBackground(Color.green);
//set Font for taUN, taPWD and taAPP
taUN.setFont(displayFont);
taPWD.setFont(displayFont);
taAPP.setFont(displayFont);
//set background to all panels
panel1.setBackground(Color.cyan);
panel2.setBackground(Color.cyan);
panel3.setBackground(Color.cyan);
//set Mnemonic for menu item
menuSort.setMnemonic('S');
menuBack.setMnemonic('B');
//set Mnemonic for button
sortBut.setMnemonic('S');
delBut.setMnemonic('D');
//set Accelerator for menu item
menuSort.setAccelerator(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.Event.CTRL_MASK));
menuBack.setAccelerator(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_B, java.awt.Event.CTRL_MASK));
//set top and bottom layout
panel1.setLayout(panel1L);
panel2.setLayout(panel2L);
panel3.setLayout(panel3L);
//get all component
container = getContentPane();
//set container layout
container.setLayout(containerL);
//Add label and text field onto panel 2
panel1.add(taUN);
panel1.add(taPWD);
panel1.add(taAPP);
//Add text field onto panel 2
panel2.add(ta1);
//Add text field onto panel 3
panel3.add(sortBut);
panel3.add(delBut);
//Add menu items to menu
menu.add(menuSort);
menu.add(menuBack);
//Add menu to menu bar
menuBar.add(menu);
//Add menu bar to JFrame
setJMenuBar(menuBar);
//Add listener to all menu items
menuSort.addActionListener(this);
menuBack.addActionListener(this);
//add listener button
sortBut.addActionListener(this);
//add panel onto container
container.add(pane,BorderLayout.CENTER);
container.add(panel3,BorderLayout.SOUTH);
container.add(panel1,BorderLayout.NORTH);
try
{
fileName = "User.dat";
input = new Scanner(new FileInputStream(fileName));
while(input.hasNext())
{
ta1.append(input.nextLine() + "\n");
}
input.close();
}
catch(FileNotFoundException fnfe)
{
System.err.println("Couldn't Find " + fileName + " !!");
}
{
System.err.println("An Error has been occured!! ");
}
}
@Override
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource() == sortBut)
{
try
{
ArrayList<String> rows = new ArrayList<>();
FileWriter writer;
try (BufferedReader reader = new BufferedReader(new FileReader("User.dat"))) {
String s;
while((s = reader.readLine())!=null)
rows.add(s);
Collections.sort(rows);
writer = new FileWriter("User.dat");
for(String cur: rows)
writer.write(cur+"\n");
}
writer.close();
fileName = "User.dat";
input = new Scanner(new FileInputStream(fileName));
ta1.setText(null);
while(input.hasNext())
{
ta1.append(input.nextLine() + "\n");
}
input.close();
}
catch(Exception e)
{
}
}
String menuCommand = ae.getActionCommand();
//Event handler for menu item
if(ae.getSource() instanceof JMenuItem){
switch (menuCommand) {
case "Sort By UserName":
try
{
ArrayList<String> rows = new ArrayList<>();
FileWriter writer;
try (BufferedReader reader = new BufferedReader(new FileReader("User.dat"))) {
String s;
while((s = reader.readLine())!=null)
rows.add(s);
Collections.sort(rows);
writer = new FileWriter("Usert.dat");
for(String cur: rows)
writer.write(cur+"\n");
}
writer.close();
fileName = "User.dat";
input = new Scanner(new FileInputStream(fileName));
ta1.setText(null);
while(input.hasNext())
{
ta1.append(input.nextLine() + "\n");
}
input.close();
}
catch(Exception e)
{
}
break;
case "Back to InsertData":
//calling the method openInsertData
openInsertData();
//set the DisplayInfo to not appear when InsertData is opened
setVisible(false);
break;
}
}
}
public void openInsertData()
{
//open InsertData
new InsertData();
}
}
View Answers
May 17, 2012 at 7:26 PM
but sir,my program is not using database...i dont know where to put the coding....
Related Tutorials/Questions & Answers:
adding the delete codeadding the
delete code hello sir...
i need to add a
delete button to my
code but i didn't know where can i put it..
i've tried but still not working..
please help me...this is the
code..
package newproject1;
import java.awt.
Adding checkbox in table using that delete table rowsAdding checkbox in table using that
delete table rows I need coding for how to add checkbox in table,the table data from database.Using that checkbox select more than than one rows,and using
delete button i want to
delete Advertisements
Example code of adding placeholder in UItextFeildExample
code of
adding placeholder in UItextFeild Ho to add add the placeholder text in UITextField in IOS program programmatically?
Thanks
... is the
code example:
mytext.placeholder = @"Enter User Name";
Thanks
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... complete example
code at How to
delete file in Java?.
Thanks
Hi,
Also
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
deletedelete how
delete only one row in the database using jsp.database is mysql
Hi Friend,
Try the following
code:ADS_TO_REPLACE_1
1...;td><input type="button" name="edit" value="
Delete" style="background-color
Delete row and column from table through java code Delete row and column from table through java
code... will see how to
delete row and
column from given table through java
code. Java
code... |
+----+----------+------------+---------+
In this table we will
delete the row having minimum
value of ID then
delete adding a dialogueadding a dialogue Blockquote
Hi can you help with the program below,the program is a loop that prints out a
code and a quantity when prompt for the user input.what I need is to modify the
code to incorporate a dialogue asking
adding loopadding loop Hi I have a program that is not compiling when I add...;
class HardwareItems
{
String
code;
String description;
double price;
HardwareItems(String
code,String description,double price
Array Delete Array
Delete
In this Tutorial we want to describe you a
code that make you to understand
Array
Delete Example. For this we are using JavaScript
To delete postTo
delete post How can I
delete my old post answer. I've posted 2 same answers by mistake
Adding JTable into existing Jframe.Adding JTable into existing Jframe. i need to add JTable into this
code pls help me..
package Com;
import Com.Details;
import java.awt.Color...");
JButton
delete=new JButton("
DELETE");
JButton save=new JButton("SAVE");
JButton
Adding JTable into existing Jframe.Adding JTable into existing Jframe. i need to add JTable into this
code pls help me..
package Com;
import Com.Details;
import java.awt.Color...");
JButton
delete=new JButton("
DELETE");
JButton save=new JButton("SAVE");
JButton
Adding JTable into existing Jframe.Adding JTable into existing Jframe. i need to add JTable into this
code pls help me..
package Com;
import Com.Details;
import java.awt.Color...");
JButton
delete=new JButton("
DELETE");
JButton save=new JButton("SAVE");
JButton
delete rowdelete row how to
delete row using checkbox and button in php?
localhost=wampserver
database name=sourabh
table name=sonu
and my
code...="
delete" >
<table width="100%" border="1">
<tr><td>
delete jspdelete jsp <%@ page language="java" contentType="text/html...; charset=ISO-8859-1">
<title>
Delete Student</title>
</head>...;/Controller">
<input type="hidden" name="page" value="
delete"/>
<
Hibernate delete example program() method of the Session object.
Here is the sample
code:
//
Delete the object...Hibernate
delete example program How to
delete an object in Hibernate? In my program I have to write program to
delete the data using Hibernate
delete recorddelete record how to
delete record using checkbox and button in php
We are providing you the jsp
code that displays the database table...=conn.createStatement();
for(int a=0;a<10;a++){
st.executeUpdate("
delete from book where
Java delete file if existsJava
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 Delete points from databaseDelete points from database I have a polygon on a web page and a
delete button. The polygon is saved in the database in one table and in another... the
delete button, the polygon in the webpage gets deleted as well as the polygon
JPA delete query - EJBJPA
delete query Hi,
I have an entity InvoiceItems.java. I want to
delete all the records from the table. What will be the JPA query to
delete....
Deleting all the records (enteties) is very easy.
You can use the following
code Java file deleteJava 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
delete row using iddelete row using id package pkg2;
import org.hibernate.Query;
import... = "
delete from Insurance insurance where id = 2";
Query query = sess.createQuery...());
}
}
}
this is the
code m using .
Error is -query must begin with SELECT or FROM
how to delete a letter in a word?how to
delete a letter in a word? how to
delete a letter in a word?
for example
if i enter= roseindia,
i want to
delete 's',
then output= roeindia
Adding images in itext pdfAdding images in itext pdf Hi,
How to add image in pdf file using itext?
Thanks
Hi,
You can use following
code:
PdfWriter.getInstance(document,new FileOutputStream("imagesPDF.pdf"));
Read more at Inserting
Adding two numbersAdding two numbers Accepting value ffrom the keyboard and
adding two numbers
What is the Delete Statements in SQL?What is the
Delete Statements in SQL? What is the
Delete Statements in SQL?
Hi,
Here is the answer,ADS_TO_REPLACE_1
Delete statement in SQL is used to
delete partial/all data.
Especially
delete statement is useful
adding groups in contactsadding groups in contacts how to add groups in contacts using servlet and jsp????pls help.thanku in advance
adding buttons - Swing AWTadding buttons can u plzz explain how to add button to a dialog box and make them perform some event on the image loaded on the panel
adding buttons - Swing AWTadding buttons can u plzz explain how to add button to a dialog box and make them perform some event on the image loaded on the panel
Adding checkbox to List as item Adding checkbox to List as item can we add checkox to List
Hi Friend,
Try the following
code:ADS_TO_REPLACE_1
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class CheckBoxInList
Dyanmically Adding RowsDyanmically
Adding Rows Hi sir Am doing project in that i need to add date picker in dynamically
adding rows but the dates are storing in first test box only ill paste my
code debug that
code as soon as possible.
Regards
testcase for adding - JUNITtestcase for adding hi deepak...I am new to junit.can u send me a JUnit test case for
adding or multiplying of two numbers.please i need it urgently
Adding Jar into EclipseAdding Jar into Eclipse Hi,
Please provide Step by step procedure to add jar, tld files and configurations in Eclipse Helios version and i am using Jboss5.
Thanks&Regards,
Shiva sADS_TO_REPLACE_1
Dynamically adding textbox and labelsDynamically
adding textbox and labels Sir,
In my application I want to insert texbox and labels dynamically and want to insert database field value in that generated label.
Plz help me,
Thanks in advance
Adding customitem in canvas in J2ME?Adding customitem in canvas in J2ME? In J2ME how should we add a customitem inside the canvas.Because i need to perform key event handling for customitem.The key event handling is allowed in canvas not in form.So i try to use
webservices adding in eclipsewebservices
adding in eclipse hi team,
i am working on webservices,
please guide me how to add webservices in eclispe with step by step and give some examples also.
Please visit the following link:
http
Java: Adding Row in JTable Java:
Adding Row in JTable how about if we already have the JTAble created earlier.
And i just found nothing to get its DefaultTableModel, thus, I can't call insertRow() method.
Is there any work around for this?
I found
jtable-adding a row dynamicallyjtable-
adding a row dynamically hi..i am doing a project for pharmacy ..
*pblm:*
when i want to enter the details in jtable while running the application there are 3 rows and 4 columns which is default bt when we we have