Help with JTextArea

Hi,
I am working on a GUI Application and need some hlep.
1] When I click on Next Item button, it should clear the previously entered values of TextFields. How do I do this?
2] How do I display text in a JTextArea which appears in a Pop-up window?
I will appreciate your help and time.
Here is what I have done so far:
// FILE Name: ProductOrder.java
// Purpose: This class contains the GUI part
import javax.swing.*;
import java.awt.*; //FlowLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class ProductOrder extends JFrame //implements ActionListener
   private Product productArray[];  //array of Product objects
   private final int NUM_OF_PROD_ELEMENTS = 6;
   private JLabel label1;
   private JLabel label2;
   private JLabel label3;
   private JTextField textField1;
   private JTextField textField2;
   private JButton button1; // Next Item button
   private JButton button2; // Receipt button
   private JButton button3; // Summary button
   // Class constructor
   public ProductOrder()
      super( "Welcome!!!" );
      productArray = new Product[NUM_OF_PROD_ELEMENTS];
      productArray[0] = new Product(100, "White Bandana", 4.98F, 0F);
      productArray[1] = new Product(200, "Green License Plate", 5.99F, 3.5F);
      productArray[2] = new Product(300, "Green Sweat Shirt", 24.99F, 7.2F);
      productArray[3] = new Product(400, "Low Profile hat", 17.98F, 4F);
      productArray[4] = new Product(500, "Gym Short", 16.98F, 4.2F);
      productArray[5] = new Product(600, "Printed Golf Balls", 8.99F, 0F);
      //float i = productArray[0].Calculate(5);
      setLayout( new FlowLayout() );
      label1 = new JLabel( "USF Campus Store" );
      add(label1);
      label2 = new JLabel( "Product Code:                                " );
      label2.setToolTipText( "Enter Product Code");
      add(label2);
      textField1 = new JTextField(2);
      add( textField1 );
      label3 = new JLabel( "Quantity:                                          " );
      label3.setToolTipText( "Enter Quantity Number");
      add(label3);
      textField2 = new JTextField(2);
      add( textField2 );
      button1 = new JButton( "Next Item");
      add( button1 );  //add button1 to JFrame
      button2 = new JButton( "Receipt");
      add( button2 );  //add button1 to JFrame
      button3 = new JButton( "Summary");
      add( button3 );  //add button1 to JFrame
      // Register event handlers
      ProductHandler handler = new ProductHandler();
      textField1.addActionListener( handler ); // Product Code
      textField2.addActionListener( handler ); // Quantity
      button1.addActionListener( handler );    // Next Item
      button2.addActionListener( handler );    // Receipt
      button3.addActionListener( handler );    // Summary
   }//end of constrct
   // Private inner class for event handling
   private class ProductHandler implements ActionListener
      public void actionPerformed( ActionEvent event )
         String string , string1;
      int pCode = 000, quant = 000;
      if (event.getSource() == textField1 )
         string = event.getActionCommand();
         //pCode = Integer.parseInt( string );
         }//end of if1
         else if (event.getSource() == textField2 )
         string1 = event.getActionCommand();
         //quant = Integer.parseInt( string1 );
         else if ( event.getSource() == button1 )  // Next Item button
            JOptionPane.showMessageDialog(null, "product code: " + textField1.getText() + " " + "Quantity: " + textField2.getText() );
         else if ( event.getSource() == button2 )  // Receipt button
      //JOptionPane.showMessageDialog(null, "product code: " + pCode );
         //JOptionPane.showMessageDialog(null, "Quantity: " + quant );
      }//end of actionPerformed( ) method
   }//end of class ProductHandler
   /*public void showOrder()
     System.out.println("\nSuccess: this is ProductOrder class. ");
} //end ProductOrder

import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.text.NumberFormat;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.DefaultTableCellRenderer;
import java.lang.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.awt.FileDialog;
import java.io.*;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import javax.swing.JFrame;
public class Geometry {
CardLayout cards;
JPanel panel;
public Geometry() {
cards = new CardLayout();
panel = new JPanel(cards);
addCards();
JFrame f = new JFrame("Geometry");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setJMenuBar(getMenuBar());
f.getContentPane().add(panel);
f.setSize(500,500);
f.setLocation(0,0);
f.setVisible(true);
f.addMouseMotionListener(
new MouseMotionListener() { //anonymous inner class
//handle mouse drag event
public void mouseMoved(MouseEvent e) {
System.out.println("Mouse " + e.getX() +"," + e.getY());
public void mouseDragged(MouseEvent e) {
System.out.println("Draggg: x=" + e.getX() + "; y=" + e.getY());
// public void mouseMoved(MouseEvent me) {
// System.out.println("Moving: x=" + me.getX() + "; y=" + me.getY());
// panel.addMouseMotionListener(
// new MouseMotionListener() { //anonymous inner class
// //handle mouse drag event
// public void mouseDragged(MouseEvent me) {
// setTitle("Dragging: x=" + me.getX() + "; y=" + me.getY());
// public void mouseMoved(MouseEvent me) {
// setTitle("Moving: x=" + me.getX() + "; y=" + me.getY());
private void addCards() {
// card one
TriangleModel tri = new TriangleModel(175,100,175,250,325,250);
TriangleView view = new TriangleView(tri);
JPanel panelOne = new JPanel(new BorderLayout());
panelOne.add(view.getUIPanel(), "North");
panelOne.add(view);
panelOne.add(view.getTablePanel(), "South");
panelOne.setName("Pythagoras's Theorem");
panel.add("Pythagoras's Theorem", panelOne);
view.addMouseMotionListener(
new MouseMotionListener() { //anonymous inner class
//handle mouse drag event
public void mouseMoved(MouseEvent e) {
System.out.println("Mouse at " + e.getX() +"," + e.getY());
public void mouseDragged(MouseEvent e) {
System.out.println("Dragging: x=" + e.getX() + "; y=" + e.getY());
// card two
TestModel trin = new TestModel(175,100,175,250,325,250);
TestView viewn = new TestView(trin);
JPanel panelTwo = new JPanel(new BorderLayout());
panelTwo.add(viewn.getUIPanel(), "North");
// panelTwo.setBackground(Color.blue);
panelTwo.setName("Similar Triangles");
panelTwo.add(viewn);
panelTwo.add(viewn.getTablePanel(), "South");
viewn.addMouseMotionListener(
new MouseMotionListener() { //anonymous inner class
//handle mouse drag event
public void mouseMoved(MouseEvent e) {
System.out.println("Mouse at " + e.getX() +"," + e.getY());
public void mouseDragged(MouseEvent e) {
System.out.println("Dragging: x=" + e.getX() + "; y=" + e.getY());
panel.add("Similar Triangles", panelTwo);
JPanel panelThree = new JPanel();
panelThree.setBackground(Color.white);
panelThree.setName("Circle Theorem1");
panel.add("Circle Theorem1", panelThree);
private JMenuBar getMenuBar() {
JMenu File = new JMenu("File");
JSeparator separator1 = new JSeparator();
JMenuItem Open = new JMenuItem("Open");
// Open.addActionListener(new java.awt.event.ActionListener() {
// public void actionPerformed(java.awt.event.ActionEvent evt) {
// openActionPerformed(evt);
JMenuItem Save = new JMenuItem("Save");
JMenuItem Print = new JMenuItem("Print");
JMenuItem Exit = new JMenuItem("Exit");
Exit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
ExitActionPerformed(evt);
JMenu theorem = new JMenu("Theorem");
ActionListener l = new ActionListener() {
public void actionPerformed(ActionEvent e) {
JMenuItem item = (JMenuItem)e.getSource();
String name = item.getActionCommand();
cards.show(panel, name);
Component[] c = panel.getComponents();
for(int j = 0; j < panel.getComponentCount(); j++) {
String name = c[j].getName();
JMenuItem item = new JMenuItem(name);
item.setActionCommand(name);
item.addActionListener(l);
theorem.add(item);
JMenuBar menuBar = new JMenuBar();
JMenuBar menuBar1 = new JMenuBar();
menuBar.add(File);
File.add(Open);
File.add(separator1);
File.add(Save);
File.add(Print);
File.add(Exit);
menuBar.add(theorem);
return menuBar;
// private void openActionPerformed(java.awt.event.ActionEvent evt) {
// FileDialog fileDialog = new FileDialog(this, "Open...", FileDialog.LOAD);
// fileDialog.show();
// if (fileDialog.getFile() == null)
// return;
// fileName = fileDialog.getDirectory() + File.separator + fileDialog.getFile();
// FileInputStream fis = null;
// String str = null;
// try {
// fis = new FileInputStream(fileName);
// int size = fis.available();
// byte[] bytes = new byte [size];
// fis.read(bytes);
// str = new String(bytes);
// } catch (IOException e) {
// } finally {
// try {
// fis.close();
// } catch (IOException e2) {
// if (str != null)
// textBox.setText(str);
private void ExitActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
System.exit(0);
public static void main(String[] args) {
new Geometry();
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.text.NumberFormat;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.DefaultTableCellRenderer;
public class Triangle
public Triangle()
TriangleModel tri = new TriangleModel(175,100,175,250,325,250);
TriangleView view = new TriangleView(tri);
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(view.getUIPanel(), "North");
f.getContentPane().add(view);
f.getContentPane().add(view.getTablePanel(), "South");
f.setSize(500,500);
f.setLocation(200,200);
f.setVisible(true);
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import javax.swing.JTable;
import javax.swing.event.MouseInputAdapter;
* TriangleControl.java
* Created on 06 February 2005, 01:19
* @author Rahindra Naidoo
public class TriangleControl extends MouseInputAdapter
TriangleView view;
TriangleModel model;
Point start;
boolean dragging, altering;
Rectangle lineLens; // used for line selection
public TriangleControl(TriangleView tv)
view = tv;
model = view.getModel();
dragging = altering = false;
lineLens = new Rectangle(0, 0, 6, 6);
public void mousePressed(MouseEvent e)
Point p = e.getPoint();
lineLens.setLocation(p.x - 3, p.y - 3);
// are we over a line
if(model.isLineSelected(lineLens))
start = p;
altering = true;
// or are we within the triangle
else if(model.contains(p))
start = p;
dragging = true;
public void mouseReleased(MouseEvent e)
altering = false;
dragging = false;
view.getCentroidLabel().setText("centroid location: " +
model.findCentroid());
view.repaint(); // for the construction lines
public void mouseDragged(MouseEvent e)
Point p = e.getPoint();
if(altering)
int x = p.x - start.x;
int y = p.y - start.y;
model.moveSide(x, y, p);
updateTable();
view.repaint();
start = p;
else if(dragging)
int x = p.x - start.x;
int y = p.y - start.y;
model.translate(x, y);
view.repaint();
start = p;
private void updateTable()
String[] lengths = model.getLengths();
String[] squares = model.getSquares();
String[] angles = model.getAngles();
JTable table = view.getTable();
for(int j = 0; j < angles.length; j++)
table.setValueAt(lengths[j], 1, j + 1);
table.setValueAt(squares[j], 2, j + 1);
table.setValueAt(angles[j], 3, j + 1);
view.getCentroidLabel().setText("centroid location: " +
model.findCentroid());
* TriangleModel.java
* Created on 06 February 2005, 01:18
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.text.NumberFormat;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.DefaultTableCellRenderer;
* @author Rahindra Naidoo
public class TriangleModel // (x1, y1)
{                                         //      |\
static final int SIDES = 3; // | \
private int cx, cy; // | \
Polygon triangle; // |_ _\ (x3, y3)
int selectedIndex; // (x2, y2)
NumberFormat nf;
Line2D[] medians;
Point2D centroid;
public TriangleModel(int x1, int y1, int x2, int y2, int x3, int y3)
int[] x = new int[] { x1, x2, x3 };
int[] y = new int[] { y1, y2, y3 };
triangle = new Polygon(x, y, SIDES);
nf = NumberFormat.getNumberInstance();
nf.setMaximumFractionDigits(1);
public boolean contains(Point p)
// Polygon.contains doesn't work well enough
return (new Area(triangle)).contains(p);
public boolean isLineSelected(Rectangle r)
Line2D line = new Line2D.Double();
for(int j = 0; j < SIDES; j++)
int[] x = triangle.xpoints;
int[] y = triangle.ypoints;
int x1 = x[j];
int y1 = y[j];
int x2 = x[(j + 1) % SIDES];
int y2 = y[(j + 1) % SIDES];
line.setLine(x1, y1, x2, y2);
if(line.intersects(r))
selectedIndex = j;
return true;
selectedIndex = -1;
return false;
* Only works for right triangle with right angle at (x2, y2)
public void moveSide(int dx, int dy, Point p)
int[] x = triangle.xpoints;
int[] y = triangle.ypoints;
switch(selectedIndex)
case 0:
x[0] += dx;
x[1] += dx;
break;
case 1:
y[1] += dy;
y[2] += dy;
break;
case 2:
double rise = y[2] - y[0];
double run = x[2] - x[0];
double slope = rise/run;
// rise / run == (y[2] - p.y) / (x[2] - p.x)
x[2] = p.x + (int)((y[2] - p.y) / slope);
// rise / run == (p.y - y[0]) / (p.x - x[0])
y[0] = p.y - (int)((p.x - x[0]) * slope);
public void translate(int dx, int dy)
triangle.translate(dx, dy);
public Polygon getTriangle()
return triangle;
public String findCentroid()
int[] x = triangle.xpoints;
int[] y = triangle.ypoints;
// construct the medians defined as the line from
// any vertex to the midpoint of the opposite line
medians = new Line2D[x.length];
for(int j = 0; j < x.length; j++)
int next = (j + 1) % x.length;
int last = (j + 2) % x.length;
Point2D vertex = new Point2D.Double(x[j], y[j]);
// get midpoint of line opposite vertex
double dx = ((double)x[last] - x[next])/2;
double dy = ((double)y[last] - y[next])/2;
Point2D oppLineCenter = new Point2D.Double(x[next] + dx,
y[next] + dy);
medians[j] = new Line2D.Double(vertex, oppLineCenter);
// centroid is located on any median 2/3 the way from the
// vertex (P1) to the midpoint (P2) on the opposite side
double[] lengths = getSideLengths();
double dx = (medians[0].getX2() - medians[0].getX1())*2/3;
double dy = (medians[0].getY2() - medians[0].getY1())*2/3;
double px = medians[0].getX1() + dx;
double py = medians[0].getY1() + dy;
//System.out.println("px = " + nf.format(px) +
// "\tpy = " + nf.format(py));
centroid = new Point2D.Double(px, py);
return "(" + nf.format(px) + ", " + nf.format(py) + ")";
public String[] getAngles()
double[] lengths = getSideLengths();
String[] vertices = new String[lengths.length];
for(int j = 0; j < lengths.length; j++)
int opp = (j + 1) % lengths.length;
int last = (j + 2) % lengths.length;
double top = lengths[j] * lengths[j] +
lengths[last] * lengths[last] -
lengths[opp] * lengths[opp];
double divisor = 2 * lengths[j] * lengths[last];
double vertex = Math.acos(top / divisor);
vertices[j] = nf.format(Math.toDegrees(vertex));
return vertices;
public String[] getLengths()
double[] lengths = getSideLengths();
String[] lengthStrs = new String[lengths.length];
for(int j = 0; j < lengthStrs.length; j++)
lengthStrs[j] = nf.format(lengths[j]);
return lengthStrs;
public String[] getSquares()
double[] lengths = getSideLengths();
String[] squareStrs = new String[lengths.length];
for(int j = 0; j < squareStrs.length; j++)
squareStrs[j] = nf.format(lengths[j] * lengths[j]);
return squareStrs;
private double[] getSideLengths()
int[] x = triangle.xpoints;
int[] y = triangle.ypoints;
double[] lengths = new double[SIDES];
for(int j = 0; j < SIDES; j++)
int next = (j + 1) % SIDES;
lengths[j] = Point.distance(x[j], y[j], x[next], y[next]);
return lengths;
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.text.NumberFormat;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.DefaultTableCellRenderer;
* TriangleView.java
* Created on 06 February 2005, 01:21
public class TriangleView extends JPanel
private TriangleModel model;
private Polygon triangle;
private JTable table;
private JLabel centroidLabel;
private boolean showConstruction;
TriangleControl control;
public TriangleView(TriangleModel model)
this.model = model;
triangle = model.getTriangle();
showConstruction = false;
control = new TriangleControl(this);
addMouseListener(control);
addMouseMotionListener(control);
public void paintComponent(Graphics g)
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2.draw(triangle);
if(model.medians == null)
centroidLabel.setText("centroid location: " + model.findCentroid());
// draw medians and centroid point
if(showConstruction && !control.dragging)
g2.setPaint(Color.red);
for(int j = 0; j < 3; j++)
g2.draw(model.medians[j]);
g2.setPaint(Color.blue);
g2.fill(new Ellipse2D.Double(model.centroid.getX() - 2,
model.centroid.getY() - 2, 4, 4));
public TriangleModel getModel()
return model;
public JTable getTable()
return table;
public JLabel getCentroidLabel()
return centroidLabel;
public JPanel getUIPanel()
JCheckBox showCon = new JCheckBox("show construction");
showCon.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
boolean state = ((JCheckBox)e.getSource()).isSelected();
showConstruction = state;
repaint();
JPanel panel = new JPanel();
panel.add(showCon);
return panel;
public JPanel getTablePanel()
String[] headers = new String[] { "", "", "", "" };
// row and column data labels
String[] rowHeaders = {
"sides", "lengths", "squares", "angles", "degrees"
String[] sidesRow = { "vertical", "horizontal", "hypotenuse" };
String[] anglesRow = { "hyp to ver", "ver to hor", "hor to hyp" };
// collect data from model
String[] angles = model.getAngles();
String[] lengths = model.getLengths();
String[] squares = model.getSquares();
String[][] allData = { sidesRow, lengths, squares, anglesRow, angles };
int rows = 5;
int cols = 4;
Object[][] data = new Object[rows][cols];
for(int row = 0; row < rows; row++)
data[row][0] = rowHeaders[row];
for(int col = 1; col < cols; col++)
data[row][col] = allData[row][col - 1];
table = new JTable(data, headers)
public boolean isCellEditable(int row, int col)
return false;
DefaultTableCellRenderer renderer =
(DefaultTableCellRenderer)table.getDefaultRenderer(String.class);
renderer.setHorizontalAlignment(JLabel.CENTER);
centroidLabel = new JLabel("centroid location: ", JLabel.CENTER);
Dimension d = centroidLabel.getPreferredSize();
d.height = table.getRowHeight();
centroidLabel.setPreferredSize(d);
JPanel panel = new JPanel(new BorderLayout());
panel.setBorder(BorderFactory.createTitledBorder("triangle data"));
panel.add(table);
panel.add(centroidLabel, "South");
return panel;
PLEASE HELP ME TO LABEL THE TRIANGLE AND CHANGE THE VALUES OF THE JTABLE - to SHOW ASquare b Square and C square as well as a label on the bottom of the screen to show A^2 + B^2 = C^2 ...
ThANKS

Similar Messages

  • Need help with JTextArea and Scrolling

    import java.awt.*;
    import java.awt.event.*;
    import java.text.DecimalFormat;
    import javax.swing.*;
    public class MORT_RETRY extends JFrame implements ActionListener
    private JPanel keypad;
    private JPanel buttons;
    private JTextField lcdLoanAmt;
    private JTextField lcdInterestRate;
    private JTextField lcdTerm;
    private JTextField lcdMonthlyPmt;
    private JTextArea displayArea;
    private JButton CalculateBtn;
    private JButton ClrBtn;
    private JButton CloseBtn;
    private JButton Amortize;
    private JScrollPane scroll;
    private DecimalFormat calcPattern = new DecimalFormat("$###,###.00");
    private String[] rateTerm = {"", "7years @ 5.35%", "15years @ 5.5%", "30years @ 5.75%"};
    private JComboBox rateTermList;
    double interest[] = {5.35, 5.5, 5.75};
    int term[] = {7, 15, 30};
    double balance, interestAmt, monthlyInterest, monthlyPayment, monPmtInt, monPmtPrin;
    int termInMonths, month, termLoop, monthLoop;
    public MORT_RETRY()
    Container pane = getContentPane();
    lcdLoanAmt = new JTextField();
    lcdMonthlyPmt = new JTextField();
    displayArea = new JTextArea();//DEFINE COMBOBOX AND SCROLL
    rateTermList = new JComboBox(rateTerm);
    scroll = new JScrollPane(displayArea);
    scroll.setSize(600,170);
    scroll.setLocation(150,270);//DEFINE BUTTONS
    CalculateBtn = new JButton("Calculate");
    ClrBtn = new JButton("Clear Fields");
    CloseBtn = new JButton("Close");
    Amortize = new JButton("Amortize");//DEFINE PANEL(S)
    keypad = new JPanel();
    buttons = new JPanel();//DEFINE KEYPAD PANEL LAYOUT
    keypad.setLayout(new GridLayout( 4, 2, 5, 5));//SET CONTROLS ON KEYPAD PANEL
    keypad.add(new JLabel("Loan Amount$ : "));
    keypad.add(lcdLoanAmt);
    keypad.add(new JLabel("Term of loan and Interest Rate: "));
    keypad.add(rateTermList);
    keypad.add(new JLabel("Monthly Payment : "));
    keypad.add(lcdMonthlyPmt);
    lcdMonthlyPmt.setEditable(false);
    keypad.add(new JLabel("Amortize Table:"));
    keypad.add(displayArea);
    displayArea.setEditable(false);//DEFINE BUTTONS PANEL LAYOUT
    buttons.setLayout(new GridLayout( 1, 3, 5, 5));//SET CONTROLS ON BUTTONS PANEL
    buttons.add(CalculateBtn);
    buttons.add(Amortize);
    buttons.add(ClrBtn);
    buttons.add(CloseBtn);//ADD ACTION LISTENER
    CalculateBtn.addActionListener(this);
    ClrBtn.addActionListener(this);
    CloseBtn.addActionListener(this);
    Amortize.addActionListener(this);
    rateTermList.addActionListener(this);//ADD PANELS
    pane.add(keypad, BorderLayout.NORTH);
    pane.add(buttons, BorderLayout.SOUTH);
    pane.add(scroll, BorderLayout.CENTER);
    addWindowListener( new WindowAdapter()
    public void windowClosing(WindowEvent e)
    System.exit(0);
    public void actionPerformed(ActionEvent e)
    String arg = lcdLoanAmt.getText();
    int combined = Integer.parseInt(arg);
    if (e.getSource() == CalculateBtn)
    try
    JOptionPane.showMessageDialog(null, "Got try here", "Error", JOptionPane.ERROR_MESSAGE);
    catch(NumberFormatException ev)
    JOptionPane.showMessageDialog(null, "Got here", "Error", JOptionPane.ERROR_MESSAGE);
    if ((e.getSource() == CalculateBtn) && (arg != null))
    try{
    if ((e.getSource() == CalculateBtn) && (rateTermList.getSelectedIndex() == 1))
    monthlyInterest = interest[0] / (12 * 100);
    termInMonths = term[0] * 12;
    monthlyPayment = combined * (monthlyInterest / (1 - (Math.pow (1 + monthlyInterest,  -termInMonths))));
    lcdMonthlyPmt.setText(calcPattern.format(monthlyPayment));
    if ((e.getSource() == CalculateBtn) && (rateTermList.getSelectedIndex() == 2))
    monthlyInterest = interest[1] / (12 * 100);
    termInMonths = term[1] * 12;
    monthlyPayment = combined * (monthlyInterest / (1 - (Math.pow (1 + monthlyInterest,  -termInMonths))));
    lcdMonthlyPmt.setText(calcPattern.format(monthlyPayment));
    if ((e.getSource() == CalculateBtn) && (rateTermList.getSelectedIndex() == 3))
    monthlyInterest = interest[2] / (12 * 100);
    termInMonths = term[2] * 12;
    monthlyPayment = combined * (monthlyInterest / (1 - (Math.pow (1 + monthlyInterest,  -termInMonths))));
    lcdMonthlyPmt.setText(calcPattern.format(monthlyPayment));
    catch(NumberFormatException ev)
    JOptionPane.showMessageDialog(null, "Invalid Entry!\nPlease Try Again", "Error", JOptionPane.ERROR_MESSAGE);
    }                    //IF STATEMENTS FOR AMORTIZATION
    if ((e.getSource() == Amortize) && (rateTermList.getSelectedIndex() == 1))
    loopy(7, 5.35);
    if ((e.getSource() == Amortize) && (rateTermList.getSelectedIndex() == 2))
    loopy(15, 5.5);
    if ((e.getSource() == Amortize) && (rateTermList.getSelectedIndex() == 3))
    loopy(30, 5.75);
    if (e.getSource() == ClrBtn)
    rateTermList.setSelectedIndex(0);
    lcdLoanAmt.setText(null);
    lcdMonthlyPmt.setText(null);
    displayArea.setText(null);
    if (e.getSource() == CloseBtn)
    System.exit(0);
    private void loopy(int lTerm,double lInterest)
    double total, monthly, monthlyrate, monthint, monthprin, balance, lastint, paid;
    int amount, months, termloop, monthloop;
    String lcd2 = lcdLoanAmt.getText();
    amount = Integer.parseInt(lcd2);
    termloop = 1;
    paid = 0.00;
    monthlyrate = lInterest / (12 * 100);
    months = lTerm * 12;
    monthly = amount *(monthlyrate/(1-Math.pow(1+monthlyrate,-months)));
    total = months * monthly;
    balance = amount;
    while (termloop <= lTerm)
    displayArea.setCaretPosition(0);
    displayArea.append("\n");
    displayArea.append("Year " + termloop + " of " + lTerm + ": payments\n");
    displayArea.append("\n");
    displayArea.append("Month\tMonthly\tPrinciple\tInterest\tBalance\n");
    monthloop = 1;
    while (monthloop <= 12)
    monthint = balance * monthlyrate;
    monthprin = monthly - monthint;
    balance -= monthprin;
    paid += monthly;
    displayArea.setCaretPosition(0);
    displayArea.append(monthloop + "\t" + calcPattern.format(monthly) + "\t" + calcPattern.format(monthprin) + "\t");
    displayArea.append(calcPattern.format(monthint) + "\t" + calcPattern.format(balance) + "\n");
    monthloop ++;
    termloop ++;
    public static void main(String args[])
    MORT_RETRY f = new MORT_RETRY();
    f.setTitle("MORTGAGE PAYMENT CALCULATOR");
    f.setBounds(600, 600, 500, 500);
    f.setLocationRelativeTo(null);
    f.setVisible(true);
    }need help with displaying the textarea correctly and the scroll bar please.
    Message was edited by:
    new2this2020

    What's the problem you're having ???
    PS.

  • Hi , please help with JTextArea.

    Hi, I have got to write an application that evaluates the factorials of the integers 1 to 5. Display the results in tabular format in a JTextArea that is displayed in a messa dialog.
    I have those codes:
    int n1 = 1, n2 = 2, n3 = 3, n4 = 4, n5 = 5, sum;
    JTextArea outputTextArea = new JTextArea();
    outputTextArea.setText( "The Factorials" );
    sum = n1 * n2 * n3 * n4 * n5;
    outputTextArea.append( sum );
    JOptionPane.showMessageDialog(null, outputTextArea,
    " The results are " );
    Now the compiler tells me that append doesn't take int type. Also if I cancel the append statement it works but it will not show me the numbers.
    Please any kind of help will be appriciated

    Thanks very much it worked.
    I realy appriciate the help you give me all the time.
    By Giuseppe, Italy, Tanks.anytime :),...BTW..one tip i would like to give is whenever u get a compile error saying that the method is not found,check with the java api ..

  • Please Help with JtextArea!! Need advice from Java expert!

    Hi, I need something VERY simple, and it is unbelievable I'm looking for a solution for so long! I really hope some of you java-gurus can help me out. Here's the thing:
    1. Make a Jframe
    2. Add a JTextArea and use a transparent color (e.g. 0.1f,0.1f,0.1f,0.1f)
    3. loop a setText method to display a constantly varying text, e.g. the time in milliseconds
    I simply can't do it in any way if I use transparency. Without transparency it works with no problems.
    I am on Mac, and I have checked out this site:
    http://www.curious-creature.org/2007/04/10/translucent-swing-windows-on-mac-os-x/
    but I can't figure out how the guy who wrote the code made it work on mac (he didn't add the full code and the imports). I already tried to contact him, but no answer...
    so PLEEEEASE take 5 minutes to write a very small example of how to manage a varying text on a transparent window.
    Thanks a lot in advance
    Lele

    -> did you maybe check out the link I posted?
    Yes, I did which is why I asked the question are you trying to create a transparent JFrame so that the desktop image is displayed in the frame? To my knowledge this feature (if it works) is a Mac only feature and does not work on windows. If this is what you are trying to do then I have no idea how to do it and will not respond any more.
    -> the GPS coordinates are displayed on top of the moving map, with no visible background
    I guess I have trouble understanding what this is - "a map with no background"?
    Is the map just not an image (ie. a JLabel with an ImageIcon) placed in a scrollpane? Then as the map moves you change the viewport position so it looks like the map is moving? Then you can simply add a label containing the GPS coordinates on top of the label representing the map.
    -> have you considered using a JLabel in an OverlayLayout?
    Right which is what I was thinking. Something simple like:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class LabelMap extends JFrame
         public LabelMap()
              JLabel map = new JLabel(new ImageIcon("yourMap.jpg"));
              getContentPane().add(new JScrollPane(map));
              JLabel point = new JLabel();
              point.setLocation(50, 50);
              point.setText(point.getLocation().toString());
              Dimension d = point.getPreferredSize();
              point.setSize(d.width, d.height);
              point.setFocusable(true);
              map.add(point);
              KeyListener kl = new KeyAdapter()
                   public void keyPressed(KeyEvent e)
                        JLabel point = (JLabel)e.getSource();
                        Point p = point.getLocation();
                        if (e.getKeyCode() == KeyEvent.VK_UP)
                             p.y -= 5;
                        else if (e.getKeyCode() == KeyEvent.VK_DOWN)
                             p.y += 5;
                        else if (e.getKeyCode() == KeyEvent.VK_LEFT)
                             p.x -= 5;
                        else if (e.getKeyCode() == KeyEvent.VK_RIGHT)
                             p.x += 5;
                        point.setLocation(p);
                        point.setText(p.getLocation().toString());
                        Dimension d = point.getPreferredSize();
                        point.setSize(d.width, d.height);
              point.addKeyListener(kl);
         public static void main(String[] args)
              LabelMap frame = new LabelMap();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.setSize(300, 300);
              frame.setLocationRelativeTo( null );
              frame.setVisible(true);
    }In the above example you can scroll the image and dynamically move the text using the arrow keys.

  • Help with JTextAreas

    I am having two problems:
    1) I need to know how to create a JTextArea that holds a finite amount of information, like 8 lines... is this possible without Listeners? Perhaps using setColumns or setWidths? I wasn't actually sure what those methods did because they didn't work for me.
    2) I need to create the Text area without Horizontal scrollbars... I can't do regular implementation as I have seen in previous postings because I am using BreezySwing where the constructor is:
         JTextArea field = addTextArea ("Type Text Here",1,1,2,1);
    with no space to add the scrollbar policy. I also tried to add a scroll pane
    JScrollPane pane = new JScrollPane(field, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    but it just greyed out my field so it wasn't editable.
    3) I want to read in all of the information that is in the text area into a string
    but I do not know how to tell when to end a loop that reads in all the informaiton. Is there a method that determines the last word in a text area?
    Is is possible to read in each row of text as a different string?
    --Thank you very much,
    Evan.
    Sorry if my questions are amatuer-- I'm a novice and my computer science class is geared towards AP knowledge-- which doesn't cover swing... I'm just interested.
    Message was edited by:
    EvanD

    Read the tutorial:
    http://java.sun.com/docs/books/tutorial/uiswing/components/textarea.html
    1. Use setRows(8).
    If you want to stop the user from entering more text after the 8 lines you will have to use a DocumentFilter for this.
    You can read here Implementing a Document Filter:
    http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html#filter
    2. You need to use setLineWrap(true) and maybe also setWrapStyleWord(true) depending on your needs.
    3. You can use getLineCount, getLineStartOffset, getLineEndOffset with getText(offset, length) to iterate over the text and read 1 line at a time.

  • Urgent help with JTextArea

    Hi! Im trying to clear a TextArea, and did that using setText(" ");
    However, when i try to call the class again (the one that creates the textarea), and try to append to it, it does not show. I think i am creating the textarea again because i called it again, so, im finding a way to delete the previously created textarea. is this possible? if so, please help me.. thanks!!!

    You need not use append.Only setText

  • Help with if statement for a beginner.

    Hello, I’m new to the dev lark and wondered if someone could point me in the right direction.
    I have the following (working!) app that lets users press a few buttons instead of typing console commands (please do not be too critical of it, it’s my first work prog).
    //DBS File send and Receive app 1.0
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import javax.swing.*;
    import java.awt.BorderLayout;
    import java.awt.FlowLayout;
    import java.awt.Font;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JCheckBox;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JTextArea;
    import java.applet.Applet;
    public class Buttons extends JFrame
         public Buttons()
              super("DBS 2");          
              JTextArea myText = new JTextArea   ("Welcome to the DBS application." +
                                                           "\n" +
                                                           "\n\n1. If you have received an email informing you that the DBS is ready to dowload please press the \"Receive DBS\" button." +
                                                           "\n" +
                                                           "\n1. Once this has been Received successfully please press the \"Prep File\" button." +
                                                           "\n\n2. Once the files have been moved to their appropriate locations, please do the \"Load\" into PAS." +
                                                           "\n\n3. Once the \"Load\" is complete, do the \"Extract\"." +
                                                           "\n\n4. When the \"Extract\" has taken place please press the \"File Shuffle\" button." +
                                                           "\n\n5. When the files have been shuffled, please press the \"Send DBS\" Button." +
                                                           "\n\nJob done." +
                                                           "\n", 20,50);
              JPanel holdAll = new JPanel();
              JPanel topPanel = new JPanel();
              JPanel bottomPanel = new JPanel();
              JPanel middle1 = new JPanel();
              JPanel middle2 = new JPanel();
              JPanel middle3 = new JPanel();
              topPanel.setLayout(new FlowLayout());
              middle1.setLayout(new FlowLayout());
              middle2.setLayout(new FlowLayout());
              middle3.setLayout(new FlowLayout());
              bottomPanel.setLayout(new FlowLayout());
              myText.setBackground(new java.awt.Color(0, 0, 0));     
              myText.setForeground(new java.awt.Color(255,255,255));
              myText.setFont(new java.awt.Font("Times",0, 16));
              myText.setLineWrap(true);
              myText.setWrapStyleWord(true);
              holdAll.setLayout(new BorderLayout());
              topPanel.setBackground(new java.awt.Color(153, 101, 52));
              bottomPanel.setForeground(new java.awt.Color(153, 0, 52));
              holdAll.add(topPanel, BorderLayout.CENTER);
              topPanel.add(myText, BorderLayout.NORTH);
              setSize(700, 600);
              setDefaultCloseOperation(EXIT_ON_CLOSE);
              getContentPane().add(holdAll, BorderLayout.CENTER);
              Container c = getContentPane();
              c.setLayout(new FlowLayout());
              final JButton receiveDBS = new JButton("Receive DBS"); //marked as final as it is called in an Inner Class later
              final JButton filePrep = new JButton("Prep File");
              final JButton fileShuffle = new JButton("File Shuffle");
              final JButton sendDBS = new JButton("Send DBS");
              JButton exitButton = new JButton("Exit");
    //          JLabel statusbar = new JLabel("Text here");
              receiveDBS.setFont(new java.awt.Font("Arial", 0, 25));
              filePrep.setFont(new java.awt.Font("Arial", 0, 25));
              fileShuffle.setFont(new java.awt.Font("Arial", 0, 25));
              sendDBS.setFont(new java.awt.Font("Arial", 0, 25));
              exitButton.setBorderPainted ( false );
              exitButton.setMargin( new Insets ( 10, 10, 10, 10 ));
              exitButton.setToolTipText( "EXIT Button" );
              exitButton.setFont(new java.awt.Font("Arial", 0, 20));
              exitButton.setEnabled(true);  //Set to (false) to disable
              exitButton.setForeground(new java.awt.Color(0, 0, 0));
              exitButton.setHorizontalTextPosition(SwingConstants.CENTER); //Don't know what this does
              exitButton.setBounds(10, 30, 90, 50); //Don't know what this does
              exitButton.setBackground(new java.awt.Color(153, 101, 52));     
              topPanel.add(receiveDBS);
              middle1.add(filePrep);
              middle2.add(exitButton);
              middle3.add(fileShuffle);
              bottomPanel.add(sendDBS);
              receiveDBS.addActionListener(new ActionListener()
                   public void actionPerformed(ActionEvent ae)
                        if (ae.getSource() == receiveDBS);
                        try
                             Runtime.getRuntime().exec("cmd.exe /c start c:\\DBS\\ReceiveDBSfile.bat");
                        catch(Exception e)
                             System.out.println(e.toString());
                             e.printStackTrace();
              filePrep.addActionListener(new ActionListener()
                   public void actionPerformed(ActionEvent ae)
                        if (ae.getSource() == filePrep);
                        try
                             Runtime.getRuntime().exec("cmd.exe /c start c:\\DBS\\filePrep.bat");
                        catch(Exception e)
                             System.out.println(e.toString());
                             e.printStackTrace();
              exitButton.addActionListener(new ActionListener()
                   public void actionPerformed(ActionEvent ae)
                        System.exit(0);
              fileShuffle.addActionListener(new ActionListener()
                   public void actionPerformed(ActionEvent ae)
                        if (ae.getSource() == fileShuffle);
                        try
                             Runtime.getRuntime().exec("cmd.exe /c start c:\\DBS\\fileShuffle.bat");
                        catch(Exception e)
                             System.out.println(e.toString());
                             e.printStackTrace();
              sendDBS.addActionListener(new ActionListener()
                   public void actionPerformed(ActionEvent ae)
                        if (ae.getSource() == sendDBS);
                        try
                             Runtime.getRuntime().exec("cmd.exe /c start c:\\DBS\\sendDBSFile.bat");
                        catch(Exception e)
                             System.out.println(e.toString());
                             e.printStackTrace();
              c.add(receiveDBS);
              c.add(filePrep);
              c.add(fileShuffle);
              c.add(sendDBS);
              c.add(exitButton);
    //          c.add(statusbar);
         public static void main(String args[])
              Buttons xyz = new Buttons();
              xyz.setVisible(true);
         }What I would like help with is the following…
    I would like output to either a JLabel or JTextArea to appear if a file appears on the network. Something along these lines…
    If file named nststrace*.* is in \\[network path] then output “Download successful, please proceed.”
    btw I have done my best to search this forum for something similar and had no luck, but I am looking forward to Encephalopathic’s answer as he/she has consistently made me laugh with posted responses (in a good way).
    Thanks in advance, Paul.

    Hospital_Apps_Monkey wrote:
    we're starting to get aquainted, but I think "best friend" could take a while as it is still as hard going as I recall, but I will persevere.Heh, it's not so bad! For example, if I had no idea how to test whether a file exists, I would just scan the big list of classes on the left for names that sound like they might include File operations. Hey look, File! Then I'd look at all of File's methods for something that tests whether it exists or not. Hey, exists! Then if I still couldn't figure out how to use it, I'd do a google search on that particular method.

  • Need Help With D&D Program

    Hi, I'm not sure if I'm allowed to post questions on this forum but I can't find anywhere to talk to helpful people about programming.
    I'm making a dnd interface for JComponents. So far I've made a simple program that has a Component that can be lifted from a container and braught to the glass pane then later moved to anywhere on the screen and dropped into the container below it. Here's where my problems come:
    1) Rite now my 'Movable Component' is a JPanel which is just colored in. I want to either take a Graphic2d from a JComponent/Component and draw it on the JPanel or change the JPanel to the component I want to paint and disable the component.
    The problem with getting the Graphics2d is that if the component isn't on the screen it doesn't make a graphic object. I tried messing with the ui delicate and overriding parental methods for paintComponent, repaint, and that repaintChildren(forget name) but I haven't had luck getting a good graphics object. I was thinking of, at the beginning of running the program, putting 1 of each component onto the screen for a second then removing it but I'd rather not. I'd also like to change the graphics dynamicly if someone stretches the component there dropping and what not.
    The problem with disabling is that it changes some of the visual features of Components. I want to be able to update the Component myself to change how it looks and I don't want disabling to gray out components.
    I mainly just dont want the components to do any of there normal fuctions. This is for a page builder, by the way.
    Another problem I'm having is that mouseMotionListener is allowing me to select 2 components that are on top of one another when there edges are near each other. I don't know if theres a fix to this other than changing the Java Class.
    My next problem is a drop layout manager, but I'm doing pretty good with that rite now. It'll problem just move components out of the way of the falling component.
    One last thing I need help with is that I don't want the object that's being carried to go across the menu bar and certain areas. When I'm having the object being carried I have it braught up to the glass pane which allows it to move anywhere. Does anyone have any idea how I could prevent the component from being over the menu bars and other objects? I might have to make 1 panel is the movable area that can then be broken down into the 'component bank', 'building page' and whatever else I'm gonna need.
    This is all just test code to get together for when I make the real program but I need to make sure it'll be possible without a lot of hacking of code.
    Sorry for the length. Thanks for any help you can give.

    The trick to making viewable components that have no behaviour, is to render them onto an image of some sort (eg a BufferedImage). You can then display the Image on a JLabel that can be dragged around the desktop.
    Here is a piece of code that does the component rendering for you. This particular example uses a fixed component size, but you can modify that as you choose of course...public class JComponentImage
         private static GraphicsConfiguration gConfig;
         private static Dimension compSize = new Dimension(80, 22);
         private static Image image = null;
         public static Image getImage(Class objectClass)
              if (gConfig == null)
                   GraphicsEnvironment gEnv = GraphicsEnvironment.getLocalGraphicsEnvironment();
                   GraphicsDevice gDevice = gEnv.getDefaultScreenDevice();
                   gConfig = gDevice.getDefaultConfiguration();
              image = gConfig.createCompatibleImage(compSize.width, compSize.height);
              JComponent jc = (JComponent) ObjectFactory.instantiate(objectClass);
              jc.setSize(compSize);
              Graphics g = image.getGraphics();
              g.setColor(Color.LIGHT_GRAY);
              g.fillRect(0, 0, compSize.width, compSize.height);
              g.setColor(Color.BLACK);
              jc.paint(g);
              return image;
    }And here is the class that makes the dragable JLabel using the class above...public class Dragable extends JLabel
         private static DragSource dragSource = DragSource.getDefaultDragSource();
         private static DragGestureListener dgl = new DragMoveGestureListener();
         private static TransferHandler th = new ObjectTransferHandler();
         private Class compClass;
         private Image image;
         Dragable(Class compClass)
              this.compClass = compClass;
              image = JComponentImage.getImage(compClass);
              setIcon(new ImageIcon(image));
              setTransferHandler(th);
              dragSource.createDefaultDragGestureRecognizer(this,
                                                          DnDConstants.ACTION_COPY,
                                                          dgl);
         public Class getCompClass()
              return compClass;
    }Oh and here is ObjectFactory which simply instantiates Objects of a given class and sets their text to their classname (very crudely)...public class ObjectFactory
         public static Object instantiate(Class objectClass)
              Object o = null;
              try
                   o = objectClass.newInstance();
              catch (Exception e)
                   System.out.println("ObjectFactory#instantiate: " + e);
              String name = objectClass.getName();
              int lastDot = name.lastIndexOf('.');
              name = name.substring(lastDot + 1);
              if (o instanceof JLabel)
                   ((JLabel)o).setText(name);
              if (o instanceof JButton)
                   ((JButton)o).setText(name);
              if (o instanceof JTextComponent)
                   ((JTextComponent)o).setText(name);
              return o;
    }Two more classes required by this codepublic class ObjectTransferHandler extends TransferHandler {
         private static DataFlavor df;
          * Constructor for ObjectTransferHandler.
         public ObjectTransferHandler() {
              super();
              try {
                   df = new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType);
              } catch (ClassNotFoundException e) {
                   Debug.trace(e.toString());
         public Transferable createTransferable(JComponent jC) {
              Transferable t = null;
              try {
                   t = new ObjectTransferable(((Dragable) jC).getCompClass());
              } catch (Exception e) {
                   Debug.trace(e.toString());
              return t;
         public int getSourceActions(JComponent c) {
              return DnDConstants.ACTION_MOVE;
         public boolean canImport(JComponent comp, DataFlavor[] flavors) {
              if (!(comp instanceof Dragable) && flavors[0].equals(df))
                   return true;
              return false;
         public boolean importData(JComponent comp, Transferable t) {
              JComponent c = null;
              try {
                   c = (JComponent) t.getTransferData(df);
              } catch (Exception e) {
                   Debug.trace(e.toString());
              comp.add(c);
              comp.validate();
              return true;
    public class ObjectTransferable implements Transferable {
         private static DataFlavor df = null;
         private Class objectClass;
         ObjectTransferable(Class objectClass) {
              try {
                   df = new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType);
              } catch (ClassNotFoundException e) {
                   System.out.println("ObjectTransferable: " + e);
              this.objectClass = objectClass;
          * @see java.awt.datatransfer.Transferable#getTransferDataFlavors()
         public DataFlavor[] getTransferDataFlavors() {
              return new DataFlavor[] { df };
          * @see java.awt.datatransfer.Transferable#isDataFlavorSupported(DataFlavor)
         public boolean isDataFlavorSupported(DataFlavor testDF) {
              return testDF.equals(df);
          * @see java.awt.datatransfer.Transferable#getTransferData(DataFlavor)
         public Object getTransferData(DataFlavor arg0)
              throws UnsupportedFlavorException, IOException {
              return ObjectFactory.instantiate(objectClass);
    }And of course the test class:public class DragAndDropTest extends JFrame
         JPanel leftPanel = new JPanel();
         JPanel rightPanel = new JPanel();
         Container contentPane = getContentPane();
         Dragable dragableJLabel;
         Dragable dragableJButton;
         Dragable dragableJTextField;
         Dragable dragableJTextArea;
          * Constructor DragAndDropTest.
          * @param title
         public DragAndDropTest(String title)
              super(title);
              dragableJLabel = new Dragable(JLabel.class);
              dragableJButton = new Dragable(JButton.class);
              dragableJTextField = new Dragable(JTextField.class);
              dragableJTextArea = new Dragable(JTextArea.class);
              leftPanel.setBorder(new EtchedBorder());
              BoxLayout boxLay = new BoxLayout(leftPanel, BoxLayout.Y_AXIS);
              leftPanel.setLayout(boxLay);
              leftPanel.add(dragableJLabel);
              leftPanel.add(dragableJButton);
              leftPanel.add(dragableJTextField);
              leftPanel.add(dragableJTextArea);
              rightPanel.setPreferredSize(new Dimension(500,500));
              rightPanel.setBorder(new EtchedBorder());
              rightPanel.setTransferHandler(new ObjectTransferHandler());
              contentPane.setLayout(new BorderLayout());
              contentPane.add(leftPanel, "West");
              contentPane.add(rightPanel, "Center");
         public static void main(String[] args)
              JFrame frame = new DragAndDropTest("Drag and Drop Test");
              frame.pack();
              frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
              frame.setVisible(true);
    }I wrote this code some time ago, so it won't be perfect but hopefully will give you some good ideas.
    Regards,
    Tim

  • Need help with a simple program (should be simple anyway)

    I'm (starting to begin) writing a nice simple program that should be easy however I'm stuck on how to make the "New" button in the file menu clear all the fields. Any help? I'll attach the code below.
    ====================================================
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Message extends JFrame implements ActionListener {
         public void actionPerformed(ActionEvent evt) {
         text1.setText(" ");
         text2.setText("RE: ");
         text3.setText(" ");
         public Message() {
         super("Write a Message - by Kieran Hannigan");
         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         setSize(370,270);
         FlowLayout flo = new FlowLayout(FlowLayout.RIGHT);
         setLayout(flo);
         //Make the bar
         JMenuBar bar = new JMenuBar();
         //Make "File" on Menu
         JMenu File = new JMenu("File");
         JMenuItem f1 = new JMenuItem("New");f1.addActionListener(this);
         JMenuItem f2 = new JMenuItem("Open");
         JMenuItem f3 = new JMenuItem("Save");
         JMenuItem f4 = new JMenuItem("Save As");
         JMenuItem f5 = new JMenuItem("Exit");
         File.add(f1);
         File.add(f2);
         File.add(f3);
         File.add(f4);
         File.add(f5);
         bar.add(File);
         //Make "Edit" on menu
         JMenu Edit = new JMenu("Edit");
         JMenuItem e1 = new JMenuItem("Cut");
         JMenuItem e2 = new JMenuItem("Paste");
         JMenuItem e3 = new JMenuItem("Copy");
         JMenuItem e4 = new JMenuItem("Repeat");
         JMenuItem e5 = new JMenuItem("Undo");
         Edit.add(e5);
         Edit.add(e4);
         Edit.add(e1);
         Edit.add(e3);
         Edit.add(e2);
         bar.add(Edit);
         //Make "View" on menu
         JMenu View = new JMenu("View");
         JMenuItem v1 = new JMenuItem("Bold");
         JMenuItem v2 = new JMenuItem("Italic");
         JMenuItem v3 = new JMenuItem("Normal");
         JMenuItem v4 = new JMenuItem("Bold-Italic");
         View.add(v1);
         View.add(v2);
         View.add(v3);
         View.addSeparator();
         View.add(v4);
         bar.add(View);
         //Make "Help" on menu
         JMenu Help = new JMenu("Help");
         JMenuItem h1 = new JMenuItem("Help Online");
         JMenuItem h2 = new JMenuItem("E-mail Programmer");
         Help.add(h1);
         Help.add(h2);
         bar.add(Help);
         setJMenuBar(bar);
         //Make Contents of window.
         //Make "Subject" text field
         JPanel row2 = new JPanel();
         JLabel sublabel = new JLabel("Subject:");
         row2.add(sublabel);
         JTextField text2 = new JTextField("RE:",24);
         row2.add(text2);
         //Make "To" text field
         JPanel row1 = new JPanel();
         JLabel tolabel = new JLabel("To:");
         row1.add(tolabel);
         JTextField text1 = new JTextField(24);
         row1.add(text1);
         //Make "Message" text area
         JPanel row3 = new JPanel();
         JLabel Meslabel = new JLabel("Message:");
         row3.add(Meslabel);
         JTextArea text3 = new JTextArea(6,22);
         messagearea.setLineWrap(true);
         messagearea.setWrapStyleWord(true);
         JScrollPane scroll = new JScrollPane(text3,
                                  JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                                  JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
         //SpaceLine
         JPanel spaceline = new JPanel();
         JLabel spacer = new JLabel(" ");
         spaceline.add(spacer);
         row3.add(scroll);
         add(row1);
         add(row2);
         add(spaceline);
         add(spaceline);
         add(row3);
         setVisible(true);
         public static void main(String[] arguments) {
         Message Message = new Message();
    }

    persiandude wrote:
    Topic: Need help with if, else, and which statements and loops.
    How would I display 60 < temp. <= 85 in java
    System.out.println("60 < temp. <= 85 in java");
    another question is how do I ask a question like want to try again (y/n) after a output and asking that everytime I type in yes after a output and terminate when saying No.Sun's [basic Java tutorial|http://java.sun.com/docs/books/tutorial/]
    Sun's [New To Java Center|http://java.sun.com/learning/new2java/index.html].Includes an overview of what Java is, instructions for setting up Java, an intro to programming (that includes links to the above tutorial or to parts of it), quizzes, a list of resources, and info on certification and courses.
    [http://javaalmanac.com|http://javaalmanac.com]. A couple dozen code examples that supplement [The Java Developers Almanac|http://www.amazon.com/exec/obidos/tg/detail/-/0201752808?v=glance].
    jGuru. A general Java resource site. Includes FAQs, forums, courses, more.
    JavaRanch. To quote the tagline on their homepage: "a friendly place for Java greenhorns." FAQs, forums (moderated, I believe), sample code, all kinds of goodies for newbies. From what I've heard, they live up to the "friendly" claim.
    Bruce Eckel's [Thinking in Java|http://mindview.net/Books/DownloadSites] (Available online.)
    Joshua Bloch's [Effective Java|http://www.amazon.com/Effective-Java-2nd-Joshua-Bloch/dp/0321356683/ref=pd_bbs_1?ie=UTF8&s=books&qid=1214349768&sr=8-1]
    Bert Bates and Kathy Sierra's [Head First Java|http://www.amazon.com/exec/obidos/tg/detail/-/0596004656?v=glance].
    James Gosling's [The Java Programming Language|http://www.bookpool.com/sm/0321349806].

  • Help with dropdown menu in JCombo box,Pleaseeeeeee

    Hi,
    I posted earlier but I`II try again. Someone must know how to do this. I have a JComboBox and I want the drop down menu to be a bit wider then the comboBox.
    I tried using this method
    public void setPreferredSize()
              Dimension d = jcbo.getPreferredSize(d);
              jcbo.setPreferredSize(new Dimension(20, d.height));
              jcbo.setPopupWidth(d.width);
    but I recieved a couldn`t resolve symbol error for the last line.
    I imported these into the program]
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    Is there something else I should of imported as well to make this work, or is it another problem all together.Any help would be greatly appreciated.

    Hi , What I want to do is have the dropmenu a bit wider then the comboBox. Here is my code.Please excuse any odd ball mistakes, At this point I have been trying anything.This is an exercise that I have to do fo a java assignment, Hence the weird GUI. In the example pic they gave me.It shows the dropmenu a bit wider than the comboBox, I am sure they through this in to screw with my brain, I have put comment tags Around the stuff I tried to use. Any help with this would be greatly appreciated.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    //import javax.swing.plaf.basic.*;
    public class Exercise9_3 extends JFrame implements ActionListener
         private JTextField nameField;
         private JTextArea nameArea;
         private JButton storeButton;
         private JComboBox jcbo;
         private JPopupMenu popup;
         protected int popupWidth;
         String newline = "\n";
         public Exercise9_3()
              createComponets();
              addComponets();
              setTitle("Exercise9_3");
         private void createComponets ()
              nameField = new JTextField(19);
              nameArea = new JTextArea(10, 15);
              storeButton = new JButton("Store");
              storeButton.addActionListener(this);
              jcbo = new JComboBox();
              jcbo.addActionListener(this);
         /*8public void setPreferredSize()
              Dimension d = jcbo.getPreferredSize(d);
              //jcbo.setPreferredSize(new Dimension(20, d.height));
              //jcbo.setPopupWidth(d.width);
         private void addComponets()
              JPanel p1 = new JPanel();
              p1.setLayout (new FlowLayout());
              p1.add(nameField);
              p1.add(nameArea);
              p1.add(jcbo);
              JPanel p2 = new JPanel();
              p2.setLayout (new FlowLayout());
              p2.add (storeButton);
              getContentPane().setLayout(new BorderLayout());
              getContentPane().add(p1, BorderLayout.CENTER);
              getContentPane().add(p2, BorderLayout.SOUTH);
         public void actionPerformed(ActionEvent e)
              if(e.getSource() == storeButton)
                   String s = nameField.getText();
                   jcbo.addItem(s);
                   jcbo.setSelectedItem(s);
                   String textArea = s ;
                   String text = nameField.getText();
                   nameArea.append(text + newline);
         nameField.selectAll();
         nameField.setText("");
         nameField.requestFocus();
              if (e.getSource() == jcbo)
    /**retrieve the input as a string*/
    String selectedName = (String)jcbo.getSelectedItem();
    /**set the name that was selected from the ComboBox and add it to textfield*/
    nameField.setText(selectedName);
         public static void main(String [] args)
              Exercise9_3 frame = new Exercise9_3();
              frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
              frame.pack();
              frame.setVisible(true);
              Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
              int screenWidth = screenSize.width;
              int screenHeight = screenSize.height;
              // Get dimension of the frame
              Dimension frameSize = frame.getSize();
              int x = (screenWidth - frameSize.width)/2;
              int y = (screenHeight- frameSize.height)/2;
         frame.setLocation(x,y);

  • Help with image viewer

    Would love some help with this one.. I am new so please bare with me. This app just reads contents of a txt file. What I am trying to add is the ability to display an image inside the program frame with scrolls bars.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    public class Viewer extends JFrame
       private JMenuBar menuBar;
       private JMenu fileMenu;
       private JMenu fontMenu;
       private JMenuItem newItem;
       private JMenuItem openItem;
       private JMenuItem saveItem;
       private JMenuItem saveAsItem;
       private JMenuItem exitItem;
       private JRadioButtonMenuItem monoItem;
       private JRadioButtonMenuItem serifItem;
       private JRadioButtonMenuItem sansSerifItem;
       private JCheckBoxMenuItem italicItem;
       private JCheckBoxMenuItem boldItem;
       private String filename;
       private JTextArea editorText;
         private JLabel label;
       private final int NUM_LINES = 20;
       private final int NUM_CHARS = 40;
       public Viewer()
          setTitle("Viewer");
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          editorText = new JTextArea(NUM_LINES, NUM_CHARS);
          editorText.setLineWrap(true);
          editorText.setWrapStyleWord(true);
          JScrollPane scrollPane = new JScrollPane(editorText);
          add(scrollPane);
          buildMenuBar();
          pack();
          setVisible(true);
       private void buildMenuBar()
          buildFileMenu();
          buildFontMenu();
          menuBar = new JMenuBar();
          menuBar.add(fileMenu);
          menuBar.add(fontMenu);
          setJMenuBar(menuBar);
       private void buildFileMenu()
          newItem = new JMenuItem("New");
          newItem.setMnemonic(KeyEvent.VK_N);
          newItem.addActionListener(new NewListener());
          openItem = new JMenuItem("Open");
          openItem.setMnemonic(KeyEvent.VK_O);
          openItem.addActionListener(new OpenListener());
          saveItem = new JMenuItem("Save");
          saveItem.setMnemonic(KeyEvent.VK_S);
          saveItem.addActionListener(new SaveListener());
          saveAsItem = new JMenuItem("Save As");
          saveAsItem.setMnemonic(KeyEvent.VK_A);
          saveAsItem.addActionListener(new SaveListener());
          exitItem = new JMenuItem("Exit");
          exitItem.setMnemonic(KeyEvent.VK_X);
          exitItem.addActionListener(new ExitListener());
          fileMenu = new JMenu("File");
          fileMenu.setMnemonic(KeyEvent.VK_F);
          fileMenu.add(newItem);
          fileMenu.add(openItem);
          fileMenu.addSeparator();
          fileMenu.add(saveItem);
          fileMenu.add(saveAsItem);
          fileMenu.addSeparator();
          fileMenu.add(exitItem);
       private void buildFontMenu()
          monoItem = new JRadioButtonMenuItem("Monospaced");
          monoItem.addActionListener(new FontListener());
          serifItem = new JRadioButtonMenuItem("Serif");
          serifItem.addActionListener(new FontListener());
          sansSerifItem =
                  new JRadioButtonMenuItem("SansSerif", true);
          sansSerifItem.addActionListener(new FontListener());
          ButtonGroup group = new ButtonGroup();
          group.add(monoItem);
          group.add(serifItem);
          group.add(sansSerifItem);
          italicItem = new JCheckBoxMenuItem("Italic");
          italicItem.addActionListener(new FontListener());
          boldItem = new JCheckBoxMenuItem("Bold");
          boldItem.addActionListener(new FontListener());
          fontMenu = new JMenu("Font");
          fontMenu.setMnemonic(KeyEvent.VK_T);
          fontMenu.add(monoItem);
          fontMenu.add(serifItem);
          fontMenu.add(sansSerifItem);
          fontMenu.addSeparator();
          fontMenu.add(italicItem);
          fontMenu.add(boldItem);
       private class NewListener implements ActionListener
          public void actionPerformed(ActionEvent e)
             editorText.setText("");
             filename = null;
       private class OpenListener implements ActionListener
          public void actionPerformed(ActionEvent e)
             int chooserStatus;
             JFileChooser chooser = new JFileChooser();
             chooserStatus = chooser.showOpenDialog(null);
             if (chooserStatus == JFileChooser.APPROVE_OPTION)
                File selectedFile = chooser.getSelectedFile();
                filename = selectedFile.getPath();
                if (!openFile(filename))
                   JOptionPane.showMessageDialog(null,
                                    "Error reading " +
                                    filename, "Error",
                                    JOptionPane.ERROR_MESSAGE);
          private boolean openFile(String filename)
             boolean success;
             String inputLine, editorString = "";
             FileReader freader;
             BufferedReader inputFile;
                   label = new JLabel();
                    add(label);
             try
                freader = new FileReader(filename);
                inputFile = new BufferedReader(freader);
                inputLine = inputFile.readLine();
                while (inputLine != null)
                   editorString = editorString +
                                  inputLine + "\n";
                   inputLine = inputFile.readLine();
                editorText.setText(editorString);
                inputFile.close(); 
                success = true;
             catch (IOException e)
                success = false;
             return success;
       private class SaveListener implements ActionListener
          public void actionPerformed(ActionEvent e)
             int chooserStatus;
             if (e.getActionCommand() == "Save As" ||
                 filename == null)
                JFileChooser chooser = new JFileChooser();
                chooserStatus = chooser.showSaveDialog(null);
                if (chooserStatus == JFileChooser.APPROVE_OPTION)
                   File selectedFile =
                                 chooser.getSelectedFile();
                   filename = selectedFile.getPath();
             if (!saveFile(filename))
                JOptionPane.showMessageDialog(null,
                                   "Error saving " +
                                   filename,
                                   "Error",
                                   JOptionPane.ERROR_MESSAGE);
          private boolean saveFile(String filename)
             boolean success;
             String editorString;
             FileWriter fwriter;
             PrintWriter outputFile;
             try
                fwriter = new FileWriter(filename);
                outputFile = new PrintWriter(fwriter);
                editorString = editorText.getText();
                outputFile.print(editorString);
                outputFile.close();
                success = true;
             catch (IOException e)
                 success = false;
             return success;
       private class ExitListener implements ActionListener
          public void actionPerformed(ActionEvent e)
             System.exit(0);
       private class FontListener implements ActionListener
          public void actionPerformed(ActionEvent e)
             Font textFont = editorText.getFont();
             String fontName = textFont.getName();
             int fontSize = textFont.getSize();
             int fontStyle = Font.PLAIN;
             if (monoItem.isSelected())
                fontName = "Monospaced";
             else if (serifItem.isSelected())
                fontName = "Serif";
             else if (sansSerifItem.isSelected())
                fontName = "SansSerif";
             if (italicItem.isSelected())
                fontStyle += Font.ITALIC;
             if (boldItem.isSelected())
                fontStyle += Font.BOLD;
             editorText.setFont(new Font(fontName,
                                    fontStyle, fontSize));
       public static void main(String[] args)
          Viewer ve = new Viewer();
    }I tried using JLabel() but I cant seem to make it work. Whenever i browse and select a .jpg it displays "�������t���o\�[��+�p��B3�+�p��B3�"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    In the future, Swing related questions should be posted in the Swing forum.
    Whenever i browse and select a .jpg it displays "�������t���o\�[��+�p��B3�+�p��B3�" You can read in a jpg file and treat it like a text file.
    Read the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/components/icon.html]How to Use Icons for the proper way to read images.

  • Need help with debugging PLEASE

    Hi,
    I'm new to Java and was given an assignment to debug a program. I am completely lost and really havent gone over most of the stuff that is in this program. I would greatly appreciate any help with this that I can get.
    Here is my code:
    import java.util.*;
    import javax.swing.*;
    public class IndexHitFrequency
    private final int NUMBER_OF_SIMULATIONS = 1000;
    private int indexHit[] = new int [10];
    public IndexHitFrequency()
    Random generator = new Random(); // for generating random number
    int array[] = {6, 2, 4, 8, 5, 0, 1, 7, 3, 9 };
    //convert to ArrayList and sort it
    List list = new ArrayList(Arrays.asList(array));
    for (int i = 0; i < NUMBER_OF_SIMULATIONS; i++)
    //generate random number
    int randomNumber = generator.nextInt(array.length);
    // get index hit
    int index = Collections.binarySearch(list, randomNumber) ;
    // save index hit to array
    if(index > -1)
    indexHit[index]++;
    }//end for
    String output = "Index\tFrequency\t\n";
    //append the frequency of index hit to output
    for (int i = 0; i < indexHit.length; i++)
    output += i + "\t" + indexHit[i] + "\t\n";
    //display result
    JTextArea outputArea = new JTextArea();
    outputArea.setText(output);
    JOptionPane.showMessageDialog(null, outputArea, "Search random number 1000 times" ,
    JOptionPane.INFORMATION_MESSAGE);
    System.exit(0);
    }// end constructor
    public static void main (String [] args)
    new IndexHitFrequency();
    } // end class IndexHitFrequency
    I get these errors after trying to compile:
    "IndexHitFrequency.java": Error #: 300 : method asList(int[]) not found in class java.util.Arrays at line 17, column 40
    "IndexHitFrequency.java": Error #: 300 : method binarySearch(java.util.List, int) not found in class java.util.Collections at line 24, column 34

    C:\Java\Tutorial\rem>javac IndexHitFrequency.java
    IndexHitFrequency.java:15: asList(java.lang.Object[]) in java.util.Arrays cannot
    be applied to (int[])
    List list = new ArrayList(Arrays.asList(array));
                                    ^
    IndexHitFrequency.java:22: cannot find symbol
    symbol  : method binarySearch(java.util.List,int)
    location: class java.util.Collections
    int index = Collections.binarySearch(list, randomNumber) ;
                           ^
    2 errors
    C:\Java\Tutorial\rem>Copied source and compiled in DOS window ( XP's cmd.exe) and got these error messages...
    I think these error are more clear than the ones you posted, so this should help you resolve the problem...
    - MaxxDmg...
    - ' He who never sleeps... '

  • Help with if statement in cursor and for loop to get output

    I have the following cursor and and want to use if else statement to get the output. The cursor is working fine. What i need help with is how to use and if else statement to only get the folderrsn that have not been updated in the last 30 days. If you look at the talbe below my select statement is showing folderrs 291631 was updated only 4 days ago and folderrsn 322160 was also updated 4 days ago.
    I do not want these two to appear in my result set. So i need to use if else so that my result only shows all folderrsn that havenot been updated in the last 30 days.
    Here is my cursor:
    /*Cursor for Email procedure. It is working Shows userid and the string
    You need to update these folders*/
    DECLARE
    a_user varchar2(200) := null;
    v_assigneduser varchar2(20);
    v_folderrsn varchar2(200);
    v_emailaddress varchar2(60);
    v_subject varchar2(200);
    Cursor c IS
    SELECT assigneduser, vu.emailaddress, f.folderrsn, trunc(f.indate) AS "IN DATE",
    MAX (trunc(fpa.attemptdate)) AS "LAST UPDATE",
    trunc(sysdate) - MAX (trunc(fpa.attemptdate)) AS "DAYS PAST"
    --MAX (TRUNC (fpa.attemptdate)) - TRUNC (f.indate) AS "NUMBER OF DAYS"
    FROM folder f, folderprocess fp, validuser vu, folderprocessattempt fpa
    WHERE f.foldertype = 'HJ'
    AND f.statuscode NOT IN (20, 40)
    AND f.folderrsn = fp.folderrsn
    AND fp.processrsn = fpa.processrsn
    AND vu.userid = fp.assigneduser
    AND vu.statuscode = 1
    GROUP BY assigneduser, vu.emailaddress, f.folderrsn, f.indate
    ORDER BY fp.assigneduser;
    BEGIN
    FOR c1 IN c LOOP
    IF (c1.assigneduser = v_assigneduser) THEN
    dbms_output.put_line(' ' || c1.folderrsn);
    else
    dbms_output.put(c1.assigneduser ||': ' || 'Overdue Folders:You need to update these folders: Folderrsn: '||c1.folderrsn);
    END IF;
    a_user := c1.assigneduser;
    v_assigneduser := c1.assigneduser;
    v_folderrsn := c1.folderrsn;
    v_emailaddress := c1.emailaddress;
    v_subject := 'Subject: Project for';
    END LOOP;
    END;
    The reason I have included the folowing table is that I want you to see the output from the select statement. that way you can help me do the if statement in the above cursor so that the result will look like this:
    emailaddress
    Subject: 'Project for ' || V_email || 'not updated in the last 30 days'
    v_folderrsn
    v_folderrsn
    etc
    [email protected]......
    Subject: 'Project for: ' Jim...'not updated in the last 30 days'
    284087
    292709
    [email protected].....
    Subject: 'Project for: ' Kim...'not updated in the last 30 days'
    185083
    190121
    190132
    190133
    190159
    190237
    284109
    286647
    294631
    322922
    [email protected]....
    Subject: 'Project for: Joe...'not updated in the last 30 days'
    183332
    183336
    [email protected]......
    Subject: 'Project for: Sam...'not updated in the last 30 days'
    183876
    183877
    183879
    183880
    183881
    183882
    183883
    183884
    183886
    183887
    183888
    This table is to shwo you the select statement output. I want to eliminnate the two days that that are less than 30 days since the last update in the last column.
    Assigneduser....Email.........Folderrsn...........indate.............maxattemptdate...days past since last update
    JIM.........      jim@ aol.com.... 284087.............     9/28/2006.......10/5/2006...........690
    JIM.........      jim@ aol.com.... 292709.............     3/20/2007.......3/28/2007............516
    KIM.........      kim@ aol.com.... 185083.............     8/31/2004.......2/9/2006.............     928
    KIM...........kim@ aol.com.... 190121.............     2/9/2006.........2/9/2006.............928
    KIM...........kim@ aol.com.... 190132.............     2/9/2006.........2/9/2006.............928
    KIM...........kim@ aol.com.... 190133.............     2/9/2006.........2/9/2006.............928
    KIM...........kim@ aol.com.... 190159.............     2/13/2006.......2/14/2006............923
    KIM...........kim@ aol.com.... 190237.............     2/23/2006.......2/23/2006............914
    KIM...........kim@ aol.com.... 284109.............     9/28/2006.......9/28/2006............697
    KIM...........kim@ aol.com.... 286647.............     11/7/2006.......12/5/2006............629
    KIM...........kim@ aol.com.... 294631.............     4/2/2007.........3/4/2008.............174
    KIM...........kim@ aol.com.... 322922.............     7/29/2008.......7/29/2008............27
    JOE...........joe@ aol.com.... 183332.............     1/28/2004.......4/23/2004............1585
    JOE...........joe@ aol.com.... 183336.............     1/28/2004.......3/9/2004.............1630
    SAM...........sam@ aol.com....183876.............3/5/2004.........3/8/2004.............1631
    SAM...........sam@ aol.com....183877.............3/5/2004.........3/8/2004.............1631
    SAM...........sam@ aol.com....183879.............3/5/2004.........3/8/2004.............1631
    SAM...........sam@ aol.com....183880.............3/5/2004.........3/8/2004.............1631
    SAM...........sam@ aol.com....183881.............3/5/2004.........3/8/2004.............1631
    SAM...........sam@ aol.com....183882.............3/5/2004.........3/8/2004.............1631
    SAM...........sam@ aol.com....183883.............3/5/2004.........3/8/2004.............1631
    SAM...........sam@ aol.com....183884.............3/5/2004.........3/8/2004............     1631
    SAM...........sam@ aol.com....183886.............3/5/2004.........3/8/2004............     1631
    SAM...........sam@ aol.com....183887.............3/5/2004.........3/8/2004............     1631
    SAM...........sam@ aol.com....183888.............3/5/2004.........3/8/2004............     1631
    PAT...........pat@ aol.com.....291630.............2/23/2007.......7/8/2008............     48
    PAT...........pat@ aol.com.....313990.............2/27/2008.......7/28/2008............28
    NED...........ned@ aol.com.....190681.............4/4/2006........8/10/2006............746
    NED...........ned@ aol.com......95467.............6/14/2006.......11/6/2006............658
    NED...........ned@ aol.com......286688.............11/8/2006.......10/3/2007............327
    NED...........ned@ aol.com.....291631.............2/23/2007.......8/21/2008............4
    NED...........ned@ aol.com.....292111.............3/7/2007.........2/26/2008............181
    NED...........ned@ aol.com.....292410.............3/15/2007.......7/22/2008............34
    NED...........ned@ aol.com.....299410.............6/27/2007.......2/27/2008............180
    NED...........ned@ aol.com.....303790.............9/19/2007.......9/19/2007............341
    NED...........ned@ aol.com.....304268.............9/24/2007.......3/3/2008............     175
    NED...........ned@ aol.com.....308228.............12/6/2007.......12/6/2007............263
    NED...........ned@ aol.com.....316689.............3/19/2008.......3/19/2008............159
    NED...........ned@ aol.com.....316789.............3/20/2008.......3/20/2008............158
    NED...........ned@ aol.com.....317528.............3/25/2008.......3/25/2008............153
    NED...........ned@ aol.com.....321476.............6/4/2008.........6/17/2008............69
    NED...........ned@ aol.com.....322160.............7/3/2008.........8/21/2008............4
    MOE...........moe@ aol.com.....184169.............4/5/2004.......12/5/2006............629
    [email protected]/27/2004.......3/8/2004............1631
    How do I incorporate a if else statement in the above cursor so the two days less than 30 days since last update are not returned. I do not want to send email if the project have been updated within the last 30 days.
    Edited by: user4653174 on Aug 25, 2008 2:40 PM

    analytical functions: http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/functions2a.htm#81409
    CASE
    http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96624/02_funds.htm#36899
    http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96624/04_struc.htm#5997
    Incorporating either of these into your query should assist you in returning the desired results.

  • I need help with Sunbird Calendar, how can I transfer it from one computer to the other and to my iphone?

    I installed Sunbird in one computer and my calendar has all my infos, events, and task that i would like to see on another computer that i just downloaded Sunbird into. Also, is it possible I can access Sunbird on my iphone?
    Thank you in advance,

    Try the forum here - http://forums.mozillazine.org/viewforum.php?f=46 - for help with Sunbird, this forum is for Firefox support.

  • Hoping for some help with a very frustrating issue!   I have been syncing my iPhone 5s and Outlook 2007 calendar and contacts with iCloud on my PC running Vista. All was well until the events I entered on the phone were showing up in Outlook, but not

    Hoping for some help with a very frustrating issue!
    I have been syncing calendar and contacts on my iPhone 5 and Outlook 2007 using iCloud  2.1.3 (my PC is running Vista). All was well until the events I entered on the phone were showing up in Outlook, but not the other way around. I’ve tried the usual recommended steps: deselecting calendar and contacts in the iCloud control panel and then re-selecting, signing out of the panel and back in, and repairing the Outlook installation in control panel.  I even uninstalled iCloud on the PC and downloaded it again (same version). 
    The furthest I’ve gotten is step 2 (and once, step 3) of 7 while performing “Outlook Setup For iCloud.” At that point I get, “Your setup couldn’t be started because of an unexpected error.”  After the first attempt at all this, all my calendar events disappeared from Outlook, although they are still in iCloud calendar and on my phone.
    Sound familiar?  Any ideas on how to solve this iCloud/Outlook issue?  Thanks much in advance!

    Hoping for some help with a very frustrating issue!
    I have been syncing calendar and contacts on my iPhone 5 and Outlook 2007 using iCloud  2.1.3 (my PC is running Vista). All was well until the events I entered on the phone were showing up in Outlook, but not the other way around. I’ve tried the usual recommended steps: deselecting calendar and contacts in the iCloud control panel and then re-selecting, signing out of the panel and back in, and repairing the Outlook installation in control panel.  I even uninstalled iCloud on the PC and downloaded it again (same version). 
    The furthest I’ve gotten is step 2 (and once, step 3) of 7 while performing “Outlook Setup For iCloud.” At that point I get, “Your setup couldn’t be started because of an unexpected error.”  After the first attempt at all this, all my calendar events disappeared from Outlook, although they are still in iCloud calendar and on my phone.
    Sound familiar?  Any ideas on how to solve this iCloud/Outlook issue?  Thanks much in advance!

Maybe you are looking for

  • Unable to uninstall Firefox from desktop

    I am trying to uninstall Firefox from my desktop, and I am not allowed to do this and it will not disappear. Please let me know what I can do. It does not work as a browser, and I can't uninstall it. Thanks.

  • Webservice in Webdynpro ABAP

    Hi Please provide tutorial and general guidelines for settings  for consuming webservice in webdynpro ABAP. Thanks & Regards, Chaitali

  • Desperate for help: My iPhoto library is "unreadable"

    HELP! Earlier I tried to open my iPhoto library and it prompted me with a weird message that I've never seen in all of my years using the software. I forget the exact words of the alert because this occurred like two hours ago, but it was something a

  • Help!  Can't sync due to itunes says my ipod is already synced with another

    I deleted and reinstalled i-tunes. Now, when I try to sync, it says my i-pod is synced with another computer. How do I get it to recognize this as the only computer that it is synced with?

  • Bug in formula %A ?

    Hello I've got a query using formula %A. It seems that when result is under 0,4% BW shows 0.0 instead of showing the result of formula. For instance, if result of formula is 0.23% BW will show 0.0%. Have anyone notice this issue before ? Kinds Regard