Rounding and displaying doubles

How do you stop a double (eg 12646903) being displayed as 1.2646903E7? ??? .
Lynda

If you are talking about rounding doubles, you should take a look at the BigDecimal class. For example if you where rounding currency and lets say you are trying to convert 1.0 at a rate of .787564 you would normally get
1.26973807842918162841369082385685 but if you wanted to round this to 1.27 you could do the following ...
double myAmount = 1.0;
double myRateOfExchange = .787564;
double myDouble = myAmount / myRateOfExchange;
BigDecimal bd = new BigDecimal(myDouble).setScale(2,BigDecimal.ROUND_HALF_DOWN);You will need to import BigDecimal to use it. import java.math.BigDecimal;Depending on how you want to round you may want to look at the field index for the BigDecimal class.
Hope this helps

Similar Messages

  • IMac display issues: black icons and folders, doubled up files in finder windows, programs won't update

    HELP!
    I'm hoping someone can help with my iMac 27" purchased in 2010.  From a previous discussion I started a year ago, I have had virtually nothing but trouble with it.  After the internal hard drive crashing, I was able to install OS X on an external drive and used it for a good 8 months to drive my iMac and I took it to an expert who has replaced it with a 3tb HDD, but at some point the display has gone crazy.  I am not certain if it is hardware, i.e. graphics card or video but I'll describe the symptoms and add some pics to see if anyone has seen this before and knows what the problem may be.
    1.     90% of the screen was covered with white with just a portion of the desktop showing through.
            (This happened when I tried to reinstall OS X on the old HDD and the new one, but didn't happen when using OS X install disc)
    2.     Files, folders, photos and some icons on the dock go black
    3.     Files and photos double up when in Finder.  When I'm viewing photos, it shows them but all the previous panes and the photos are jumbled behind the
            photos.
    4.     Anything I open in Preview is completely black, but ColourSync Utility opens everything fine.
    5.     Programs won't update.  They will download onto my iMac but won't update.  Some say, because I don't have OS X 10.6.8 others just won't open.
            Including Google Chrome, opens with two tabs open but when I open a third tab the rainbow wheel just turns.  Skype won't open just gives a failure
            report.
    6.     10.6.8 Update Combo downloads but when I restart the screen is covered in white - as in 1. and I have to reinstall OS X 10.6.2 to get the screen to               clear but then all the above problems continue.
    7.     Sometimes videos don't display in Youtube, or the entire page other than the video player is covered in rainbow lines.
    8.     Some buttons are blacked out on selection pages, i.e. system preferences, or saving screens
    9.     Photos opened in FB go upside down and flicker all over the page as my mouse runs over them.
    10.   Photos won't upload into internet editing programs.
    I can't find anyone who has had the same issue in all of the discussions I've looked at, but it sounds like I have a video problem, but I wondered if it might be a software problem with flash or something.  Or I have something malicious on my computer.
    I also have an iphone 5 that faulted with the iTunes and USB icons and won't fix after trying one of those R-Sims, and I wondered if somewhere along the line it may have even had a virus/trojan/malware that has infected my external drive and then my internal drive.  A reason I have thought that is because I have used my daughter's MacPro laptop and plugged in my external drive and I noticed the windows in hers were starting to do the same thing.
    And on top of all that, my fans didn't work for over a year and I had to place an external fan at the back of the computer or it would overheat and shut down, but after resetting the SMU it started working again, but it is very noisy. I have tried to download SMC Fan Control and although it downloads to the HDD, it won't open.
    Sorry its such a long post, I do hope with all of this information someone can help me.
    Thanks so much.

    HI and Welcome to Apple Discussions...
    *Soon after, I installed Quake Wars, L4D 1, 2, Mass Effect 2, Need For Speed: Undercover, Mozilla Firefox and *Sophos Enterprise AV*. Approximately a week after installation, I began to experience malfunctions varying greatly*
    Macs get grumpy when running anti virus software. Disable or completely uninstall Sophos A/V and see if that makes a difference. A/V software on a Mac will slow the drive down more and more as time goes on.
    Also, check the vendor sites for each 3rd party software you installed to make sure they are compatible with 10.6.x
    The "hard reboots" are a result of the system freezing due to incompatible or outdated software.
    Carolyn
    Message was edited by: Carolyn Samit

  • Calculating and displaying the Length of the side of a triangle

    Hi everyone. I am currently working on Dragging and Stretching a triangle on screen. Ive got it working to a certain extent but the only problem is that whenever I go to the point from which i have to drag my triangle i.e. the Left hand Corner of the BAse at exactly 300,300 it redraws a new triangle below the existing one and then when i stretch it from the top and the right it leaves a trail of triangles everytime. But when i resize my window it clears the trail only to start agian when I drag or stretch it...
    All my code for wahtever I have done is displayed below. I would appreciate all the help that any one can offer.
    Secondly , as I stretch my triangle I would like to calculate My Length of the hypotenuse and the other 2 sides as they change and display it in System.out.println for now...
    PLEASE HELP
    the code is
    This is my Main Form --- Interactive Geometry.java
    import java.awt.BorderLayout;
    import java.awt.Container;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseMotionListener;
    import javax.swing.JFrame;
    * InteractiveGeometry.java
    * Created on 30 November 2004, 20:29
    * @author  Kripa Bhojwani
    public class InteractiveGeometry extends javax.swing.JFrame {
        public EastPanel eastpanel;
        public Container container;
        public GeomPanel gp;
        public boolean pressed = false;
        public boolean pressT = false;
        public boolean pressR = false;
        /** Creates new form InteractiveGeometry */
        public InteractiveGeometry() {
            initComponents();
            eastpanel = new EastPanel();
            container = new Container();
            Model model = new Model(300,150,450,300,300,300);
            gp = new GeomPanel(model);
            container = getContentPane();
            container.add(eastpanel,BorderLayout.EAST);
            container.add(gp,BorderLayout.CENTER);
            setSize(1400,9950);
            gp.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());
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        private void initComponents() {
            jMenuBar2 = new javax.swing.JMenuBar();
            jMenu2 = new javax.swing.JMenu();
            jMenuItem1 = new javax.swing.JMenuItem();
            jMenu1 = new javax.swing.JMenu();
            jMenuItem2 = new javax.swing.JMenuItem();
            addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
                public void mouseDragged(java.awt.event.MouseEvent evt) {
                    formMouseDragged(evt);
                public void mouseMoved(java.awt.event.MouseEvent evt) {
                    formMouseMoved(evt);
            addWindowListener(new java.awt.event.WindowAdapter() {
                public void windowClosing(java.awt.event.WindowEvent evt) {
                    exitForm(evt);
            jMenuBar2.setBackground(new java.awt.Color(0, 102, 204));
            jMenu2.setBackground(new java.awt.Color(222, 222, 238));
            jMenu2.setText("File");
            jMenu2.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jMenu2ActionPerformed(evt);
            jMenuItem1.setBackground(new java.awt.Color(204, 255, 255));
            jMenuItem1.setText("Exit");
            jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jMenuItem1ActionPerformed(evt);
            jMenu2.add(jMenuItem1);
            jMenuBar2.add(jMenu2);
            jMenu1.setBackground(new java.awt.Color(199, 215, 255));
            jMenu1.setText("Theorem ");
            jMenuItem2.setText("Pythagoras Theorem");
            jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jMenuItem2ActionPerformed(evt);
            jMenu1.add(jMenuItem2);
            jMenuBar2.add(jMenu1);
            setJMenuBar(jMenuBar2);
            pack();
        private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {
            // TODO add your handling code here:
        private void formMouseDragged(java.awt.event.MouseEvent evt) {
            // TODO add your handling code here:
        private void formMouseMoved(java.awt.event.MouseEvent evt) {
            // TODO add your handling code here:
        public void mouseDragged(MouseEvent me) {
            setTitle("Dragging: x=" + me.getX() + "; y=" + me.getY());
        private void jMenu2ActionPerformed(java.awt.event.ActionEvent evt) {
            // TODO add your handling code here:
        private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {
            // TODO add your handling code here:
            System.exit(0);
        /** Exit the Application */
        private void exitForm(java.awt.event.WindowEvent evt) {
            System.exit(0);
         * @param args the command line arguments
        public static void main(String args[]) {
            InteractiveGeometry ig = new InteractiveGeometry();
            ig.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            ig.show();
            // new InteractiveGeometry().show();
        // Variables declaration - do not modify
        private javax.swing.JMenu jMenu1;
        private javax.swing.JMenu jMenu2;
        private javax.swing.JMenuBar jMenuBar2;
        private javax.swing.JMenuItem jMenuItem1;
        private javax.swing.JMenuItem jMenuItem2;
        // End of variables declaration
    This is my Panel -- GeomPanel.java which draws everything -- /*
    * GeomPanel.java
    * Created on 30 November 2004, 20:29
    import java.awt.*;
    import java.util.*;
    import javax.swing.*;
    import java.awt.Graphics.*;
    import java.awt.event.MouseListener;
    import java.awt.event.MouseMotionListener;
    import java.awt.geom.Line2D;
    import java.awt.geom.Point2D;
    import java.awt.event.*;
    import java.awt.Graphics2D;
    import java.awt.geom.Ellipse2D;
    import javax.swing.event.TableModelListener;
    import javax.swing.JScrollPane;
    import javax.swing.event.*;
    import java.awt.Dimension;
    import java.awt.Container.*;
    * @author Kripa Bhojwani
    public class GeomPanel extends javax.swing.JPanel implements Observer, MouseMotionListener, MouseListener {
    private Model model;
    private boolean pressed = false;
    private boolean pressT = false;
    private boolean pressR = false;
    /** Creates new form GeomPanel */
    public GeomPanel(Model model) {
    this.model = model;
    model.addObserver(this);
    addMouseListener(this);
    addMouseMotionListener(this);
    initComponents();
    setBackground(Color.getHSBColor(6,600,660));
    public void paintComponent(Graphics gfx) {
    Graphics2D g = (Graphics2D) gfx;
    Point tc = model.getTop();
    Point lc = model.getLeft();
    Point rc = model.getRight();
    Point2D.Double p1 = new Point2D.Double(tc.getX(),tc.getY());
    Point2D.Double p2 = new Point2D.Double(lc.getX(),lc.getY());
    Point2D.Double p3 = new Point2D.Double(rc.getX(),rc.getY());
    Line2D.Double line = new Line2D.Double(p1, p2);
    Line2D.Double line1 = new Line2D.Double(p2, p3);
    Line2D.Double line2 = new Line2D.Double(p1, p3);
    g.setColor(Color.BLACK);
    g.draw(line);
    g.draw(line2);
    g.draw(line1);
    /** This method is called from within the constructor to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    private void initComponents() {
    setLayout(new java.awt.BorderLayout());
    addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
    public void mouseDragged(java.awt.event.MouseEvent evt) {
    formMouseDragged(evt);
    private void formMouseDragged(java.awt.event.MouseEvent evt) {
    // TODO add your handling code here:
    public void mouseClicked(MouseEvent e) {
    public void mouseDragged(MouseEvent e) {
    System.out.println("Dragged at "+ e.getX()+ "," + e.getY());
    if(pressed == true){
    model.setLeft(e.getX() , e.getY());
    else if(pressT == true){
    model.setTop(e.getX() , e.getY());
    else if (pressR == true){
    model.setRight(e.getX(), e.getY());
    else{
    pressed = false;
    pressT= false;
    pressR=false;
    repaint();
    public void mouseEntered(MouseEvent e) {
    public void mouseExited(MouseEvent e) {
    public void mouseMoved(MouseEvent e) {
    System.out.println("Mouse at " + e.getX() +"," + e.getY());
    public void mousePressed(MouseEvent e) {
    if (model.getLeft().getX()== e.getX() && model.getLeft().getY()== e.getY()){
    pressed = true;
    else if (model.getTop().getX()==e.getX() && model.getTop().getY()==e.getY()){
    pressT = true;
    else if(model.getRight().getX() == e.getX() && model.getRight().getY()==e.getY()){
    pressR = true;
    // else if(model.getCircle().getX() == e.getX() && model.getCircle().getY() == e.getY()){
    // inoval = true;
    else {
    pressed =false;
    pressT = false;
    pressR = false;
    } repaint();
    public void mouseReleased(MouseEvent e) {
    if(pressed == true){
    model.setLeft(e.getX(),e.getY());
    else if (pressT ==true ){
    model.setTop(e.getX(), e.getY());
    else if(pressR ==true){
    model.setRight(e.getX(),e.getY());
    else {
    pressed = false;
    pressT = false;
    pressR = false;
    repaint();
    public void update(Observable o, Object arg) {
    repaint();
    // Variables declaration - do not modify
    // End of variables declaration
    This is my Model class called Model.java which Holds all teh data for my triangle
    import java.awt.Point;
    import java.util.Observable;
    * Model.java
    * Created on 05 December 2004, 14:11
    * @author  Kripa Bhojwani
    public class Model extends Observable{
        private int  x1,x2,x3, y1,y2,y3;
        private int _transx;
        private int _transy;
        private int _c;
        private int _d;
        /** Creates a new instance of Model */
        public Model(int x1, int y1, int x2, int y2, int x3, int y3) {
            this.x1 = x1;
            this.y1 = y1;
            this.x2 = x2;
            this.y2 = y2;
            this.x3 = x3;
            this.y3 = y3;
            setChanged();
            notifyObservers();
        public void setTop(int x1, int y1){
            //this.x1 =x1;
            this.y1= y1;
            setChanged();
            notifyObservers();
        public void setRight(int x2, int y2){
            this.x2 = x2;
            // this.y2 =y2;
            setChanged();
            notifyObservers();
        public void setLeft(int x3, int y3){
            _transx = x3 - this.x3;
            _transy = y3 - this.y3;
            this.x3 += _transx;
            this.y3 += _transy;
            this.y2 += _transy;
            this.x2 += _transx;
            this.x1 += _transx;
            this.y1 += _transy;
            setChanged();
            notifyObservers();
        public Point getTop(){
            Point p = new Point(x1,y1);
            return p;
        public Point getRight(){
            Point p1 = new Point(x2,y2);
            return p1;
        public Point getLeft(){
            Point p3 = new Point(x3,y3);
            return p3;
        public void update() {
            setChanged();
            notifyObservers();
    This is my TableModel which is the JTable to display all the Cordinates and Lengths and other Measurements like angles etc./*
    * TableModel.java
    * Created on 03 December 2004, 15:08
    import javax.swing.JTable;
    import javax.swing.JScrollPane;
    import javax.swing.JPanel;
    import javax.swing.JFrame;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.Observer;
    import javax.swing.event.TableModelEvent;
    import javax.swing.table.AbstractTableModel;
    * @author Kripa Bhojwani
    public class TableModel extends AbstractTableModel implements Observer{
    private String[] columnNames = {"Point", "X Coordinate", "Y Coordinate"};
    private Object[][] data = {};
    private int rowCount;
    private int columnCount;
    /** Creates a new instance of TableModel */
    public TableModel() {
    rowCount = 0;
    columnCount = 3;
    public int getColumnCount() {
    return columnCount;
    public int getRowCount() {
    return rowCount;
    public String getColumnName(int col) {
    return columnNames[col];
    public void setColumnName (String[] name){
    columnNames = name;
    public void setValueAt(Object obj, int row, int col) {
    data[row][col] = obj;
    fireTableCellUpdated(row, col);
    TableModelEvent tme = new TableModelEvent(this);
    fireTableChanged(tme);
    public Object getValueAt(int row, int col) {
    return data[row][col];
    public void update(java.util.Observable o, Object arg) {
    This is the Panel on the east side of My Main application form which will display all the measurements and Cordinates ---EastPanel.java
    import java.awt.BorderLayout;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.event.TableModelListener;
    import java.awt.Dimension;
    * EastPanel.java
    * Created on 04 December 2004, 23:07
    * @author  Kripa Bhojwani
    public class EastPanel extends javax.swing.JPanel implements TableModelListener{
        private TableModel tm;
        /** Creates new form EastPanel */
        public EastPanel() {   
          initComponents();
            tm = new TableModel();
            JTable table1 = new JTable(tm);
            table1.setPreferredScrollableViewportSize(new Dimension(250,264));
            table1.getModel().addTableModelListener(this);
            JScrollPane sp = new JScrollPane(table1);
            add(sp,BorderLayout.EAST);
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        private void initComponents() {
            setLayout(new java.awt.BorderLayout());
        public void tableChanged(javax.swing.event.TableModelEvent e) {
        // Variables declaration - do not modify
        // End of variables declaration
    }                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    

    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 G
    public G()
    TriangleModel tri = new
    ri = 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(),
    Panel(), "North");
    f.getContentPane().add(view);
    f.getContentPane().add(view.getTablePanel(),
    Panel(), "South");
    f.setSize(500,500);
    f.setLocation(200,200);
    f.setVisible(true);
    public static void main(String[] args)
    new G();
    class TriangleModel // (x1,
    y1)
    {                                         //      |\
    static final int SIDES = 3; // | \
    private int cx, cy; // |
    | \
    Polygon triangle; // |_
    |_ _\ (x3, y3)
    int selectedIndex; // (x2,
    (x2, y2)
    NumberFormat nf;
    Line2D[] medians;
    Point2D centroid;
    public TriangleModel(int x1, int y1, int x2, int
    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
    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.y) / (x[2] - p.x)
    x[2] = p.x + (int)((y[2] - p.y) /
    )((y[2] - p.y) / slope);
    // rise / run == (p.y - y[0]) / (p.x
    y - y[0]) / (p.x - x[0])
    y[0] = p.y - (int)((p.x - x[0]) *
    )((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
    the line from
    // any vertex to the midpoint of the opposite
    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],
    Double(x[j], y[j]);
    // get midpoint of line opposite vertex
    double dx = ((double)x[last] -
    le)x[last] - x[next])/2;
    double dy = ((double)y[last] -
    le)y[last] - y[next])/2;
    Point2D oppLineCenter = new
    Center = new Point2D.Double(x[next] + dx,
    y[next]
    y[next] + dy);
    medians[j] = new Line2D.Double(vertex,
    uble(vertex, oppLineCenter);
    // centroid is located on any median 2/3 the
    2/3 the way from the
    // vertex (P1) to the midpoint (P2) on the
    ) on the opposite side
    double[] lengths = getSideLengths();
    double dx = (medians[0].getX2() -
    etX2() - medians[0].getX1())*2/3;
    double dy = (medians[0].getY2() -
    etY2() - medians[0].getY1())*2/3;
    double px = medians[0].getX1() + dx;
    double py = medians[0].getY1() + dy;
    //System.out.println("px = " + nf.format(px)
    rmat(px) +
    // "\tpy = " +
    py = " + 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
    es = 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[last] -
    lengths[opp] *
    lengths[opp] * lengths[opp];
    double divisor = 2 * lengths[j] *
    lengths[j] * lengths[last];
    double vertex = Math.acos(top /
    h.acos(top / divisor);
    vertices[j] =
    ertices[j] = nf.format(Math.toDegrees(vertex));
    return vertices;
    public String[] getLengths()
    double[] lengths = getSideLengths();
    String[] lengthStrs = new
    rs = 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
    rs = new String[lengths.length];
    for(int j = 0; j < squareStrs.length; j++)
    squareStrs[j] = nf.format(lengths[j] *
    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[j], y[j], x[next], y[next]);
    return lengths;
    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:
    id 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
    g2.fill(new Ellipse2D.Double(model.centroid.getX() -
    2,
    model.centroid.getY()
    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
    ox("show construction");
    showCon.addActionListener(new
    ener(new ActionListener()
    public void actionPerformed(ActionEvent
    (ActionEvent e)
    boolean state =
    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",
    ", "angles", "degrees"
    String[] sidesRow = { "vertical",
    rtical", "horizontal", "hypotenuse" };
    String[] anglesRow = { "hyp to ver", "ver to
    "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,
    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 -
    lData[row][col - 1];
    table = new JTable(data, headers)
    public boolean isCellEditable(int row,
    ble(int row, int col)
    return false;
    DefaultTableCellRenderer renderer =
    (DefaultTableCellRenderer)table.getDefaultRenderer(St
    ring.class);
    renderer.setHorizontalAlignment(JLabel.CENTER);
    centroidLabel = new JLabel("centroid
    centroid location: ", JLabel.CENTER);
    Dimension d =
    sion d = centroidLabel.getPreferredSize();
    d.height = table.getRowHeight();
    centroidLabel.setPreferredSize(d);
    JPanel panel = new JPanel(new
    anel(new BorderLayout());
    panel.setBorder(BorderFactory.createTitledBorder("tri
    angle data"));
    panel.add(table);
    panel.add(centroidLabel, "South");
    return panel;
    class TriangleControl extends MouseInputAdapter
    TriangleView view;
    TriangleModel model;
    Point start;
    boolean dragging, altering;
    Rectangle lineLens; // used for line
    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
    centroid location: " +
    model.findCentroid());
    view.repaint(); // for the construction
    truction 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], 4, j + 1);
    view.getCentroidLabel().setText("centroid
    centroid location: " +
    model.findCentroid());
    Hey sorry mate.. ive got a nother problem.
    I need to add loads of theorems to this tool. so i need a JMenu Bar called File with all the normal things. then another Menu called Theorems where i can have a list of JMenuItems with the theorem names --- Like when they click on Pythagoras Theorem it opens up all the triangle and the traingle data that u helped me with.
    The thing is im using netbeans and in netbeans i can do it coz its there and all you got to do is put the components together.
    Please Help
    Thanks...
    Sharan

  • Error in updating and displaying ouput in JSP

    Hi im doing project using jsp files.In part of my project there is vote page and vote result page.
    my vote_page.jsp
    <%@ page import="java.util.*" %>
    <%@ page import="java.sql.*" %>
    <%@ page import="java.text.*" %>
    <%@ page import="java.sql.Date" %>
    <%@ page language = "java" %>
    <%! int ctr=0;%>
    <%! String[] songs=new String[10];%>
    <%
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection connect;
    connect=DriverManager.getConnection("jdbc:odbc:RegisterDataSource");
    Statement state;
    state = connect.createStatement();
    String strQuery1 = "SELECT title FROM ItemEJBTable";
    String str;
    ResultSet result1 = state.executeQuery(strQuery1);
    while(result1.next())
    songs[ctr]=result1.getString("title");
    ctr++;
    connect.close();
    catch(Exception e)
    %>
    <form method="GET" action="http://localhost:8000/Music/Vote_result_page.jsp">
    <p align="center">
    <font><b><u>Vote for your favorite song</u></b></font></p>
    <font><b>       Songs</b></font>
    <font> </font> 
    <select size="1" name="Song1">
    <%
    for(ctr=0;ctr<songs.length;ctr++){
    %>
    <option>
    <% out.println(songs[ctr]);}%>
    </option>
    </select></td>
    </tr>
    </table>
    <input type="submit" value="Vote" name="submit">and my vote_result_page.jsp
    <%@ page import="java.util.*" %>
    <%@ page import="java.sql.*" %>
    <%@ page import="java.text.*" %>
    <%@ page language = "java" %>
    <%! int voteNum=0; %>
    <%! String selSong=new String();
    %>
    <% selSong=request.getParameter("Song1");
    out.println(selSong);
    String selSong1 = selSong.trim().toString();
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection connect;
    connect=DriverManager.getConnection("jdbc:odbc:RegisterDataSource");
    Statement state,state2;
    ResultSet result1;
    state = connect.createStatement();
    state2 = connect.createStatement();
    String strQuery1 = "update Vote_Info set Number_votes=Number_votes+1
    where itemCode=(select itemCode from ItemEJBTable where title='"+selSong+"')";
    state.executeUpdate(strQuery1);
    String strQuery2="select Number_votes from Vote_Info where itemCode =
    (select itemCode from ItemEJBTable where title='"+selSong1+"')";
    result1=state2.executeQuery(strQuery2);
    while(result1.next())
    voteNum=result1.getInt("NumberVotes");
    out.println(selSong+" got "+voteNum+" votes");
    connect.close();
    voteNum=voteNum+1;
    catch(Exception e)
    %>
    <td width="82%" valign="top">
    <!--Display the number of people who have voted for the song-->
    <p align="left"><font face="Arial" size="3" color="#800000">
    <b><u>You voted for the song:</u></b></font>
    <p align="left"><font face="Arial" size="3" color="#800000">
    <b><%=request.getParameter("Song1")%>
    </b></font></p>
    <p align="left"><%= voteNum %> <font face="Arial" size="3" color="#800000">
    people have voted for this song so far.</font></p>
    <input type="submit" value="OK" name="submit">When i select song_no_1 and click on vote button on vote_page.jsp it directs to vote result page and displays that
    1 person has voted for this song and this vote is not updating on table. When i go again to vote page and vote on song_no_2 it says that "2 person have voted this song" even if it is not voted before.
    I dont no where the problem occurs pls help me for this.

    sorry for double posting because i didnt got reply from first one so i thought that nobody have looked on that topic that's why i done this.

  • Adobe reader XI and X wont start up and display thinking icon

    Hi
    I'm running Widows 7 home premium on a 64 bit system with Kapersky's antivirus.  I've tried a bunch of different things to get the Adobe reader to work to no avail.  Adobe reader XI opens and then immediately freezes and displays the thinking symbol.  If I uninstal XI and instal the older X version it works for a short duration of time and then ends up doing the same thing a day later or so.  I really like the Adobe reader and its capabilities and need it to view PDF files.  What the heck is going on?  Can anyone help me?
    Thank You
    Cody
    Bend, OR

    Some things to try...
    Using Windows Explorer navigate to C:\Program Files (x86)\Adobe\Reader 11.0\Reader, then double-click on Eula.exe and accept the license agreement
    Can you open Adobe Reader by itself?  If so, try disabling Protected Mode [Edit | Preferences | Security (Enhanced)].
    If you cannot open Reader by itself, try to disable Protected Mode in the registry; download, unzip, then run the attached registry script
    It could even be a malware issue; see http://helpx.adobe.com/acrobat/kb/reader-core-dll-error.html

  • Can anyone tell me how to click the sphere and display a messege???

    /* Goal: Want to create a bunch of spheres, and when a sphere is clicked:
    * 1) display a message in the textfield
    * 2) transform the position of the sphere to (0,0,0)
    * (if (0,0.0) is occupied by another sphere, move that sphere somewhere.
    * Achieved : create the spheres,can transform,rotate and zoome the spheres.
    * Problem: having trouble to click it and display text and change location (problem with picking)
    * Thanks!!!!!!
    public class node extends Applet{
    public static void main(String[] args){
    new MainFrame(new node(),1000,800);
    Sphere sphere;
    PickCanvas pc;
    TextField text;
    public void init(){
    setLayout(new BorderLayout());
    GraphicsConfiguration gc=
    SimpleUniverse.getPreferredConfiguration();
    Canvas3D cv=new Canvas3D(gc);
    add(cv,BorderLayout.CENTER);
    //add mouseListener
    //add mouseListener for click
    cv.addMouseListener(new MouseAdapter(){
    public void mouseClicked
    (java.awt.event.MouseEvent mouseEvent){
    pick(mouseEvent);
    //create textfield down below
    text=new TextField();
    add(text,BorderLayout.SOUTH);
    BranchGroup bg=createSceneGraph(cv);
    bg.compile();
    SimpleUniverse su= new SimpleUniverse(cv);
    su.getViewingPlatform().setNominalViewingTransform();
    su.addBranchGraph(bg);
    private BranchGroup createSceneGraph(Canvas3D cv){
         BranchGroup root= new BranchGroup();
    TransformGroup spin= new TransformGroup();
    spin.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
    spin.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    root.addChild(spin);
    //appearance
    Appearance ap=new Appearance();
              ap.setMaterial(new Material());
              //create ten spheres
              for(int i=0;i<10;i++){
                   double x=0.1*i;
                   double y=-0.05*i;
                   //<transform sphere>
                   Transform3D tr=new Transform3D();
                   tr.setTranslation(new Vector3d(x,y,0));
                   tr.setScale(0.03);
                   //<transform sphere>
                   //<objects>
                   sphere=new Sphere();
                   sphere.setAppearance(ap);
                   TransformGroup Tg= new TransformGroup(tr);
                   Tg.addChild(sphere);
                   spin.addChild(Tg);
                   //<objects>
              //rotation
    MouseRotate rotator=new MouseRotate(spin);
    BoundingSphere bounds= new BoundingSphere();
    rotator.setSchedulingBounds(bounds);
    spin.addChild(rotator);
    //translation
    MouseTranslate translator=new MouseTranslate(spin);
    translator.setSchedulingBounds(bounds);
    spin.addChild(translator);
    //zoom
    MouseZoom zoom=new MouseZoom(spin);
    zoom.setSchedulingBounds(bounds);
    spin.addChild(zoom);
              // <picking>
              BranchGroup bg=new BranchGroup();
    spin.addChild(bg);
    pc=new PickCanvas(cv,bg);
    pc.setTolerance(5);
    pc.setMode(PickTool.GEOMETRY_INTERSECT_INFO);
    //</picking>
    // <background and light>
              BoundingSphere bound=new BoundingSphere();
              Background background=new Background(1.0f,1.0f,1.0f);
              background.setApplicationBounds(bound);
              root.addChild(background);
              AmbientLight light=new AmbientLight(true, new Color3f(Color.cyan));
              light.setInfluencingBounds(bound);
              root.addChild(light);
              PointLight ptlight=new PointLight(new Color3f(Color.green),
                        new Point3f(3f,3f,3f),new Point3f(1f,0f,0f));
              ptlight.setInfluencingBounds(bound);
              root.addChild(ptlight);
              PointLight ptlight2=new PointLight(new Color3f(Color.yellow),
                        new Point3f(3f,3f,3f),new Point3f(1f,0f,0f));
              ptlight2.setInfluencingBounds(bound);
              root.addChild(ptlight2);
         // </background and light>
    return root;
    //mouse event
    public void pick(MouseEvent mouseEvent){
    pc.setShapeLocation(mouseEvent);
    PickResult[] results= pc.pickAll();
    //when a sphere is clicked, display Node #
    for(int i=0;(results !=null) && (i<results.length);i++){
    PickIntersection inter= results.getIntersection(0);
    int[] ind=inter.getPrimitiveCoordinateIndices();
    text.setText("Node"+ind[0]);
    //When a sphere is clicked, i want to change its position
    //how to relocate the clicked sphere to position (0,0,0)?
    //(if there is a sphere already in(0,0,0),change that sphere to
    //somewhere else)
    (I import this )
    import javax.media.j3d.AmbientLight;
    import javax.media.j3d.Appearance;
    import javax.media.j3d.Background;
    import javax.media.j3d.BoundingSphere;
    import javax.media.j3d.BranchGroup;
    import javax.media.j3d.Canvas3D;
    import javax.media.j3d.Material;
    import javax.media.j3d.PointAttributes;
    import javax.media.j3d.PointLight;
    import javax.media.j3d.Shape3D;
    import javax.media.j3d.Transform3D;
    import javax.media.j3d.TransformGroup;
    import com.sun.j3d.utils.behaviors.mouse.*;
    import com.sun.j3d.utils.picking.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.media.j3d.*;
    import com.sun.j3d.utils.universe.*;
    import com.sun.j3d.utils.geometry.*;
    import java.applet.*;
    import com.sun.j3d.utils.applet.MainFrame;
    import javax.vecmath.*;

    never mind. I got it to work.

  • Preview Doesn't Display Double Spacing In Documents

    Is there a way to display double spacing in preview? It shows up when the document is viewed in Pages and Open Office.

    Hi, Guy Burns,
    What is the resolution of the images you try to enlarge?
    My guess:
    If the resolution of your images is lower then 2560 wide (your screen resolution), the window will open with the exact size and resolution of the picture (for instance 1920 wide). i.e. One pixel on your screen equals one pixel of your picture.You can indeed enlarge the window and zoom in, but then you are enlarging pixels, the image will get less sharp.
    The "Scale large images to fit window" function, is meant for "large images" as the name implies, so images with a larger resolution then your screen resolution. With this function, you can reduce the size of images that would otherwise not fit entirely on your screen, to the necessary size to view the whole picture as big as possible. So this function does not work if the "scale" is 100% or more.
    In slideshow mode however, there's a function to automatically adapt the size of smaller images to "full screen", and also "quicklook" (spacebar) supports full screen mode.

  • TS3274 words w/friends has frozen up and displays a white screen.

    words with friends froze up after a play and displays a white screen.  Other apps working ok.

    See if you can force quit the app. Double tap the home button. Flick sideways if needed to get the preview up on your screen. Flick that preview up and off the screen then single tap the home button to exit the mode. Then try your app again.

  • Flush displayed ALV and display normal posting messages on same screen

    Hi,
    I have a requirement wherein i have displayed ALV with execute button on same screen with FI data displayed in ALV.
    Now when user select one particular row and excute it , the requirement is to flush that ALV displayed and display normal
    message such as POSTING DONE
    How can i achieve it ? I am using REUSE_ALV_LIST

    What do you mean by "Now when user select one particular row and excute it "???
    Meaning you do some event like double clicking on that particular row or after selecting it, you will trigger some button?
    For 1st condition, make sure you've created an ALV event.
    If 2nd one, either you create/modify the ALV toolbar.
    Then you can do a simple call screen to exit from that ALV. Or a simple pop up message.

  • How to display double byte characters with system.out.print?

    Hi, I'm a newbie java programmer having trouble to utilize java locale with system io on dos console mode.
    Platform is winxp, jvm1.5,
    File structure is:
    C:\myProg <-root
    C:\myProg\test <-package
    C:\myProg\test\Run.java
    C:\myProg\test\MessageBundle.properties <- default properties
    C:\myProg\test\MessageBundle_zh_HK.properties <- localed properties (written in notepad and save as Unicode, window notepad contains BOM)
    inside MessageBundle.properties:
    test = Hello
    inside Message_zh_HK.properties:
    test = &#21890; //hello in big5 encoding
    run.java:
    package test;
    import java.util.*;
    public class Run{
      public static void main(String[] args){
        Locale locale = new Locale("zh","HK");
        ResourceBundle resource =
            ResourceBundle.getbundle("test.MessageBundle", locale);
        System.out.println(resource.getString("test"));
      }//main
    }//classwhen run this program, it'll kept diplay "hello" instead of the encoded character...
    then when i try run the native2ascii tool against MessageBundle_zh_HK.properties, it starts to display monster characters instead.
    Trying to figure out what I did wrong and how to display double byte characters on console.
    Thank you.
    p.s: while googling, some said dos can only can display ASCII. To demonstrate the dos console is capable of displaying double byte characters, i wrote another helloWorld in chinese using notepad with C# and compile using "csc hello.cs", sure enough, console.write in c# allowed me to display the character I was expecting. Since dos console can print double byte characters, I must be missing something important in this java program.

    after google a brunch, I learned that javac (hence java.exe) does not support BOM (byte order mark).
    I had to use a diff editor to save my text file as unicode without BOM in order for native2ascii to convert into a ascii file.
    Even the property file is in ascii format, I'm still having trouble to display those character in dos console. In fact, I just noticed I can use system.out.println to display double byte character if I embedded the character itself in java source file:
    public class Run {
         public static void main(String[] args) throws UnsupportedEncodingException{
              String msg = "&#20013;&#25991;";    //double byte character
                    try{
                    System.out.println(new String(msg.getBytes("UTF-8")) + " new string");  //this displays fine
                    catch(Exception e){}
                    Locale locale = new Locale("zh", "HK");
              ResourceBundle resource = ResourceBundle.getBundle("test.MessagesBundle", locale);
                    System.out.println(resource.getString("Hey"));      //this will display weird characterso it seems like to me that I must did something wrong in the process of creating properties file from unicode text file...

  • Hey! I don't know if my MacBook Air is frozen, but the screen is gray with the apple logo and an icon below turning round and round as if it's opening, but has been like that for a few days. I've switched it off and then on again several times, still the

    Hey
    I don't know if my mac book air is frozen, but the screen is gray with the apple logo in the middle of the gray screen, with the 'booting' icon turning round and round. I have switched it off fron both the power and power button on the computer, it goes off, when I put it on, same screen comes on again. Help Please!

    Take each of these steps that you haven't already tried. Stop when the problem is resolved.
    Step 1
    The first step in dealing with a boot failure is to secure your data. If you want to preserve the contents of the startup drive, and you don't already have at least one current backup, you must try to back up now, before you do anything else. It may or may not be possible. If you don't care about the data that has changed since your last backup, you can skip this step.   
    There are several ways to back up a Mac that is unable to boot. You need an external hard drive to hold the backup data.
         a. Boot into the Recovery partition, or from a local Time Machine backup volume (option key at startup.) When the OS X Utilities screen appears, launch Disk Utility and follow the instructions in this support article, under “Instructions for backing up to an external hard disk via Disk Utility.”
    b. If you have access to a working Mac, and both it and the non-working Mac have FireWire or Thunderbolt ports, boot the non-working Mac in target disk mode. Use the working Mac to copy the data to another drive. This technique won't work with USB, Ethernet, Wi-Fi, or Bluetooth.
    c. If the internal drive of the non-working Mac is user-replaceable, remove it and mount it in an external enclosure or drive dock. Use another Mac to copy the data.
    Step 2
    Sometimes a boot failure can be resolved by resetting the NVRAM.
    Step 3
    If you use a wireless keyboard, trackpad, or mouse, replace or recharge the batteries. The battery level shown in the Bluetooth menu item may not be accurate.
    Step 4
    If there's a built-in optical drive, a disc may be stuck in it. Follow these instructions to eject it.
    Step 5
    Press and hold the power button until the power shuts off. Disconnect all wired peripherals except those needed to boot, and remove all aftermarket expansion cards. Use a different keyboard and/or mouse, if those devices are wired. If you can boot now, one of the devices you disconnected, or a combination of them, is causing the problem. Finding out which one is a process of elimination.
    If you've booted from an external storage device, make sure that your internal boot volume is selected in the Startup Disk pane of System Preferences.
    Step 6
    Boot in safe mode. Note: If FileVault is enabled, or if a firmware password is set, or if the boot volume is a software RAID, you can’t do this. Post for further instructions.
    Safe mode is much slower to boot and run than normal, and some things won’t work at all, including wireless networking on certain Macs.
    The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin.
    When you boot in safe mode, it's normal to see a dark gray progress bar on a light gray background. If the progress bar gets stuck for more than a few minutes, or if the system shuts down automatically while the progress bar is displayed, your boot volume is corrupt and the drive is probably malfunctioning. In that case, go to Step 6.
    If you can boot and log in now, empty the Trash, and then open the Finder Info window on your boot volume ("Macintosh HD," unless you gave it a different name.) Check that you have at least 9 GB of available space, as shown in the window. If you don't, copy as many files as necessary to another volume (not another folder on the same volume) and delete the originals. Deletion isn't complete until you empty the Trash again. Do this until the available space is more than 9 GB. Then reboot as usual (i.e., not in safe mode.)
    If the boot process hangs again, the problem is likely caused by a third-party system modification that you installed. Post for further instructions.
    Step 7
    Launch Disk Utility in Recovery mode (see Step 1.) Select your startup volume, then run Repair Disk. If any problems are found, repeat until clear. If Disk Utility reports that the volume can't be repaired, the drive has malfunctioned and should be replaced. You might choose to tolerate one such malfunction in the life of the drive. In that case, erase the volume and restore from a backup. If the same thing ever happens again, replace the drive immediately.
    This is one of the rare situations in which you should also run Repair Permissions, ignoring the false warnings it may produce. Look for the line "Permissions repair complete" at the end of the output. Then reboot as usual.
    Step 8
    Reinstall the OS. If your Mac was upgraded from an older version of OS X, you’ll need the Apple ID and password you used to upgrade.
    Step 9
    Repeat Step 6, but this time erase the boot volume in Disk Utility before installing. The system should automatically reboot into the Setup Assistant. Follow the prompts to transfer your data from a Time Machine or other backup.
    Step 10
    This step applies only to older Macs (not current models) that have a logic-board ("PRAM") battery. Both desktop and portable Macs used to have such a battery. The logic-board battery, if there is one, is separate from the main battery of a portable. A dead logic-board battery can cause a boot failure. Typically the failure will be preceded by loss of the settings for the startup disk and system clock. See the user manual for replacement instructions. You may have to take the machine to a service provider to have the battery replaced.
    Step 11
    If you get this far, you're probably dealing with a hardware fault. Make a "Genius" appointment at an Apple Store, or go to another authorized service provider.

  • Having trouble with rounding and if/else

    I am trying to write a program that reads 2 floating-point numbers and test if they're the same when rounded to 2 decimal places and whether they diff by less than 0.01. I'm having trouble compiling it, with errors such as
    "C:\Documents and Settings\John\My Documents\Test2.java:24: 'else' without 'if' else"
    C:\Documents and Settings\John\My Documents\Test2.java:18: cannot find symbol
    symbol  : method round(double,int)
    location: class java.lang.Math
         double round1 = Math.round(firstinput,2);
                             ^
    C:\Documents and Settings\John\My Documents\Test2.java:19: cannot find symbol
    symbol  : method round(double,int)
    location: class java.lang.Math
         double round2 = Math.round(secondinput,2);Here is the code:
    import java.util.Scanner;
    import java.text.NumberFormat;
    import java.math.*;
    import java.lang.Math;
    public class Test2
         public static void main( String args[] )
         Scanner sc = new Scanner( System.in);
         System.out.println("Enter your first floating-point number: ");
         double firstinput = sc.nextDouble();
         System.out.println("Enter your second floating-point number: ");
         double secondinput = sc.nextDouble();
         double round1 = Math.round(firstinput,2);
         double round2 = Math.round(secondinput,2);
         double total = round1 - round2;
        if(round1 == round2);
        System.out.print("They are the same when rounded to two decimal places. \n");
        else
        System.out.print("They are not the same when rounded to two decimal places. \n");
         if(total<1.01 && total>0.99)
         System.out.print("They differ by less than 0.01. \n");
         else
         System.out.print("They do not differ by less than 0.01. \n");
    }

    Are you restricted to Math.round()? Try reading about DecimalFormat:
    http://java.sun.com/j2se/1.4.2/docs/api/java/text/DecimalFormat.html
    Your code with DecimalFormat:
    import java.text.DecimalFormat;
    import java.util.Scanner;
    public class Test2 {
        public static void main(String[] args) {
            DecimalFormat df = new DecimalFormat("#.##");
            Scanner sc = new Scanner( System.in);
            System.out.println("Enter your first floating-point number: ");
            double firstinput = sc.nextDouble();
            System.out.println("Enter your second floating-point number: ");
            double secondinput = sc.nextDouble();
            double round1 = Double.parseDouble(df.format(firstinput));
            double round2 = Double.parseDouble(df.format(secondinput));
            double total = round1 - round2;
            if(round1 == round2)
                System.out.print("They are the same when rounded to two decimal places. \n");
            else {
                System.out.print("They are not the same when rounded to two decimal places. \n");
                if(total<1.01 && total>0.99) //<== Rather redundant, why not just use total == 1
                    System.out.print("They differ by less than 0.01. \n"); //<== From the above if statement, it seems if you are looking to see if the 2 numbers differ by less than 1.00, and not 0.01. The same goes for the else statement below
                else
                    System.out.print("They do not differ by less than 0.01. \n");
    }Also, when I ran your program with the latter code and entered two same floating point numbers, it also printed out "They do not differ by less than 0.01." I've added curly brackets around the outer else statement to ensure that it does not happen. It's best to use curly brackets in structured statements if their function exceeds more than one line; for stability and legibility.
    Also, read my comments.

  • Launchpad Displays Doubles & Triples

    Launchpad displays doubles & triples of most applications. How do I fix this?

    Launchpad will display an icon for each copy of an application that is currently installed (as well as any aliases to those applications), so you will see more than one icon for an application if you have more than one version of the application installed or aliased.
    Prior to installing OS X Lion, if you moved installed applications into sub-folders inside of /Applications, OS X Lion installs the current versions of those applications in /Applications, and leaves the earlier versions of the applications that you moved.
    Taken from:
    http://support.apple.com/kb/HT4836
    Regards,
    Colin R.

  • Help, how to open and display blobs from tables

    Dear all,
    I am trying to store ms-word files on a table using a blob column.
    Does anyone how to open the files and display them from a form using 9iAS?
    Thank you.
    Carlos.

    And there may be, but you won't likely find that here. Do some time searching Google and maybe you'll find code that someone was nice enough to make freely available, although I wouldn't count on it. Were i a programmer and took the time to read those docs and write the code, I'd want to be paid for my time. But there are a lot of programmers who swear by freeware! You may get lucky.

  • Open and display image in MVC layout

    Hello!
    I cant figure out how I shall do this in an MVC layout:
    The program request user to open an image file that are then displayed in a JLabel
    My setup at the moment resolve in a nullpointerexeption because it dont get any actual image file, but I dont understand what I have missed.
    I can not post the whole code fo you to run because it is to big, so I post the part that are the most important. please have a look.
    PicturePanel
    //Import Java library
    import javax.swing.*;
    import java.awt.*;
    public class PicturePanel extends JPanel {
         //Variables
         private ImageIcon picture;
         //Method to get information of the selected file
         PicturePanel (String fileName) {
              picture = new ImageIcon (fileName); //Get the filename
              int w = picture.getIconWidth(); //Get the image with
              int h = picture.getIconHeight(); //Get the image height
              //Set preferable size for the image (Use the properties for the selected image)
              setPreferredSize(new Dimension(w, h));
              setMinimumSize(new Dimension(w, h));
              setMaximumSize(new Dimension(w, h));
         //Method to draw the selected image
         protected void paintComponent(Graphics g) {
              super.paintComponent(g); //We invoke super in order to: Paint the background, do custom painting.
              g.drawImage(picture.getImage(), 0, 0, this); //Draw the image at its natural state
    }From my model:
    //Local attributes
         boolean check = false; //Used to see if a statement is true or not
         PicturePanel pp;
         JFileChooser fc;
         int returnVal;
    //newFile in File menu
         public void newFile() {
              //Open a file dialog in users home catalog
              fc = new JFileChooser();
              //In response to a button click:
              returnVal = fc.showOpenDialog(pp);
              System.out.println("You pressed new in file menu");
         }From my controler:
    //User press "New" in File menu
              else if (user_action.equals("New")) {
                   //Call method in model class
                   model.newFile();
                   //Update changes
                   if (model.returnVal == JFileChooser.APPROVE_OPTION) {
                        System.out.println("Hello1");
                        File f = model.fc.getSelectedFile();
                        if (model.pp != null)     
                             model.pp = new PicturePanel(f.getAbsolutePath());
                        System.out.println("Hello2");
                        //Display image (Here is line 83)
                        view.setImage_DisplayArea(model.pp);
                        System.out.println("Hello3");
              }From my view:
    //Sets the image to be displayed on the image_display area (Here is line 302)
         public void setImage_DisplayArea(PicturePanel pp) {
              image_display.add(pp);
         }The complet error:
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
         at java.awt.Container.addImpl(Container.java:1015)You pressed new in file menu
    Hello1
    Hello2
         at java.awt.Container.add(Container.java:351)
         at View_Inlupp2.setImage_DisplayArea(View_Inlupp2.java:302)
         at Control_Inlupp2.actionPerformed(Control_Inlupp2.java:83)
         at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1882)
         at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2202)
         at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
         at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
         at javax.swing.AbstractButton.doClick(AbstractButton.java:334)
         at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1050)
         at apple.laf.CUIAquaMenuItem.doClick(CUIAquaMenuItem.java:119)
         at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1091)
         at java.awt.Component.processMouseEvent(Component.java:5602)
         at javax.swing.JComponent.processMouseEvent(JComponent.java:3129)
         at java.awt.Component.processEvent(Component.java:5367)
         at java.awt.Container.processEvent(Container.java:2010)
         at java.awt.Component.dispatchEventImpl(Component.java:4068)
         at java.awt.Container.dispatchEventImpl(Container.java:2068)
         at java.awt.Component.dispatchEvent(Component.java:3903)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4256)
         at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3936)
         at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3866)
         at java.awt.Container.dispatchEventImpl(Container.java:2054)
         at java.awt.Window.dispatchEventImpl(Window.java:1801)
         at java.awt.Component.dispatchEvent(Component.java:3903)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)Edited by: onslow77 on Dec 16, 2009 5:00 PM
    Edited by: onslow77 on Dec 16, 2009 5:04 PM

    Hello again!
    Anyone that can help me figure out how to implement this in an MVC layout, I feel stuck.
    I post a little program that open and display an image file so that you better can understand what I whant to do.
    ShowImage
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.File;
    import javax.swing.filechooser.*;
    public class ShowImage extends JFrame{
         //Variables
         JFileChooser fc = new JFileChooser();
         PicturePanel pp = null;
         ShowImage () {
              super("Show"); //Title
              //Create the GUI
              JPanel top = new JPanel();
              add(top, BorderLayout.NORTH);
              JButton openBtn = new JButton("Open");
              top.add(openBtn);
              openBtn.addActionListener(new Listner());
              //Settings for the GUI
              setDefaultCloseOperation(EXIT_ON_CLOSE);
              pack();
              setVisible(true);
         class Listner implements ActionListener {
              public void actionPerformed(ActionEvent ave) {
                   int answer = fc.showOpenDialog(ShowImage.this);
                   if (answer == JFileChooser.APPROVE_OPTION){
                        File f = fc.getSelectedFile();
                        //Check
                        System.out.println(f);
                        System.out.println(pp);
                        if (pp != null)
                             remove(pp); //Clean so that we can open another image
                        //Check
                        System.out.println(pp);
                        //Set the PicturePanel
                        pp = new PicturePanel(f.getAbsolutePath());
                        //Check
                        System.out.println(pp);
                        //Add PicturePanel to frame
                        add(pp, BorderLayout.CENTER);
                        validate();
                        pack();
                        repaint();
         //Main
         public static void main(String[] args) {
              new ShowImage();
    }PicturePanel
    //Import Java library
    import javax.swing.*;
    import java.awt.*;
    public class PicturePanel extends JPanel {
         //Variables
         private ImageIcon picture;
         //Method to get information of the selected file
         PicturePanel (String fileName) {
              picture = new ImageIcon (fileName); //Get the filename
              int w = picture.getIconWidth(); //Get the image with
              int h = picture.getIconHeight(); //Get the image height
              //Set preferable size for the image (Use the properties for the selected image)
              setPreferredSize(new Dimension(w, h));
              setMinimumSize(new Dimension(w, h));
              setMaximumSize(new Dimension(w, h));
         //Method to draw the selected image
         protected void paintComponent(Graphics g) {
              super.paintComponent(g); //We invoke super in order to: Paint the background, do custom painting.
              g.drawImage(picture.getImage(), 0, 0, this); //Draw the image at its natural state
    }//The endEdited by: onslow77 on Dec 16, 2009 7:30 PM

Maybe you are looking for

  • Database table update issue

    Hello experts, Need your Help... I am trying to update database table using Update command. And I am doing COMMIT WORK AND WAIT. after the successful update. But my code sometimes does not work and the table is not updated. Sometimes the code works a

  • Importing the METADATA ONLY using DBMS_DATAPUMP

    Hi DBAs, Using the DBMS_DATAPUMP , how can I import the metadata only for a particular table . Also I dont want to import any associated INDEXES and TRIGGERS. I have the following codes but it is trying to import every thing. Also if the table exist,

  • About mapping-input-parameter operator !

    hi all: There is a problem, I deploy a mapping,the mapping have a mapping input parameter, the mapping is runing a time every day£¬and every day's parameter is different. I want to mapping input parameter of the mapping can auto get a value from some

  • Hp probook 4520s model web cam drivers are not instaling

    i am using windows 8.1 64bit os. i was download webcam drivers from hp support site, but that software are not instaling. please help me my email: [email protected]

  • If I bought Photoshop for my PC, how do I transfer the license to my Mac?

    I just bought a new Macbook Air, but when I purchased Photoshop, it was for my PC.  Is there a way to load this onto my Mac without purchasing again? Sarah