oghenekaro EFEKODO

Ranch Hand
+ Follow
since Oct 10, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by oghenekaro EFEKODO

need help in making my application dispaly with the dialog box appearing at the center.The "InputDialog.java" contains the dialog i want to appear at the center of th "FoodFrame.java" class.pls somebody help me out.

codes:
//InputDialog.java


code 2:
//FoodFrame.java
17 years ago
need help in solving the following problems
1. i have a JTable that i want to display information in the table header from a JTextField am using to input data.please how do i handle it.

inputfield = new JTextField(20);

tablemodel = new DefaultTable();
tablemodel.addColumn("Number");
tablemodel.addColumn("Food Item");
tablemodel.addColumn("Quantity");
tablemodel.addColumn("Price");
tablemodel.addColumn("Description");

table = new JTable(tablemodel);

TableColumn column = null;
for (int i = 0; i < 5; i++) {
column = table.getColumnModel().getColumn(i);

if(i==0){
column.setPreferredWidth(65);
} else if(i==1){
column.setPreferredWidth(100);
} else if(i==2){
column.setPreferredWidth(65);
} else if(i==3){
column.setPreferredWidth(65);
} else{
column.setPreferredWidth(100);
}
}

2.need help in the Look and Feel of my JFrame have the look of a glass.please somebody tell to do this.

thanks in advance.
17 years ago
yes,my database is access
sorry i forgot.thanks for telling to include the kind of exception.
exception for
1. syntax error in INSERT INTO statement.
2.compile with -Xlint:deprecation
when i did,it tells me that java.util.Date(String s) is deprecated.so what i used to replace it.
need help urgently,i have been trying to input a date value via JTextField which is the date of transaction and i have been experiencing alot of problem.please somebody show how to insert date into my database from a text field.below are the methods i have tried and didn't work.thanks in advance.

1. i used this and recieve exception message
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:sparkletransaction","","");


java.sql.Date date =java.sql.Date.valueOf(dateF.getText());

String insert="INSERT INTO personaltransaction(date,name,phone,addres,deposit,balance) VALUES(?,?,?,?,?,?)";
//insert=insert+;
stat=con.prepareStatement(insert);

stat.setDate(1,date);
stat.setString(2,fullName);
stat.setString(3,phoneF.getText());
stat.setString(4,addressF.getText());
stat.setString(5,ss);
stat.setString(6,bb);

stat.executeUpdate();
stat.close();
}
catch(Exception e){
System.out.println(e);
}
}
2.also tried this in my code and recieve an exception.
Date date= new Date();
SimpleDateFormat template = new SimpleDateFormat("dd-mm-yyyy");
Date enddate = new Date(datefield.getText());
java.sql.Date date = java.sql.Date.valueOf(template.format(enddate));
need help urgently,i have been trying to input a date value via JTextField which is the date of transaction and i have been experiencing alot of problem.please somebody show how to insert date into my database from a text field.below are the methods i have tried and didn't work.thanks in advance.

1. i used this and recieve exception message
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:sparkletransaction","","");


java.sql.Date date =java.sql.Date.valueOf(dateF.getText());

String insert="INSERT INTO personaltransaction(date,name,phone,addres,deposit,balance) VALUES(?,?,?,?,?,?)";
//insert=insert+;
stat=con.prepareStatement(insert);

stat.setDate(1,date);
stat.setString(2,fullName);
stat.setString(3,phoneF.getText());
stat.setString(4,addressF.getText());
stat.setString(5,ss);
stat.setString(6,bb);

stat.executeUpdate();
stat.close();
}
catch(Exception e){
System.out.println(e);
}
}
2.also tried this in my code and recieve an exception.
Date date= new Date();
SimpleDateFormat template = new SimpleDateFormat("dd-mm-yyyy");
Date enddate = new Date(datefield.getText());
java.sql.Date date = java.sql.Date.valueOf(template.format(enddate));
all i really need is, when my application comes up,the food items display in the JList i used in my application.thanks in advance.
all i really need is, when my application comes up,the food items display in the JList i used in my application.thanks in advance.
Number FoodItem Quantity Price Description
**************************************************
1Rice 1 bag 5000 Carbohydrate
2Beans 1 bag 4000 Protein
3Palm Oil 1 bottle 500 Fats & Oil

