Neon Tetras 24 Newbie Poster

Thanks a lot. it worked like magic. its good cos I don't have to pay extra money for a database

Neon Tetras 24 Newbie Poster

My web hosting plan does not include a database. Is there a way i can get around this? Like upload a .sql file or ms access db into my server and connect to it using php?

Neon Tetras 24 Newbie Poster

I want to execute WordPad using the code below.
It runs fine on my pc. But failed to run on other pcs.

String program = "C:\\Program Files\\Windows NT\\Accessories\\wordpad";
String file = "srcFiles\\Resources\\readme.rtf"; //This is the path to the file i want to open with wordpad.
Runtime  load = Runtime.getRuntime();;
try{
 load.exec(program + " " + file);
 }catch(java.io.IOException ioe){
 System.out.println(ioe.getMessage());
 }

Please what am i getting wrong?

Neon Tetras 24 Newbie Poster

i started this project using netbeans. that is why i had these fully qualified names

Neon Tetras 24 Newbie Poster

Hi guys.
I decided to post this simple Photo viewer application.
Its strictly for beginners, and cab be improved.

    /**
     *
     * @author Neon Tetras
     */
    import java.awt.Image;
    import java.io.File;
    import java.io.IOException;
    import javax.imageio.ImageIO;
    import javax.swing.ImageIcon;

    public class ImageViewer extends javax.swing.JFrame {

        /**
         * Class constructor: ImageViewer
         */
        public ImageViewer() {
            initComponents();

            listFiles(Path);    //Lists all the files in the directory on window opening

            setLabelIcon(Path,filenames[position]); //sets the label to display the first
                                                    //image in the directory on window opening.
            PreviousButton.setEnabled(false);
        }
        /**
         *Initialize components
         */
        private void initComponents() {
            setTitle("Image Viewer");
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            setLayout(new java.awt.BorderLayout());// The layout is BorderLayout
            //setBorder(javax.swing.BorderFactory.createEtchedBorder());
            setBackground(java.awt.Color.GRAY);

            picLabel = new javax.swing.JLabel();        //Create the Label to display the picture
            picLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
            picLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

            PreviousButton = new javax.swing.JButton();
            PreviousButton.setText("Previous");
            PreviousButton.setIconTextGap(10); //Distance between the icon and text is 10

            PreviousButton.addActionListener(new java.awt.event.ActionListener() { //Register an actionListener for the PreviousButton
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    PreviousButtonActionPerformed(evt);
                }
            });

            NextButton = new javax.swing.JButton();
            NextButton.setPreferredSize(PreviousButton.getPreferredSize());
            NextButton.setText("Next");
            NextButton.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
            NextButton.setIconTextGap(10); //Distance between the icon and text is 10

            NextButton.addActionListener(new java.awt.event.ActionListener() {  //Registers an actionListener for the NextButton
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    NextButtonActionPerformed(evt);
                }
            });

            javax.swing.Box vbox = javax.swing.Box.createVerticalBox(); //VerticalBox to hold the pictureLabel and the buttons

            vbox.add(javax.swing.Box.createVerticalStrut(30));
            vbox.add(picLabel);
            vbox.add(javax.swing.Box.createVerticalStrut(50));

            javax.swing.JPanel prev_next_pane = new javax.swing.JPanel(); //Panel to hold the Previous and Next buttons.

            java.awt.FlowLayout flow = new java.awt.FlowLayout(java.awt.FlowLayout.CENTER);
            flow.setHgap(30);
            prev_next_pane.setLayout(flow);

            prev_next_pane.add(PreviousButton);
            prev_next_pane.add(NextButton);
            prev_next_pane.setOpaque(false);

            vbox.add(prev_next_pane); //Add the panel to the verticalBox
            add(vbox);

        java.awt.Toolkit theKit = getToolkit();
        java.awt.Dimension size = theKit.getScreenSize();

        setLocation(size.width/5,size.height/10);
        setMinimumSize(new java.awt.Dimension(900,600));
        //setMaximumSize(new Dimension(size.width/4 +  50,size.height/4));

          //pack();
        }//END:initComponents

        /**
         *Handler for previous button
         */
        private …
JamesCherrill commented: Good example of Java perogramming. Well done +15
Begginnerdev commented: Nice post! +9
Neon Tetras 24 Newbie Poster

no its not.
its a personal project

Neon Tetras 24 Newbie Poster

