peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

This works fine.

import java.io.File;
import java.io.IOException;

/**
 * Delete a file from within Java
 * 
 * @author Ian F. Darwin, http://www.darwinsys.com/
 * @version $Id: Delete.java,v 1.5 2004/02/09 03:33:47 ian Exp $
 */
public class Delete {
  public static void main(String[] argv) throws IOException {

    // Construct a File object for the backup created by editing
    // this source file. The file probably already exists.
    // My editor creates backups by putting ~ at the end of the name.
    File bkup = new File("C:\\test.txt");
    // Quick, now, delete it immediately:
    bkup.delete();
  }
}

Is there anything else you do with the file before deleting? Like using for temporary writing?

PhiberOptik commented: Lots of help thanks! +1
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

I have two questions ( these may be very simple, but I'm concentrating on different things so I need somebody push me in right direction as not to waste time, bold said but that is reality)

  1. Passing object from top component to lower ones
    I have GUI where after successful login main frame keeps hold of user unique ID and pass it down to lower components by the use of constructor. It is very inefficient as the frame holds an panel in which I'm displaying different panels that are often combinations of other panels. So this unique ID is passed down by 1-2 class constructors that do not have any use of it. How can I access variable in the frame from a component 2-3 levels bellow?
  2. Lower component passing data to higher.
    You may say little reverse situation to previous question. Let say that from the frame menu I selected to "view clients" and these are displayed in the panel hold directly by frame. I collect data from DB initialize the "view clients" panel and this displayed in the frame's panel.
    JMenuItem jmiAllClients = new JMenuItem("View Clients", KeyEvent.VK_C);
    jmiAllClients.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.ALT_DOWN_MASK));
    jmiAllClients.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
              mainPanel.removeAll();
              ViewClientsPanel viewCP = new ViewClientsPanel();
              mainPanel.add(viewCP);
              validate();
              repaint();
          }
      });

    VievClientsPanel is a panel with table in, direct table editing is disabled. However if you select a column in a table edit button become enabled and once you hit it full set of selected client data are fill …

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

This is closely associated with development technology that you use (PHP/JSP/any form of ASP). For example in JSP when my page get processed with server side (servlet), I will make use of mail library, beside logging/storing submitted data I attach a method that will trigger mailing process with what ever data I want/need.
So depending on whatever you use you should post in one of the Web Development section.

PS: Dreamweaver is only a tool which can be replaced by many others, so no point to mention it. It is more useful to designers then developers that would pick up something else (Eclipse, NetBeans, Visual Studio, Zend etc.)

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

LOL, these are because of code formatting if I use [code]

[/code] you will get this view

String kn = getKeyName(kc);
if (kn == null) kn = "";
// AND
g.drawString("Key name: " + kn, w / 2, y,
                Graphics.HCENTER | Graphics.BOTTOM);
y += fh;

however if I add language declaration as [code=Java] [/code] you will get you number list

String kn = getKeyName(kc);
if (kn == null) kn = "";
// AND
g.drawString("Key name: " + kn, w / 2, y,
                Graphics.HCENTER | Graphics.BOTTOM);
y += fh;

So when ever you copy code that been formated with code tags you should click (Toggle Plain Text) which will get you text area from which you can easily copy code and no number lines will be included

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

There is no such thing as Number list, provided code uses information already included in API and only game buttons have extra detection to show what game actions are associated with them and print these in string format.
So if you want to capture only game actions you need to exclude

String kn = getKeyName(kc);
if (kn == null) kn = "";
// AND
g.drawString("Key name: " + kn, w / 2, y,
                Graphics.HCENTER | Graphics.BOTTOM);
y += fh;

Did that answer your question?

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

These methods are setter and getter as they help you initialize and retrieve value from an Object to which they are related to, hence the prefix of each method

private void setQuestion(String str){ question = str;}
public String getQuestion(){ return question;}

depending on project requirement you will make setter private or public, where getter is usually public.

In original code there is call for initializeTest() method that looks like this

private void initializeTest()
    {
    	test[0] = new Test("Question 1 to ask", "I like A", "I like B", "I like C", "I like B");
    	test[1] = new Test("Question 2 to ask", "I like A", "I like B", "I like C", "I like A");
    	test[2] = new Test("Question 3 to ask", "I like A", "I like B", "I like C", "I like C");
    }

in this method with every call for new Test a new object of type Test is created and because arguments been provided newly created object is automatically initialized with these arguments. The initialization take place in the constructors like in our case in this one

public Test(String quest, String oA, String oB, String oC, String ans)
	{
		setQuestion(quest);
		setOptionA(oA);
		setOptionB(oB);
		setOptionC(oC);
		setAnswer(ans);
	}

