What's wrong with this program, nothing displays.
Compile ok, but nothing displays.
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
public class Card{
JFrame f;
JLabel nameTF;
JComboBox jobChoice;
JButton B1, B2, B3, B4;
public static void main(String[] av) {
new Card( );
public Card( ) {
f=new JFrame();
f.setSize(500,500);
Container cp = f.getContentPane( );
cp.setLayout(new GridLayout(0, 1));
f.addWindowListener(new WindowAdapter( ) {
public void windowClosing(WindowEvent e) {
f.setVisible(false);
f.dispose( );
System.exit(0);
JMenuBar mb = new JMenuBar( );
f.setJMenuBar(mb);
JMenu aMenu;
aMenu = new JMenu("filemenu");
mb.add(aMenu);
JMenuItem mi = new JMenuItem("exit");
aMenu.add(mi);
mi.addActionListener(new ActionListener( ) {
public void actionPerformed(ActionEvent e) {
System.exit(0);
aMenu = new JMenu("editmenu");
mb.add(aMenu);
aMenu = new JMenu("viewmenu");
mb.add(aMenu);
aMenu = new JMenu("optionsmenu");
mb.add(aMenu);
aMenu =new JMenu("helpmenu");
mb.add(aMenu);
JPanel p1 = new JPanel( );
p1.setLayout(new GridLayout(0, 1, 50, 10));
nameTF = new JLabel("My Name", JLabel.CENTER);
nameTF.setFont(new Font("helvetica", Font.BOLD, 18));
nameTF.setText("MYNAME");
p1.add(nameTF);
jobChoice = new JComboBox( );
jobChoice.setFont(new Font("helvetica", Font.BOLD, 14));
String next;
int i=1;
do {
next = "job_title" + i;
if (next != null)
jobChoice.addItem(next);
} while (next != null);
p1.add(jobChoice);
cp.add(p1);
JPanel p2 = new JPanel( );
p2.setLayout(new GridLayout(2, 2, 10, 10));
B1 = new JButton( );
B1.setText("button1.label");
p2.add(B1);
B2 = new JButton( );
B2.setText("button2.label");
p2.add(B2);
B3 = new JButton( );
B3.setText("button3.label");
p2.add(B3);
B4 = new JButton( );
B4.setText("button4.label");
p2.add(B4);
cp.add(p2);
f.pack( );
f.show();
}
hi there
try this code i changed a little bil and one more thing yr LOOP is not working Properly check that out
rest is fine
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
public class Card extends JFrame
JLabel nameTF;
JComboBox jobChoice;
JButton B1, B2, B3, B4;
public static void main(String[] av)
Card C = new Card( );
C.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
public Card( )
setSize(500,500);
Container cp = getContentPane( );
cp.setLayout(new GridLayout(0, 1));
addWindowListener(new WindowAdapter( )
public void windowClosing(WindowEvent e)
dispose( );
System.exit(0);
JMenuBar mb = new JMenuBar( );
setJMenuBar(mb);
JMenu aMenu;
aMenu = new JMenu("filemenu");
mb.add(aMenu);
JMenuItem mi = new JMenuItem("exit");
aMenu.add(mi);
mi.addActionListener(new ActionListener( )
public void actionPerformed(ActionEvent e)
dispose( );
System.exit(0);
aMenu = new JMenu("editmenu");
mb.add(aMenu);
aMenu = new JMenu("viewmenu");
mb.add(aMenu);
aMenu = new JMenu("optionsmenu");
mb.add(aMenu);
aMenu =new JMenu("helpmenu");
mb.add(aMenu);
JPanel p1 = new JPanel( );
p1.setLayout(new GridLayout(0, 1, 50, 10));
nameTF = new JLabel("My Name", JLabel.CENTER);
nameTF.setFont(new Font("helvetica", Font.BOLD, 18));
nameTF.setText("MYNAME");
p1.add(nameTF);
jobChoice = new JComboBox( );
jobChoice.setFont(new Font("helvetica", Font.BOLD, 14));
String next;
// int i=1;
// do
// next = "job_title" + i;
// if (next != null)
// jobChoice.addItem(next);
// } while (next != null);
p1.add(jobChoice);
cp.add(p1);
JPanel p2 = new JPanel( );
p2.setLayout(new GridLayout(2, 2, 10, 10));
B1 = new JButton( );
B1.setText("button1.label");
p2.add(B1);
B2 = new JButton( );
B2.setText("button2.label");
p2.add(B2);
B3 = new JButton( );
B3.setText("button3.label");
p2.add(B3);
B4 = new JButton( );
B4.setText("button4.label");
p2.add(B4);
cp.add(p2);
pack( );
setVisible(true);
}Regards
Satinderjit
Similar Messages
-
What's wrong with this program?
/* Daphne invests $100 at 10% simple interest. Deirdre invests $100 at 5% interest compounded annually. Write a program that finds how many years it takes for the value of Deirdre's investment to exceed the value of Daphne's investment. Aso show the two values at that time.*/
#include <stdio.h>
#define START 100.00
int main(void)
int counter = 1;
float daphne = START;
float deirdre = START;
printf("Daphne invests $100 at 10 percent simple interest. Deirdre invests $100 at 5 percent interest compounded annually.
When will Deirdre's account value exceed Daphne's?
Let\'s find out.
while (daphne > deirdre)
daphne += 10.00;
deirdre *= 1.05;
printf("%f %f
", daphne, deirdre);
printf("At year %d, Daphne has %.2f dollars. Deirdre has %.2f dollars.
", counter, daphne, deirdre);
counter++;
printf("By the end of year %d, Deirdre's account has surpassed Daphne's in value.
", counter);
return 0;
This is my output:
*Daphne invests $100 at 10 percent simple interest. Deirdre invests $100 at 5 percent interest compounded annually.*
*When will Deirdre's account value exceed Daphne's?*
*Let's find out.*
*By the end of year 1, Deirdre's account has surpassed Daphne's in value.*
What's wrong with it?
Message was edited by: musicwind95
Message was edited by: musicwind95John hadn't responded at the time I started typing this, but I'll keep it posted anyways in order to expand on John's answer a little bit. The answer to your last question is that the loop's condition has to return true for it to run the first time around. To examine this further, let's take a look at the way you had the while loop before:
while (daphne > deirdre)
Now, a while loop will run the code between its braces as long as the condition inside the parenthesis (daphne > deirdre, in this case) is true. So, if the condition is false the first time the code reaches the while statement, then the loop will never run at all (it won't even run through it once -- it will skip over it). And since, before the while loop, both variables (daphne and dierdre) are set equal to the same value (START (100.00), in this case), both variables are equal at the point when the code first reaches the while statement. Since they are equal, daphne is NOT greater than dierdre, and therefore the condition returns false. Since the condition is false the first time the code reaches it, the code inside the loop's braces is skipped over and never run. As John recommended in the previous post, changing it to this:
while (daphne >= deirdre)
fixes the problem because now the condition is true. The use of the "greater than or equal to" operator (>=) instead of the "great than" operator (>) means that the condition can now be returned true even if daphne is equal to deirdre, not just if it's greater than deirdre. And since daphne and deirdre are equal (they are both 100.00) when the code first reaches the while loop, the condition is now returned true and the code inside the loop's braces will be run. Once the program reaches the end of the code inside the loop's braces, it will check to see if the condition is still true and, if it is, it will run the loop's code again (and again and again and again, checking to see if the condition is still true each time), and if it's not true, it will skip over the loop's bottom brace and continue on with the rest of the program.
Hope this helped clear this up for you. Please ask if you have any more questions. -
What is wrong with this program segment? I could not understand the error..
public class Hmw3
public static char[] myMethod(char[]p1,int p2, char p3)
{ //13 th row
if(p2<p1.length)
p1[p2]=p3;
System.out.println(p1);
public static void main(String[] args)
String sentence="It snows";
char[] tmp=sentence.toCharArray();
System.out.println(tmp);
myMethod(tmp,3,'k');
sentence=String.copyValueOf(tmp);
System.out.println(sentence);
i wrote this program segment and compiler gave this error:
C:\Program Files\Xinox Software\JCreator LE\MyProjects\hmw3\Hmw3.java:13: missing return statement
What is wrong???Your method signature states that myMethod should return an array for chars.
But in ur implementation of myMethod, there is nothing returned.
Just add a return statement like "return p1" -
What is wrong with this program it keeps telling me the file doesn't exist?
this program is supposed to write the file so why does it need the file to already exist?
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.ArrayList;
import java.util.Scanner;
public class NewClass implements ActionListener{
static List list = new List();
static TextField input = new TextField(20);
static Button submit = new Button("Submit");
static Frame f = new Frame("RealmList editor");
static File file = new File("/Applications/World of Warcraft/realmlist.wtf");
static Label status = new Label("");
static Button selected = new Button("Change to Selected");
static File config = new File("/Applications/RealmLister/config.txt");
static File dir = new File("/Applications/RealmLister/");
public static void main(String[] args) {
f.setLayout(new BorderLayout());
f.add(list, BorderLayout.CENTER);
Panel p = new Panel();
p.add(input);
p.add(submit);
p.add(selected);
f.add(p, BorderLayout.NORTH);
f.add(status, BorderLayout.SOUTH);
new NewClass();
f.setSize(500,500);
f.setVisible(true);
try {
loadConfig();
} catch(Exception e) {}
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
try {
writeConfig();
System.exit(0);
} catch(Exception e) {
status.setText("Error: config couldn't be written!("+e+")");
public NewClass() {
submit.addActionListener(this);
input.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if(e.getKeyCode() == KeyEvent.VK_ENTER) {
try {
editRealmlist(input.getText(), true);
input.setText("");
catch(Exception ex) {
status.setText("Error: "+e);
selected.addActionListener(this);
public void actionPerformed(ActionEvent e) {
if(e.getSource() == submit) {
try {
editRealmlist(input.getText(), true);
input.setText("");
} catch(Exception ex) {
status.setText("Error: "+e);
wait(3000);
status.setText("");
if(e.getSource() == selected) {
try {
editRealmlist(list.getSelectedItem(),false);
} catch(Exception ex) {
status.setText("Error: "+e);
wait(3000);
status.setText("");
public static void loadConfig() throws Exception{
if(config.exists()) {
Scanner scan = new Scanner(config);
ArrayList<String> al = new ArrayList<String>();
while(scan.hasNext()) {
al.add(scan.nextLine());
for(int i = 0; i < al.size(); i++) {
list.add(al.get(i));
public static void writeConfig() throws Exception{
FileWriter fw = new FileWriter(config);
dir.mkdir();
config.mkdirs();
String temp = "";
for(int i = 0; i < list.getItemCount(); i++) {
temp += list.getItem(i)+"\n";
fw.write(temp);
fw.flush();
System.gc();
public static void editRealmlist(String realm, boolean addtoList) throws Exception{
FileWriter fw = new FileWriter(file);
fw.write("set realmlist "+realm+"\nset patchlist us.version.worldofwarcraft.com");
fw.flush();
status.setText("Editing RealmList.wtf Please Wait...");
Thread.sleep(3000);
status.setText("");
System.gc();
if(addtoList)
list.add(realm);
public void wait(int time) {
try {
Thread.sleep(time);
catch(Exception e) {}
}Erm, you should call mkdirs() on a File object that represents a directory.
-
What's wrong with this picture (unbundle display glitch)?
Let me state first that I actually like the look of what I am going to show you, and I am tempted to suggest it as an actual feature...
In any case, here it is:
This is an unbundle node in an actual diagram. All items are connected. I was simply hovering over them to better read the name of the objects (white on a darker background is easier on my eyes than a pale orange on a white background) and as I was doing so, I noticed that if I lingered long enough and at the right location on an item, it would remain highlighted when I moved to the next one. This is how I generated the situation above (it took me some time to get it right, but that is not too difficult).
Note that I am not activating the wiring tool (BTW, I have autotool off), I am just hovering with it over the unbundle node.
All my drivers are up to date (including video drivers). Tested in LV 2011, Windows XP.This is probably the same display issue which was discussed here - http://forums.ni.com/t5/LabVIEW/Property-node-inverted-color/m-p/871556#M394578
As long as it's not doing anything bad, it doesn't really bother me.
That said, I don't remember seeing it in a long time, so it's possible that this stopped happening for me in LV 2009 (unlikely) or that it was an issue with the video driver on my previous laptop.
Try to take over the world! -
What's wrong with this program that about socket
package example;
import java.net.*;
import java.io.*;
public class Server implements Runnable{
Thread t;
ServerSocket sSocket;
int sPort=6633;
public Server(){
try{
sSocket=new ServerSocket(sPort);
System.out.println("server start....");
}catch(IOException e){
e.printStackTrace();
t=new Thread(this);
t.start();
public void run(){
try{
while(true){
Socket cSocket=sSocket.accept();
ClientThread cThread=new ClientThread(cSocket);
cThread.start();
}catch(IOException e){
e.printStackTrace();
public static void main(String[] args){
new Server();
package example;
import java.net.*;
import java.io.*;
public class ClientThread extends Thread{
Socket cSocket;
PrintStream writer;
BufferedReader reader;
public ClientThread(Socket s){
cSocket=s;
try{
writer=new PrintStream(cSocket.getOutputStream());
reader=new BufferedReader(new InputStreamReader(cSocket.getInputStream()));
}catch(IOException e){
e.printStackTrace();
public void run(){
try{
while(true){
String message=reader.readLine();
System.out.println("Server get:"+message);
}catch(IOException e){
e.printStackTrace();
package example;
import java.net.*;
import java.io.*;
public class Client{
public static void main(String[] args){
String ipaddr="localhost";
PrintStream writer;
try{
Socket cSocket=new Socket(ipaddr,6633);
System.out.println(cSocket);
writer=new PrintStream(cSocket.getOutputStream());
System.out.println("client send:hello");
writer.print("hello");
catch(Exception e){
e.printStackTrace();
}first,I run Server,and then I run Client,
output at Server:
server start....
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:168)
at java.net.SocketInputStream.read(SocketInputStream.java:90)
at sun.nio.cs.StreamDecoder$ConverterSD.implRead(StreamDecoder.java:285)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:182)
at java.io.InputStreamReader.read(InputStreamReader.java:167)
at java.io.BufferedReader.fill(BufferedReader.java:136)
at java.io.BufferedReader.readLine(BufferedReader.java:299)
at java.io.BufferedReader.readLine(BufferedReader.java:362)
at example.ClientThread.run(ClientThread.java:20)
what' wrong??????In your Client class, after doing writer.print("hello"); you should flush
the output stream. As it is now, you attempt to write something (without actually
sending something to your server) and main simply terminates. The server,
still waiting for some input (you didn't flush on the client side), is confronted with
a closed client socket (main on the client side terminated and implicitly closed
the client socket), hence the 'connection reset' exception on the server side.
kind regards,
Jos -
What is wrong with this program?
When I run a get these messages:
^
MULTIPLYIMP.java:25: 'class' or 'interface' expected
^
MULTIPLYIMP.java:7: cannot resolve symbol
symbol : class UnicastRemoteObject
location: class MULTIPLYIMP
UnicastRemoteObject implements multiply {
^
MULTIPLYIMP.java:6: MULTIPLYIMP should be declared abstract; it does not define
greet() in MULTIPLYIMP
public class MULTIPLYIMP extends
^
MULTIPLYIMP.java:11: cannot resolve symbol
symbol : method supa ()
location: class MULTIPLYIMP
supa (); //Export
^
MULTIPLYIMP.java:15: missing method body, or declare abstract
public int mult (int a,int b) throws RemoteException
^
9 errors
//MULTIPLYIMPL.JAVA
import java.rmi.*;
import .rmi.server.*;
public class MULTIPLYIMP extends
unicastRemoteObject implements multiply {
public MULTIPLYIMPL () throwsRemoteException {
supa (); //Export
public int mult (int a,int b) throws RemoteException
return (a * b)
public String greet () throws RemoteException
return("CCM 3061");When I run a get these messages:
^
MULTIPLYIMP.java:25: 'class' or 'interface' expected
^
MULTIPLYIMP.java:7: cannot resolve symbol
symbol : class UnicastRemoteObject
location: class MULTIPLYIMP
UnicastRemoteObject implements multiply {
^
You haven't imported the right package.
You need to import
java.rmi.server.UnicastRemoteObject
or
java.rmi.server.*
MULTIPLYIMP.java:6: MULTIPLYIMP should be declared
abstract; it does not define
greet() in MULTIPLYIMP
public class MULTIPLYIMP extends
^
It says that you don't define greet() because it doesn't have curly braces after the method name.
I'm reasonably sure
public String greet () throws RemoteException
return("CCM 3061");is not acceptable, usepublic String greet () throws RemoteException
return("CCM 3061");
MULTIPLYIMP.java:11: cannot resolve symbol
symbol : method supa ()
location: class MULTIPLYIMP
supa (); //Export
^
MY GOD MAN, SUPER(), SUPER!!!!!!
MULTIPLYIMP.java:15: missing method body, or declare
abstract
public int mult (int a,int b) throws RemoteException
^
9 errors
Same with mult(), need to have curly braces around the method body
//MULTIPLYIMPL.JAVA
import java.rmi.*;
WHAT IS THIS LINE?
import java.rmi.server.*
import .rmi.server.*;
public class MULTIPLYIMP extends
unicastRemoteObject implements multiply {
public MULTIPLYIMPL () throwsRemoteException {
supa (); //Export
public int mult (int a,int b) throws RemoteException
return (a * b)
public String greet () throws RemoteException
return("CCM 3061");
}Messy messy code mate,
Good luck,
Radish21 -
What's wrong with this code to display a JTable?
Hi.
I am trying to display a JTable in BorderLayout.CENTER, and I am getting this compile time error:
SampleVIew.java:78: cannot resolve symbol
method add (SampleView.NewTable)
class javax.swing.JPanel
.....guiPane.add(DefaultNewTable);
Here is the code snippet, I've highlighted the offensive code with <--- HERE
public class SampleView extends JApplet
public SampleView()
JFrame pf = new JFrame("Testing");
Container content = pf.getContentPane();
// ============================== CENTER
JPanel centerPane = new JPanel(new GridLayout(2,0));
// ============================== add new table to top half of centerPane
NewTable DefaultNewTable = new NewTable();
JScrollPane scrollpane = new JScrollPane(DefaultNewTable); // <---- HERE
centerPane.add(scrollpane); // <---- HERE
content.add(centerPane, BorderLayout.CENTER);
pf.setVisible(true);
public class NewTable
public void NewTable()
JTable newtable = new JTable(new TableDefinition())
protected JTableHeader createDefaultTableHeader()
return new JTableHeader(columnModel)
public String getToolTipText(MouseEvent mevt)
String tip = null;
java.awt.Point p = mevt.getPoint();
int index = columnModel.getColumnIndexAtX(p.x);
int realIndex = columnModel.getColumn(index).getModelIndex();
return colHeaderInfo[realIndex];
initColumnSizes(newtable);
enableCellSelection(newtable);
newtable.setVisible(true);
} // end of class NewTable()
// etc
}TIA :-)Hi.
Followed you advice and used "this" instead of lical variable "newtable".
I still don't get a display on BorderLayout.CENTER.
The code snippet looks like this now: public class SampleView extends JApplet
public SampleView()
JFrame pf = new JFrame("Testing");
Container content = pf.getContentPane();
// ============================== CENTER
JPanel centerPane = new JPanel(new GridLayout(2,0));
// ============================== add new table to top half of centerPane
NewTable DefaultNewTable = new NewTable();
JScrollPane scrollpane = new JScrollPane(DefaultNewTable);
centerPane.add(scrollpane);
content.add(centerPane, BorderLayout.CENTER);
pf.setVisible(true);
public class NewTable extends JTable
public void NewTable()
JTable newtable = new JTable(new TableDefinition())
protected JTableHeader createDefaultTableHeader()
return new JTableHeader(columnModel)
public String getToolTipText(MouseEvent mevt)
String tip = null;
java.awt.Point p = mevt.getPoint();
int index = columnModel.getColumnIndexAtX(p.x);
int realIndex = columnModel.getColumn(index).getModelIndex();
return colHeaderInfo[realIndex];
initColumnSizes(this);
enableCellSelection(this);
this.setVisible(true); // <--- This is useless!
} // end of class NewTable()
// etc
}The kinda error I can't come to grip with because it compiles and run without console output... :-( -
Does ANYONE know whats wrong with this program?!?!
Hey(again),
Does anyone know whats wrong with this program?:
public class FloatingNumbersTest
public static void main(String args[])
float float1 =50.0f;
float closeFloat=0.001f
float farfloat=100.0f
if (float1<=closeFloat)
System.out.print("Float1 pretty close to zero");
if (float1>=closeFloat)
System.out.print("Float1 is near 0");
if (float1>=farfloat)
System.out.print("Float1 is not even close to zero!"0
}There has seemed to be 5 errors!public class FloatingNumbersTest
public static void main(String args[])
float float1 =50.0f;
float closeFloat=0.001f
float farfloat=100.0f
if (float1<=closeFloat)
HERE System.out.print("Float1 pretty close to zero");
if (float1>=closeFloat)
System.out.print("Float1 is near 0");
if (float1>=farfloat)
System.out.print("Float1 is not even close to zero!"0
}you're missing the opening { for the first if. -
I can't figure out what's wrong with this code
First i want this program to allow me to enter a number with the EasyReader class and depending on the number entered it will show that specific line of this peom:
One two buckle your shoe
Three four shut the door
Five six pick up sticks
Seven eight lay them straight
Nine ten this is the end.
The error message i got was an illegal start of expression. I can't figure out why it is giving me this error because i have if (n = 1) || (n = 2) statements. My code is:
public class PoemSeventeen
public static void main(String[] args)
EasyReader console = new EasyReader();
System.out.println("Enter a number for the poem (0 to quit): ");
int n = console.readInt();
if (n = 1) || (n = 2)
System.out.println("One, two, buckle your shoe");
else if (n = 3) || (n = 4)
System.out.println("Three, four, shut the door");
else if (n = 5) || (n = 6)
System.out.println("Five, six, pick up sticks");
else if (n = 7) || (n = 8)
System.out.println("Seven, eight, lay them straight");
else if (n = 9) || (n = 10)
System.out.println("Nine, ten, this is the end");
else if (n = 0)
System.out.println("You may exit now");
else
System.out.println("Put in a number between 0 and 10");
I messed around with a few other thing because i had some weird errors before but now i have narrowed it down to just this 1 error.
The EasyReader class code:
// package com.skylit.io;
import java.io.*;
* @author Gary Litvin
* @version 1.2, 5/30/02
* Written as part of
* <i>Java Methods: An Introduction to Object-Oriented Programming</i>
* (Skylight Publishing 2001, ISBN 0-9654853-7-4)
* and
* <i>Java Methods AB: Data Structures</i>
* (Skylight Publishing 2003, ISBN 0-9654853-1-5)
* EasyReader provides simple methods for reading the console and
* for opening and reading text files. All exceptions are handled
* inside the class and are hidden from the user.
* <xmp>
* Example:
* =======
* EasyReader console = new EasyReader();
* System.out.print("Enter input file name: ");
* String fileName = console.readLine();
* EasyReader inFile = new EasyReader(fileName);
* if (inFile.bad())
* System.err.println("Can't open " + fileName);
* System.exit(1);
* String firstLine = inFile.readLine();
* if (!inFile.eof()) // or: if (firstLine != null)
* System.out.println("The first line is : " + firstLine);
* System.out.print("Enter the maximum number of integers to read: ");
* int maxCount = console.readInt();
* int k, count = 0;
* while (count < maxCount && !inFile.eof())
* k = inFile.readInt();
* if (!inFile.eof())
* // process or store this number
* count++;
* inFile.close(); // optional
* System.out.println(count + " numbers read");
* </xmp>
public class EasyReader
protected String myFileName;
protected BufferedReader myInFile;
protected int myErrorFlags = 0;
protected static final int OPENERROR = 0x0001;
protected static final int CLOSEERROR = 0x0002;
protected static final int READERROR = 0x0004;
protected static final int EOF = 0x0100;
* Constructor. Prepares console (System.in) for reading
public EasyReader()
myFileName = null;
myErrorFlags = 0;
myInFile = new BufferedReader(
new InputStreamReader(System.in), 128);
* Constructor. opens a file for reading
* @param fileName the name or pathname of the file
public EasyReader(String fileName)
myFileName = fileName;
myErrorFlags = 0;
try
myInFile = new BufferedReader(new FileReader(fileName), 1024);
catch (FileNotFoundException e)
myErrorFlags |= OPENERROR;
myFileName = null;
* Closes the file
public void close()
if (myFileName == null)
return;
try
myInFile.close();
catch (IOException e)
System.err.println("Error closing " + myFileName + "\n");
myErrorFlags |= CLOSEERROR;
* Checks the status of the file
* @return true if en error occurred opening or reading the file,
* false otherwise
public boolean bad()
return myErrorFlags != 0;
* Checks the EOF status of the file
* @return true if EOF was encountered in the previous read
* operation, false otherwise
public boolean eof()
return (myErrorFlags & EOF) != 0;
private boolean ready() throws IOException
return myFileName == null || myInFile.ready();
* Reads the next character from a file (any character including
* a space or a newline character).
* @return character read or <code>null</code> character
* (Unicode 0) if trying to read beyond the EOF
public char readChar()
char ch = '\u0000';
try
if (ready())
ch = (char)myInFile.read();
catch (IOException e)
if (myFileName != null)
System.err.println("Error reading " + myFileName + "\n");
myErrorFlags |= READERROR;
if (ch == '\u0000')
myErrorFlags |= EOF;
return ch;
* Reads from the current position in the file up to and including
* the next newline character. The newline character is thrown away
* @return the read string (excluding the newline character) or
* null if trying to read beyond the EOF
public String readLine()
String s = null;
try
s = myInFile.readLine();
catch (IOException e)
if (myFileName != null)
System.err.println("Error reading " + myFileName + "\n");
myErrorFlags |= READERROR;
if (s == null)
myErrorFlags |= EOF;
return s;
* Skips whitespace and reads the next word (a string of consecutive
* non-whitespace characters (up to but excluding the next space,
* newline, etc.)
* @return the read string or null if trying to read beyond the EOF
public String readWord()
StringBuffer buffer = new StringBuffer(128);
char ch = ' ';
int count = 0;
String s = null;
try
while (ready() && Character.isWhitespace(ch))
ch = (char)myInFile.read();
while (ready() && !Character.isWhitespace(ch))
count++;
buffer.append(ch);
myInFile.mark(1);
ch = (char)myInFile.read();
if (count > 0)
myInFile.reset();
s = buffer.toString();
else
myErrorFlags |= EOF;
catch (IOException e)
if (myFileName != null)
System.err.println("Error reading " + myFileName + "\n");
myErrorFlags |= READERROR;
return s;
* Reads the next integer (without validating its format)
* @return the integer read or 0 if trying to read beyond the EOF
public int readInt()
String s = readWord();
if (s != null)
return Integer.parseInt(s);
else
return 0;
* Reads the next double (without validating its format)
* @return the number read or 0 if trying to read beyond the EOF
public double readDouble()
String s = readWord();
if (s != null)
return Double.parseDouble(s);
// in Java 1, use: return Double.valueOf(s).doubleValue();
else
return 0.0;
Can anybody please tell me what's wrong with this code? ThanksString[] message = {
"One, two, buckle your shoe",
"One, two, buckle your shoe",
"Three, four, shut the door",
"Three, four, shut the door",
"Five, six, pick up sticks",
"Five, six, pick up sticks",
"Seven, eight, lay them straight",
"Seven, eight, lay them straight",
"Nine, ten, this is the end",
"Nine, ten, this is the end"
if(n>0)
System.out.println(message[n]);
else
System.exit(0); -
What's wrong with this SQL?
what's wrong with this SQL?
Posted: Jan 16, 2007 9:35 AM Reply
Hi, everyone:
when I insert into table, i use the fellowing SQL:
INSERT INTO xhealthcall_script_data
(XHC_CALL_ENDED, XHC_SWITCH_PORT, XHC_SCRIPT_ID, XHC_FAX_SPECIFIED)
VALUES (SELECT TO_DATE(HH_END_DATE||' '||HH_END_TIME,'MM/DD/YY HH24:MI:SS'), HH_SWITCHPORT, HH_SCRIPT,'N'
FROM tmp_healthhit_load WHERE HH_SCRIPT !='BROCHURE' UNION
SELECT TO_DATE(HH_END_DATE||' '||HH_END_TIME,'MM/DD/YY HH24:MI:SS'), HH_SWITCHPORT, HH_SCRIPT,'N' FROM tmp_healthhit_load WHERE HH_SCRIPT !='BROCHURE');
I always got an error like;
VALUES (SELECT TO_DATE(HH_END_DATE||' '||HH_END_TIME,'MM/DD/YY HH24:MI:SS'), HH_SWITCHPORT,
ERROR at line 3:
ORA-00936: missing expression
but I can't find anything wrong, who can tell me why?
thank you so much in advance
mpowel01
Posts: 1,516
Registered: 12/7/98
Re: what's wrong with this SQL?
Posted: Jan 16, 2007 9:38 AM in response to: jerrygreat Reply
For starters, an insert select does not have a values clause.
HTH -- Mark D Powell --
PP
Posts: 41
From: q
Registered: 8/10/06
Re: what's wrong with this SQL?
Posted: Jan 16, 2007 9:48 AM in response to: mpowel01 Reply
Even I see "missing VALUES" as the only error
Eric H
Posts: 2,822
Registered: 10/15/98
Re: what's wrong with this SQL?
Posted: Jan 16, 2007 9:54 AM in response to: jerrygreat Reply
...and why are you doing a UNION on the exact same two queries?
(SELECT TO_DATE(HH_END_DATE||' '||HH_END_TIME,'MM/DD/YY HH24:MI:SS') ,HH_SWITCHPORT ,HH_SCRIPT ,'N' FROM tmp_healthhit_load WHERE HH_SCRIPT !='BROCHURE' UNION SELECT TO_DATE(HH_END_DATE||' '||HH_END_TIME,'MM/DD/YY HH24:MI:SS') ,HH_SWITCHPORT ,HH_SCRIPT ,'N' FROM tmp_healthhit_load WHERE HH_SCRIPT !='BROCHURE');
jerrygreat
Posts: 8
Registered: 1/3/07
Re: what's wrong with this SQL?
Posted: Jan 16, 2007 9:55 AM in response to: mpowel01 Reply
Hi,
thank you for your answer, but the problem is, if I deleted "values" as you pointed out, and then execute it again, I got error like "ERROR at line 3:
ORA-03113: end-of-file on communication channel", and I was then disconnected with server, I have to relogin SQLplus, and do everything from beganing.
so what 's wrong caused disconnection, I can't find any triggers related. it is so wired?
I wonder if anyone can help me about this.
thank you very much
jerry
yingkuan
Posts: 1,801
From: San Jose, CA
Registered: 10/8/98
Re: what's wrong with this SQL?
Posted: Jan 16, 2007 9:59 AM in response to: jerrygreat Reply
Dup Post
jerrygreat
Posts: 8
Registered: 1/3/07
Re: what's wrong with this SQL?
Posted: Jan 16, 2007 10:00 AM in response to: Eric H Reply
Hi,
acturlly what I do is debugging a previous developer's scipt for data loading, this script was called by Cron work, but it never can be successfully executed.
I think he use union for eliminating duplications of rows, I just guess.
thank you
jerry
mpowel01
Posts: 1,516
Registered: 12/7/98
Re: what's wrong with this SQL?
Posted: Jan 16, 2007 10:03 AM in response to: yingkuan Reply
Scratch the VALUES keyword then make sure that the select list matches the column list in number and type.
1 insert into marktest
2 (fld1, fld2, fld3, fld4, fld5)
3* select * from marktest
UT1 > /
16 rows created.
HTH -- Mark D Powell --
Jagan
Posts: 41
From: Hyderabad
Registered: 7/21/06
Re: what's wrong with this SQL?
Posted: Jan 16, 2007 10:07 AM in response to: jerrygreat Reply
try this - just paste the code and give me the error- i mean past the entire error as it is if error occurs
INSERT INTO xhealthcall_script_data
(xhc_call_ended, xhc_switch_port, xhc_script_id,
xhc_fax_specified)
SELECT TO_DATE (hh_end_date || ' ' || hh_end_time, 'MM/DD/YY HH24:MI:SS'),
hh_switchport, hh_script, 'N'
FROM tmp_healthhit_load
WHERE hh_script != 'BROCHURE'
UNION
SELECT TO_DATE (hh_end_date || ' ' || hh_end_time, 'MM/DD/YY HH24:MI:SS'),
hh_switchport, hh_script, 'N'
FROM tmp_healthhit_load
WHERE hh_script != 'BROCHURE';
Regards
Jagan
jerrygreat
Posts: 8
Registered: 1/3/07
Re: what's wrong with this SQL?
Posted: Jan 16, 2007 11:31 AM in response to: Jagan Reply
Hi, Jagan:
thank you very much for your answer.
but when I execute it, I still can get error like:
ERROR at line 1:
ORA-03113: end-of-file on communication channel
so wired, do you have any ideas?
thank you very muchAnd this one,
Aother question about SQL?
I thought I already told him to deal with
ORA-03113: end-of-file on communication channel
problem first.
There's nothing wrong (syntax wise) with the query. (of course when no "value" in the insert) -
I HATE my new MACBOOK PRO, it will not let me open any PDF files and I downloaded the ADOBE READER three freaking times and it keeps saying that all the files are corrupt or damaged. I would rather have my 2008 Dell at this point. what is wrong with this thing
Perhaps the PDF files are corrupted.
Hit the command key and spacebar, a blue Spotlight in the upper right hand corner appears, now type Preview and press return on the Preview program.
Now you can try opening the PDF's from the file menu and see what's going on.
If they are corrupted, perhaps they are trojans from your Windows PC or gotten from a bad location online.
Download the free ClamXav and run a scan on the possibly infected folder. -
What's wrong with this formula?
What's wrong with this formula? Why am I getting 0?
Mismatch in data types.
Status, "=*Book*" is fine, as the content of the status column is text, and the condition is comparing it to a text string (with wild cards)
But
Event Date, "=*2011*" compares a Date and Time value in Event Date to a text string (with wild cards).
Here's a demonstration, using COUNTIF to stand in for COUNTIFS.
Note that the "book" counts are all correct.
Note that the first Date count counts both occurrences of Jan 2, 2012 in column A, despite the difference in format used in displaying the dates, while the second counts neither, due to the wild card forcing it to look for a text string, not a Date and Time value.
For your case, you'll need a COUNTIFS formula with three test-range, condition pairs:
=COUNTIFS(Schedule :: $A,"=*book*",Schedule :: $B,">="&B2,Schedule :: B,"<="&B3)
Regards,
Barry -
What's wrong with this (transparent) picture ...?
There are many posts on the issue of JPG's being converted into PNG's and a variety of replies with sympathetic suggestions for how to avoid this plague.
Many months back I also used to see recommendations of making an iWeb graphic into a very reduced opacity item that can be used as a hyper-link.
But I've yet to see any of the responders directly address the dreaded png's of transparent hyperlinks.
Why not.?
What's wrong with this picture.?
Am I, so far, only partially educated about file type as to be unreasonably anxious about transparent hyper-link png's.?
Has this graphic question just slipped through the cracks because of all the other jpg-into-png avoidance issues.?
Or perhaps, do transparent png's "work-just-fine, thank-you" on a PC's I.E...?
Is it somehow possible to reduce the opacity of an imported JPG without it converting..?
If png's are to be avoided for any of us aiming at the-world-beyond-Mac, then that ought to include the iWeb graphics used for hyper-Links, right.
What is the story..?
Any help appreciated appreciated.!Nope… it'll more than likely be a problematic G5 software installation. My Mac mini runs a 24" display and can play 720p video just fine with it's extremely crappy Intel GMA950 integrated graphics. It does however frame drop a little with 1080i high motion video. Both Bluetooth and USB mice just work fine. The Mac Pro will have no problems doing any of this.
-
Can someone tell me what's wrong with this LOV query please?
This query works fine..
select FILTER_NAME display_value, FILTER_ID return_value
from OTMGUI_FILTER where username = 'ADAM'
But this one..
select FILTER_NAME display_value, FILTER_ID return_value
from OTMGUI_FILTER where username = apex_application.g_user
Gives the following error.
1 error has occurred
* LOV query is invalid, a display and a return value are needed, the column names need to be different. If your query contains an in-line query, the first FROM clause in the SQL statement must not belong to the in-line query.
Thanks very much,
-Adam vonNiedaYa know, I still don't know what's wrong with this.
declare
l_val varchar2(100) := nvl(apex_application.g_user,'ADAM');
begin
return 'select filter_name display_value, filter_id return_value
from otmgui_filter where username = '''|| l_val || '''';
end;
Gets the same error as above. All I'm trying to do is create a dropdown LOV which selects based on the apex_application.g_user.
What am I missing here?
Thanks,
-Adam
Maybe you are looking for
-
10g Express installation on Win 2003 Server is failing
Hi, I am facing the similar issue like this Oracle Database 10g Express Edition installing on win2003 SP2 installation is failing after copying the files and publishing the product information and then automatically rolling back the complete setup. I
-
Delete scriptcode - General question: capacity limit of Acrobat Windows
Hello everybody, I've got a general question to the capacity limit of Acrobat Windows. I often make forms with for instance the current one has 18 pages. Eleven pages have fields on it. (But some pages have only one field on it) The fields of one pag
-
Error when downloading SMS messages from Nokia 623...
Hi, I have been using a Nokia 6233 phone for the past 3 yrs. Now that my phone memory is full I was attempting to download the messages in my inbox to my PC. However when I attempt to connect my phone to my PC (this is the first time that I am trying
-
Hello AAA experts, My customer has to change the ip address of one of the ACS server that is in production. In my opinion change in ip address would cause AAA client information in ACS gui to update and point to new ip address automatically. Would b
-
What to backup on Ciscoworks lms 2.6 windows server
Howdy, I need to do a file level backup of a Ciscoworks lms 2.6 windows server and want to know what i need to backup on the windows server file level? Basically what partitions, folders, files etc? Thanks..