so how can i do this?

Neon Tetras 24 Newbie Poster

I created several JComboBoxes using a for loop. I want them to reset when i click the reset button.
But this doesn't work.

These are my codes...

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.ItemListener;
import java.awt.event.ItemEvent;

class TryCombo extends JFrame{
 TryCombo(){
 super("Trying JComboBox");
 setDefaultCloseOperation(EXIT_ON_CLOSE);

  JButton but = new JButton("reset");
  but.addActionListener(new ActionListener(){
  public void actionPerformed(ActionEvent e){
  ComboBox myCombos = new ComboBox();
  myCombos.setSelectedItem("Grades");
  }});

  JPanel pane = new JPanel();
    pane.setLayout(new GridLayout(2,3));
  for(int i = 1; i<=6; i++){
  pane.add(new ComboBox());
  }

  add(pane,BorderLayout.CENTER);
  add(but,BorderLayout.SOUTH);
  pack();
  setVisible(true);
 }

 class ComboBox extends JComboBox implements ItemListener{
 ComboBox(){
 final String[] Grades = {"Grades","A","A-","B+","B","B-","C+","C","C-","D","F"};   
 for(String grades : Grades){
        addItem(grades);
        }
  addItemListener(this);
  }

  public void itemStateChanged(ItemEvent e){
  Object item = getSelectedItem();
 System.out.println(item);
 }

 }
 public static void main(String[] args){
 new TryCombo();
 }
 }
Neon Tetras 24 Newbie Poster

I want to uninstall Microsoft SQL Server 2008 R2.
But i get this error message whenever i try doing that....

TITLE: SQL Server Setup failure.

SQL Server Setup has encountered the following error:

The given key was not present in the dictionary..

------------------------------
BUTTONS:

OK

Can someone help me out here?

Its really giving me sleepless nights..

Neon Tetras 24 Newbie Poster

Thanks JamesCherrill. Your reply has really helped.

Neon Tetras 24 Newbie Poster

@AHarrisGsy... Yes i do.

Neon Tetras 24 Newbie Poster

Thanks, i'm sure you'd help

Neon Tetras 24 Newbie Poster

I'm a rookie in Java. I'm sure with you all, i'd become a Legend.
Peace..

Neon Tetras 24 Newbie Poster

I'm working on a Grade Point Average Calculator.

The user just have to Select the number of courses offered, then select the grade obtain in the different courses by choosing the appropriate grade from the Choice Box.

The problem with my application is that, if the user mistakenly selects "A" instead of "B", then he corrects his mistake by selecting "B", the program sums up all the selections, including the wrong selection. So the calculation ends up being wrong.

Another proble with my application is that, u can't select an item twice. i.e if a user, selects "A" in the first Choice box, he can't select "A" again in the same Choice box, in case he wants to do another calculation.

This is the source code for the gradeChoice class.....

import java.awt.*;

import java.awt.event.ItemListener;
import java.awt.event.ItemEvent;

import javax.swing.*;
/*
 *
 *@author Anokam Kingsley
 */

    GradeChoice(){
        super();

            final String[] Grades = {"Grades","A","A-","B+","B","B-","C+","C","C-","D","F"};

            for(String grades : Grades){
                add(grades);
                }

            addItemListener(new ItemListener(){

                             public void itemStateChanged(ItemEvent e){

                                    String gradeString = getSelectedItem();
                                     switch(gradeString){
                                     case "A" :
                                     gradeMark = 4.00;
                                     break;
                                     case "A-":
                                     gradeMark = 3.67;
                                     break;
                                     case "B+":
                                     gradeMark = 3.34;
                                     break;
                                     case "B":
                                     gradeMark = 3.00;
                                     break;
                                     case "B-":
                                     gradeMark = 2.67;
                                     break;
                                     case "C+":
                                      gradeMark = 2.34;
                                     break;
                                     case "C":
                                      gradeMark = 2.00;
                                     break;
                                     case "C-": 
                                      gradeMark = 1.67;
                                     break;
                                     case "D":
                                      gradeMark = 1.00;
                                     break;
                                     case "F":
                                      gradeMark = 0.00;
                                     break;
                                     default:
                                     System.out.println("Error!!");                         
                                     } 

                                    Scores += gradeMark;

                                }}); //End of addItemListener

                         }//End of GradeChoice constructor

                                 static double gradeMark,Scores;;

    }// End of …