where with the help of setter methods we initialize every variable of the Test object. If the setter method would be public instead of private we could do something like this

test[0] = new Test();
test[0].setQuestion("Question 1 to ask");
test[0].setOptionA("I like A");
test[0].setOptionB("I like B");
test[0].setOptionB("I like B");
test[0].setAnswer("I like …
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

I use http://hostsyst.com/en/, provider is OK if you looking for some start. However I got no control over server restart to see any errors from there and have to way for guy to tell me if something went wrong (I'm on windows, he on some *nix, good recipient for trouble)
I found few others, but as I do not know anyone using them so I can not give direct recommendation
http://www.itanets.co.uk/
http://www.eukhost.com/
http://javaprovider.net/

PS: Warning for any hosting providers. You are welcome to post links, but without your sales promotions such as "best hosting" or "cheapest hosting" etc. Please keep that sort of promotion for your site, plain link will do just fine

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster
  1. Read/write file
  2. Database access JDBC
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

I'm gone send you PM in a minute, don't want to do free advertising here

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Here of course...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

so, how am i gonna run that sort of code, with out the Number list?

Please explain yourself this doesn't make sense to me.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

As I mention previously you would do best if you keep mobile content in sub-domain (if your domain is for example seetha.com you should get sub-domain like mobile.seetha.com or wap.seetha.com DO NOT FORGET TO SPEAK WITH YOUR HOSTING PROVIDER SO YOU KNOW THEIR POLICY ON THIS). So once the script recognise incoming request it will directed user to seetha.com/home.asp or mobile.seetha.com/home.wml respectively. From this point onward documents in desktop domain are linked between each other, but there is no cross linking with mobile domain

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Few tips PhiberOptik, try to locate some Java User Group (JUG or JAVAWUG), Java meet up in your area or if you by any chance cellege/university student there is Open Source University Meetup (OSUM) web group for students. These groups do lots of free events

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

This is new area in mobile development and not so well know. You will need to do lot of search, if you university student check if your school have subscription with ACM portal, IEEE and similar, then with use of http://scholar.google.co.uk/ you may start search for academic materials and these are full of references which may lead you to industry reaserch

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

You need to reveal more of your current implementation or we will not able to help you ( some supporting code would more then welcome...)

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Get (WURFL it needs PHP) or create browser/device detection algorithm and based upon this you can re-direct devices to your sub-domain specially designed for mobile devices

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

OK then ( Just small warning, what you did by creating another post in different sections is something we do not like to see - please refer to forum rules 5th paragraph of Keep It Organized in regards of forum flooding. So in the future if this happens please click on the "Flag Bad Post" and type short message like "Please move it to JavaScript section")
If you can please close this post/mark as solved so as other do not get "cute" ideas

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Here is a better example. This example will show you how you can monitor button presses and what sort of information you can get out of it. KeyCanvas class is taken from Jonathan Knudsen book Kicking Butt with MIDP and MSA, chapter 9.13
MIDLET: ButtonEvents.java

package buttonEvents;

/**
 * Created by IntelliJ IDEA.
 * User: Peter
 * Date: 23-Dec-2008
 * Time: 11:18:42
 */

import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;

public class ButtonEvents extends MIDlet implements CommandListener {
    private Canvas mCanvas;
    private Command mOKCommand;

    public void startApp() {
        Display display = Display.getDisplay(this);
        if (mCanvas == null) {
            mCanvas = new KeyCanvas();
            mOKCommand = new Command("OK", Command.OK, 0);
            mCanvas.addCommand(mOKCommand);
            mCanvas.setCommandListener(this);
        }
        display.setCurrent(mCanvas);
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }

    public void commandAction(Command c, Displayable d) {
        if (c == mOKCommand) {
            destroyApp(true);
            notifyDestroyed();
        }
    }
}

CANVAS: KeyCanvas.java

package buttonEvents;

/**
 * Created by IntelliJ IDEA.
 * User: Peter
 * Date: 23-Dec-2008
 * Time: 11:20:15
 */

import javax.microedition.lcdui.*;

public class KeyCanvas extends Canvas {
    private String mMessage = "Press any key!";
    private int mKeyCode;

    public void paint(Graphics g) {
        int w = getWidth();
        int h = getHeight();
        g.setColor(0xffffff);
        g.fillRect(0, 0, w, h);
        int fh = g.getFont().getHeight();
        int y = h / 2 - fh * 2;
        int kc = mKeyCode;
        g.setColor(0x000000);
        g.drawString(mMessage, w / 2, y,
                Graphics.HCENTER | Graphics.BOTTOM);
        y += fh;
        if (kc != 0) {
            String kn = getKeyName(kc);
            if (kn == null) kn = "";
            int ga = getGameAction(kc);
            String gn = getGameActionName(ga);
            g.drawString("Key code: …
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

You see this constructor

public clsCanvas(midMain m)

it is expecting some argument to be passed down from previous MIDlet, Canvas or Form
plus you calling

fParent.destroyApp(false);

that is always implemented in MIDlet, also you missing two closing bracklets on the end of code which you provided (see your post with the code).

So no, this will not compile and therefore it will not run.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Sorry this class is not completed and you missing MIDlet, what you want me to do with that?

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Nope there is no direct way as in general there are 3 types of mobile devices

  • without capability of internet access (old phones)
  • internet access, but no internet browser just simple parser (most of current phones)
  • internet access and mobile internet browser ( number of Windows CE based phones, some Symbian, Blackberry, HTC, iPhone etc. )

First group is out of loop as there is no internet
Second group will require simplified version of your web site based on WAP
Last group will be happy browsing normal page

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Either use code tags to make it part of post [code] YOUR CODE HERE [/code] or use advance posting option ( press "Go Advanced" button) and bellow post editing area you will find Manage Attachments button which will allows you to upload code (*.java) or compressed source files (*.zip)

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

i want to include next page option in my web application

This doesn't make too much sense, please elaborate on what you want to do.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Are you sure that you asking your question in correct forum section? You talking about JavaScript in Java forum section. Just in case you do not know Java is not same as JavaScript

PS: You will need to elaborate your question it does not really make too much sense.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

If you provide code and stack trace for errors there are many that may help you...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

You have mistake here, missing 2 x back slash

con = DriverManager.getConnection("jdbc:mysql://##.###.###.##:3306/dbName",
        "USERNAME", "PASSWORD");
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Josh also make sure that your database server is capable of external access, MySQL is often installed as local and cannot be accessed from outside world

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Two comments
1) You may want to get latest Connector/J 5.1
2) Adding something to JDK or JRE installation is not the best thing to do and untidy, what if you update/reinstall Java. Better to keep separated folder with JAR files you often use and through your IDE to either link whole folder to general settings or just link up wanted JAR with your current project

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

rude04 as Ezzaral suggested here, Acrobat Viewer bean will be the easiest solution based on your knowledge of Java

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Test class as suggested

public class Test
{
	private String question;
	private String optionA;
	private String optionB;
	private String optionC;
	private String answer;
	
	public Test(){}
	
	public Test(String quest, String oA, String oB, String oC, String ans)
	{
		setQuestion(quest);
		setOptionA(oA);
		setOptionB(oB);
		setOptionC(oC);
		setAnswer(ans);
	}
	
	private void setQuestion(String str){ question = str;}
	public String getQuestion(){ return question;}
	
	private void setOptionA(String str){ optionA = str;}
	public String getOptionA(){ return optionA;}
	
	private void setOptionB(String str){ optionB = str;}
	public String getOptionB(){ return optionB;}
	
	private void setOptionC(String str){ optionC = str;}
	public String getOptionC(){ return optionC;}
	
	private void setAnswer(String str){ answer = str;}
	public String getAnswer(){ return answer;}
}

Your re-done code, I made change to name( class name starts with capital letter any every other word in the name should start with capital too hence new class name SwingQuestionnaire) and also renamed some variables as to make it easier to work with it. Original names jcomp1 - jcomp6 are meaningless and difficult to remember which one is what

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;

public class SwingQuestionnaire extends JPanel implements ActionListener{
    private JLabel titleLabel;
    private JLabel questionNumLabel;
    private JButton nextButton;
    private JLabel questionLabel;
    private JRadioButton jrbA;
    private JRadioButton jrbB;
    private JRadioButton jrbC;
    private int score;
    private int qNum = 0;
    private Test[] test = new Test[3];


    public SwingQuestionnaire() {
        //construct components
        JSeparator line1 = new JSeparator (JSeparator.HORIZONTAL);
        ButtonGroup group = new ButtonGroup();
        //int score;
        initializeTest();
        titleLabel = new JLabel ();
        questionNumLabel = new JLabel();
        
        questionLabel = new JLabel ();
        jrbA …
Ezzaral commented: Nice example. +16
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

The questions and the answers will be hard coded or read from file or database?

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Lets make bargain.
You give me code what you have plus maybe how it should approached and I will try to improve it with you.
Do we have deal?

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Hey where is Poken, Digimon and Dragon Ball ;) (just joking)
Are there any sites with English version? ( I tried to learn Japanese, while studying Karate, but then I went for Taekwon-Do :D )

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

It is not such a difficult task.
Create a constructor something like this

Test(String question, String answerA, String answerB, String answerC, String correctAnswer)

Fill in data and put it in Array/ArrayList/Vector (something you familiar with).
Your frame view can be split into three panels CountPanel (showing current position or question taken in the test), QuestionPanel (build of label with question and check boxes in CheckboxGroup)and ButtonPanel (with button) on the first view you will show first data set for question one.
Now you have come up with simple logic that will on button press swap data in in the label and checkbox group of your QuestionPanel with new set, plus it will increment the count

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Ping cannot be accessed directly you can use Runtime to execute console ping command and read it in, but this is awkward solution

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

You can have look on java.net package, but there is not too much to it

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Post moved to JavaScript, because of poster confusion with JSP - Java Server Pages

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

http://java.sun.com/docs/books/tutorial/

You should seriously check out Starting "Java" sticky post so you do not double post ;)

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

I need Java Script function for search data(text) inside a html table. not a my sql table. (table size is fixed)

Make up you mind what technology you want to use and do not forget to support your claim by existing coding you already did as this is no 24/7 service "give me code"!

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Upload it on the server,buy web hosting package, use company server if available or make your pc a hosting server

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Here is "little dirty" solution

import java.util.*;
import javax.swing.JOptionPane;
public class RandomNumber
{	
	public static void main(String[] args) 
	{
	
		String output="";
		int[] arrayRan=new int[6];
		int rand;
		for(int i=0;i<arrayRan.length;i++)
		{
			do //execute following line
			{
				rand =(int)(Math.random()*48)+1;
			}while(doesExists(rand, arrayRan, i)); //while return is true
			arrayRan[i] = rand;
		}
		Arrays.sort(arrayRan);
		for(int i=0;i<arrayRan.length;i++)
		{
			System.out.println(arrayRan[i]);
		}
				
	}
	
	private static boolean doesExists(int rand, int[] arr, int i)
	{
		if( i != 0)
		{
			for(int j = 0; j < i; j++)
			{
				if(rand == arr[j])
					return true;	// number already in the array
			}			
		}
		return false;
	}
}

If you have any questions just ask

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

One possibility, however it may not work well with less know browsers

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

There is no install, you just upload CSS file to your web server and tell the HTML/XHTML/PHP or what ever format you gone use that it should use this layout, plus in the document you tell tags which settings to use. For example <table class="bordless"....> . If image is used as background or in some decoration, find it CSS and change the path of the image for the path to your image

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

@ccube921 - that will not work, at least not properly as there are very few mobile phones with mobile browsers.

OlyComputers if you want to have redirection then use WURFL that can be simple deployed on Apache server with PHP support. However there is a cost to this solution as WURFL is based on one huge XML (some 6MB) so there is a delay between connection and recognition-redirection some 6-10sec

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Separate tables, it will make your life easier for the tracking purposes, also if you really want you can extend this beyond two tables...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Simple query such as

select * from TABLE_NAME:

will retrieve data. I think you doing something somewhere along the way. Would you mind to post your code?

PS: Please use code tags to keep your code formatted [code] YOUR CODE HERE [/code]

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

@k2k - when you buying web hosting the package says what it contains. These days only very basic and cheapest options do not include database in their offer. If you got one of these, then I have to say that unfortunately you made mistake as buying database server on its own will cost you more as to get hosting with DB included. Try to speak with your hosting provider about possible upgrade of your package, I'm sure they will happy to do for you.

If the package which you have contains DB, then just look up login details from the hosting administrator and get working on your database.

As to your question about installation of phpMyAdmin, this tool is most likely already made available to you ( well I seen it with MySQL database, not sure about MS SQL or Oracle) as it is tool of choice for huge number of hosting companies and you do not need to install it.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Acer is well known for these sort of problems with laptop screens, beside hinges (these tend to crack and eventually break down very quickly).
You will need to sent your laptop back to Acer for repair as they will swap the whole screen for you. If the laptop is older you may consider it not to send as they charge horrible prices for after warranty repairs and they will not tell you how much it will cost before you send your laptop for examination.
Sorry, for bad news. I can give you few personal stories on Acer topic, I'm one of unhappy customers and I will never ever buy from them

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Did you read this yet? Convert Java to EXE - Why, When, When Not and How

PS: If you so "hot" to get your application in EXE format, why don't you pay for the software. Then you will not deal with trial version and people that spent their time to create these converters get credit where due..

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

If you actually try to explain your problem in proper manner people may listen to you. You started post with assumption there is no logout option. Please check attached screen shot for locating of this option I do not see reason why make this post with Dani's business details that are publicly available Dani is not your 24/7 service support Abusing people will get you nowhere PS: I think you own some apology, if not I think you do not deserve place among us