|
Ok I think I am starting to understand what you are trying to explain to me. Since guiWrapper is the outermost JPanel, I set its background by setBackground(Color.yellow); And borders on my topLeft and topRight JPanels do not actually bleed through to the Panel behind them; since I set no background initially, they were that weird beige color and I needed to define them with topLeft.setBackground(Color.red); and topRight.setBackground(Color.green); .
I added the lines of code and set the color to darkGray , and it worked just fine. I see where my thinking went wrong to. Thank you so much for the help!
|
|
|
|
|
Hi all !
I want to receive page source from a hyperlink.
This is may code
public class SourceViewer{
public static void main (String[] args) throws IOException{
System.out.print("Enter url of local for viewing html source code: ");
String url = "http://vdict.com/Hello,1,0,0.html";
try{
URL u = new URL(url);
HttpURLConnection uc = (HttpURLConnection) u.openConnection();
int code = uc.getResponseCode();
String response = uc.getResponseMessage();
System.out.println("HTTP/1.x " + code + " " + response);
for(int j = 1; ; j++){
String header = uc.getHeaderField(j);
String key = uc.getHeaderFieldKey(j);
if(header == null || key == null)
break;
System.out.println(uc.getHeaderFieldKey(j) + ": " + header);
}
InputStream in = new BufferedInputStream(uc.getInputStream());
Reader r = new InputStreamReader(in);
int c;
while((c = r.read()) != -1){
System.out.print((char)c);
}
}
catch(MalformedURLException ex){
System.err.println(url + " is not a valid URL.");
}
catch(IOException ie){
System.out.println("Input/Output Error: " + ie.getMessage());
}
}
}
it work well with some link.
But problem with this link:
http://vdict.com/Hello,1,0,0.html[^]
this is the result form browser and my program:
-Browser:you can see by your self.
-My program:
Date: Fri, 23 Oct 2009 03:53:22 GMT
Server: Apache/2.2.3 (Red Hat)
X-Powered-By: PHP/5.1.6
Expires: Fri, 30 Oct 2009 03:53:22 GMT
Cache-Control: max-age=360000, must-revalidate
Pragma: public
Last-Modified: Fri, 23 Oct 2009 03:53:22 GMT
Vary: Accept-Encoding
Content-Length: 2102
Content-Type: text/html; charset=UTF-8
Set-Cookie: PHPSESSID=4hgviiktc0gc38aiotd8s6jn37; path=/
Connection: Close
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
<meta name='description' content='Vietnamese dictionary and translation for mobile phones and PDAs'>
<meta name='keywords' content='vietnamese, dictionary, translation, mobile phones, pda, nokia, iphone, blackberry'>
<meta name='robots' content='index, follow' />
<meta name='revisit-after' content='1 days' />
<meta name='resource-type' content='document' />
<title>Vietnamese Dictionary for Mobile phones and PDAs</title>
<link href='libs/loadstatic/m.css' rel='stylesheet' type='text/css' />
</head>
<body>
<div class="container">
<div class="header">VDict mobile</div>
<div class="menu"><strong>Dictionary</strong> - <a href="t.php">Translation</a></div> <div class="searchform">
<form name="frmlookup" id="frmlookup" action="/" method="get" style="margin:0">
<input name="word" type="text" class="forminput" size="30" value="" />
<br />
<select name="dict" class="formselect" >
<option value="1">English - Vietnamese</option>
<option value="2">Vietnamese - English</option>
<option value="3">Vietnamese - Vietnamese</option>
<option value="5">French - Vietnamese</option>
<option value="4">Vietnamese - French</option>
<option value="6">Computing</option>
<option value="7">English - English</option>
<option value="8">Chinese - Vietnamese </option>
<option value="9">Russian - Vietnamese</option>
</select>
<br />
<input name="searchaction" type="submit" value="Lookup" class="subbut" />
</form>
<div class="result"><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br /> </div>
</div>
<div class="footer">© Vdict mobile (<a href="http://vdict.com/?ndr=1">Switch to full version</a>) </div>
</div>
</body>
</html>
Can anybody tell me about this problem and how to fix it.
Thanks and regards !
|
|
|
|
|
The problem is that it does not get two things.
1. The CSS tags in the HTML file
2. The CSS file
I am not sure how to get the tags.
|
|
|
|
|
I need to write a java applet to help students learn multiplication. Use either Random class or Math.random() method to produce two positive one-digit integers. The applet should prompt the user with a question. The student then enters an answer. If the answer is correct, display the message "Very good!" and ask another question. If the answer is wrong, display the message "No. Please try again." and let the student try the same question repeatedly until the student finally gets it right. I think it takes the input but it doesn't do anything.
[code]
import java.awt.*;
import java.util.Random;
import java.util.Scanner;
import javax.swing.JApplet;
import javax.swing.JLabel;
import javax.swing.JTextField;
public class Assignment6 extends JApplet{
private Random randomNumbers = new Random();
private enum Status { Right, Wrong };
public void init(){
Scanner input = new Scanner(System.in);
int number1 = 1 + randomNumbers.nextInt( 9 ); // first die roll
int number2 = 1 + randomNumbers.nextInt( 9 ); // second die roll
int multiplication = number1 * number2;
int mOfNumbers;
Status answerStatus;
System.out.print( "How much is " + number1 + " times " + number2 + "? " );
mOfNumbers = input.nextInt();
// determine answer status
if ( mOfNumbers == multiplication ) // win by making point
answerStatus = Status.Right;
else
answerStatus = Status.Wrong;
}{
if ( answerStatus == Status.Right )
System.out.println( "Very Good! " );
else
System.out.println( "No. Please try again." );
}
[/code]
|
|
|
|
|
Is anyone willing to help? I really need some urgent help. PLEASE HELP!!! I am trying my best to finish the code.
|
|
|
|
|
Shah Ravi wrote: I need to write a java applet to help students learn multiplication.
1. This code does not even compile, so I don't see how it could have been tested.
2. System.in and System.out use the console so are not much use in a Java applet.
|
|
|
|
|
One thing I notice is that there is no loop in your code when there should be. Otherwise the program will not repeat its processes. Also, I do not see where your enum places the string "right", and "wrong", in the variables of the enum. I would suggest just using simple string values for this, it would be much simpler.
Also to simplify things, I would put brackets everywhere they can be so you can see where one process begins, and another ends.
Your logic seems fine, it just needs a loop, I would suggest a while loop. Say, until the user enters a certain word or number, continue with the loop. When they do enter it, end the program.
As far as I can see that is all you need to do for this program. Tell me if this helps.
|
|
|
|
|
shawndeprey wrote: As far as I can see that is all you need to do for this program.
You are quite right, but first he needs to understand how to do I/O from an applet. As I stated above System.in and System.out will not work here.
|
|
|
|
|
Ah yes I forgot he wanted to make this an applet. He could use a:
JOptionPane.showInputDialogue("Question to be asked?");
This is a real simple way which I did on one of my applet program...Though I think it defeats the purpose of being an applet lol.
|
|
|
|
|
shawndeprey wrote: Also, I do not see where your enum places the string "right", and "wrong", in the variables of the enum. I would suggest just using simple string values for this, it would be much simpler.
What does this mean? I don't understand what you are trying to say here. What do you mean when you talk about "the variables of the enum"? Using an enum in this case seems to be overkill compared to a simple boolean but the way it is defined and used looks correct to me unless I am missing something.
|
|
|
|
|
David Skelly wrote: unless I am missing something.
Nothing at all, the basic code is OK. Apart from the fact that there is no repeat loop when a wrong answer is given. However the main problem is that this is really a Java application rather than an applet.
|
|
|
|
|
The Java applet class should contain:
1. Two Integers.
2. Integer 1 takes a Math.random
3. Integer 2 takes another Math.random
4. You give the JOptionpane.showinputdialog to ask question dont forget to parse
5. If statement to check result
6. Joptionpane to show the result of if
|
|
|
|
|
|
This is JavaScript, not Java. You are in the wrong forum. Try posting your question in the Web Development forum instead.
|
|
|
|
|
How applet insert in the client and server concept in java.
|
|
|
|
|
Vinoli wrote: How applet insert in the client and server concept in java.
Your question is not clear, can you try and explain what you are trying to do?
|
|
|
|
|
|
That's not a question, but an attempt to promote the product. In my case, you're failing - I'm not going to use a product that's promoted this way.
Now, if you wrote an article, then I might take the time to read it, and perhaps, evaluate the product someday.
I are Troll
|
|
|
|
|
i have a application that contains purchase page which transaction happened through Authorize.net.i want return back to my application ,After submit the form. Is there any possible?
|
|
|
|
|
sangeethanarayan wrote: i have a application that contains purchase page which transaction happened through Authorize.net.i want return back to my application ,After submit the form.
Well its your application ...
sangeethanarayan wrote: Is there any possible?
There are many, what is your question?
|
|
|
|
|
use something like <pre> <a href="newwindowURL" target="_blank" onClick="location.href('oldwindowURL')">click here</a></pre>
|
|
|
|
|
When button is pressed which one finds whether is it double or single click?
|
|
|
|
|
Vinoli wrote: When button is pressed which one finds whether is it double or single click?
You need to implement MouseListener interface. The mouseClicked() accepts argument of type MouseEvent . You could use the getClickCount() method of MouseEvent
Example:
public void mouseClicked(MouseEvent e)
{
System.out.println
( "Click at (" + e.getX() + ":" + e.getY() + ")" );
if (e.getClickCount() == 2)
System.out.println( " and it's a double click!");
else
System.out.println( " and it's a single click!");
}
Regards
Nuri Ismail
|
|
|
|
|
I wrote program for color palatte.The concept is Buttons should have different colors.If any button pressed means particular color should displayed in the background.But buttons should not posses any letter.
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
<br />
<br />
public class color extends Applet implements ActionListener<br />
{<br />
Button r,g;<br />
public void init()<br />
{<br />
r=new Button();<br />
g=new Button();<br />
r.setBackground(Color.red);<br />
g.setBackground(Color.green);<br />
add(r);<br />
add(g);<br />
r.addActionListener(this);<br />
g.addActionListener(this);<br />
}<br />
public void paint(Graphics g)<br />
{ <br />
repaint();<br />
}<br />
public void actionPerformed(ActionEvent e)<br />
{<br />
String c=null;<br />
c=e.getActionCommand();<br />
if(c.equals('r'))<br />
setBackground(Color.red);<br />
if(c.equals('g'))<br />
setBackground(Color.green);<br />
}<br />
}<br />
|
|
|
|
|
Use getSource() method of ActionEvent to determine which button is clicked:
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == r)
setBackground(Color.red);
else if(e.getSource() == g)
setBackground(Color.green);
}
Hope this helps.
Nuri Ismail
|
|
|
|