i have a table like this in my database,need help in populating my list
with "FoodItem" from the database when my GUI comes up.

I want programmers to help me out. i want the code to print from a JTextArea.
17 years ago
need help making the following in my code work:
1.how do i display the whole table in my code using a dialog box or JOptionPane.
2. i want to display a message beneath the table show the total price of items selected from the JComboBox .
3.is there any way i could add a method or sommething that display detail of each item seleted from the list in a seperate column of the JTable in my code.say for instance,if i selects beans,1 cup, 100 and it display protein in a seperate column in the JTable.

Thanks in advance.

my code:

'\n'
import java.awt.*;
import java.awt.event.*;

import javax.swing.*;
import javax.swing.border.*;
import javax.swing.table.*;

import java.util.*;

public class BreakFast extends JFrame implements ActionListener{

private JList ingredient;
private JTable table;
private DefaultTableModel model;
private JButton move;
private String[] food;
private JComboBox box,box1;
private String[] units;
private double[] price={100,150,200,250,300,350,400};
private JButton finish;


public BreakFast(){
Container c=getContentPane();
c.setLayout(new FlowLayout());

food = new String[] {"Corn Flakes","Beans","Shredded Bread","Mushroom",
"eggs","Milks","Butter","Sugar","water","Oil"};

ingredient = new JList(food);
ingredient.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
ingredient.setVisibleRowCount(4);

JPanel p = new JPanel();
p.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));

move = new JButton(">>>");
move.addActionListener(this);

//meal = new JTextArea(5,20);
//meal.setEditable(false);

p.add(new JScrollPane(ingredient),"Wast");

JPanel p2 = new JPanel();
p2.setBorder(new BevelBorder(BevelBorder.RAISED));

units = new String[]{"2 cups","3 cups","4 cups","5 cups",
"1 mudu","2 mudu","3 mudu","4 mudu","5 mudu","6 mudu",
"7 mudu","8 mudu","9 mudu","1 bag"};
box = new JComboBox(units);
box.addActionListener(this);

box1 = new JComboBox();
//box1.setEditable(true);
box1.addActionListener(this);
for(int i=0;i<price.length;i++){
box1.addItem(price[i]);
}



model = new DefaultTableModel();

//model.addColumn("No.");
model.addColumn("Food Items");
model.addColumn("Units");
model.addColumn("Price");



table = new JTable(model);

JScrollPane pane = new JScrollPane(table);
pane.setPreferredSize(new Dimension(350,100));

finish = new JButton("Finish");
finish.addActionListener(this);

p.add(box,"West");
p.add(box1,"Center");
p.add(move,"East");
p2.add(pane,"North");
p2.add(finish,"South");

c.add(p);
c.add(p2);

setSize(450,300);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

public void actionPerformed(ActionEvent e){
Object[] value = ingredient.getSelectedValues();
if(e.getSource() == move){
for(int i=0;i< value.length;i++){
String word = (String)value[i];
Vector<Object> data = new Vector<Object>();
data.addElement( word );
data.addElement( box.getSelectedItem() );
data.addElement( box1.getSelectedItem());

model.addRow( data );
}
}
if(e.getSource() == finish){
JOptionPane.showMessageDialog( BreakFast.this,table,"Selection Summary",JOptionPane.PLAIN_MESSAGE);
System.exit(0);
}
}

public static void main(String[] arg){
new BreakFast();
}
}
18 years ago
need help.i have items in a list and combo box in which i want it in such away that when item is selected from the list and combo box it goes to the table i have in a panel.i want to discard the text area i used.thanks in advance

my code:
18 years ago
need help in converting my jar file to executeable and also how to write an installation shied for my program.thanks in advance.
18 years ago
please,note am trying to connect to microsoft access.thanks in advance.
need help in identifying what's wrong with my code.whenever i click create database button and query button nothing happens.i used system dsn and my dsn name is kingsley.

my code is: