|
I was aware that it was not the image size, but the number of pixels in the shape being filled that was the problem, and that the recursion overflow error was occurring in the changeColor() method... Your solution does not implement the bucket feature in MS Paint, because when you use the paint bucket in Paint it fills all adjacent pixels of a similar color with the color of your choice, what you have given me only fills a rectangle with a certain color :/
Thanks for the reply though!
|
|
|
|
|
I think I found the answer guys. My main problem for looking for help with my problem was that I didn't know what the "paint can tool" functionality was called! But it turns out there is something called the Flood Fill Algorithm that is exactly what I'm talking about implementing.
http://en.wikipedia.org/wiki/Flood_fill[^]
|
|
|
|
|
My bad, in my way I was trying to say that if you give the coordinates of the pixels then use the graphics class to fill in the color but its not practical any way here is a nice implementation of the specified algorithm: http://www.cis.upenn.edu/~matuszek/cit594-2005/ Check FloodFillApplet.java and ColorArrayComponent.java
Good luck
|
|
|
|
|
|
how to devlop TAPI in java. i want to devlop TAPI in java and use this interface in ASP.Net application to devlop a virtual phone.
|
|
|
|
|
I personally haven't done Tapi programming but from what I searched you can do it solely using ASP.NET
http://www.julmar.com/blog/mark/PermaLink,guid,0535ed97-f590-438e-9b99-1ddee1e8237a.aspx (you require the Atapi.dll from http://www.julmar.com/tapi/)
I also found this (JTapi) http://xtapi.sourceforge.net/ and http://blog.devrealm.org/2009/03/26/jtapi-overview/ You can convert the classes to applets and embed them in your ASP.NET application but I think if you can get the first link to work that would save you a lot of time.
Good Luck
|
|
|
|
|
Hi all,
am an entirely a newbie in encryption, just decided to give it a go with a book. But a lost at trying to configure my machine to run simple encryption codes, like the one given below; running with a 128-byte array size works fine but i dont know how i can implement the 256-byte or 192-byte array key size.
I've replaced the "strong Encryption" policy in JRE in Java path with unrestricted policy jar files i downloaded from Sun website.
Also i used the bounty Castle provider and copied the jar files to "ext" sub-directory in Jre directories.
Yet it does'nt seem to work perfectly.
Any Idea would be greatly appreciated.
Thanks alot in advance!!
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.KeyGenerator;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
public class EncryptTest {
public EncryptTest()
{
}
public static void main(String[] args) throws Exception
{
KeyGenerator keygen = KeyGenerator.getInstance("AES");
keygen.init(192);
SecretKey aesKey = keygen.generateKey();
Cipher aesCipher;
aesCipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
aesCipher.init(Cipher.ENCRYPT_MODE, aesKey);
byte[] clearText = "This is an example!".getBytes();
System.out.println("ClearText: "+new String(clearText));
byte[] cipherText = aesCipher.doFinal(clearText);
System.out.println("CipherText: "+new String(cipherText));
aesCipher.init(Cipher.DECRYPT_MODE, aesKey);
byte[] clearTextDecrypt = aesCipher.doFinal(cipherText);
System.out.println("DecryptedText: " + new String(clearTextDecrypt));
boolean equalText = Arrays.equals(clearText, clearTextDecrypt);
if (equalText)
{
System.out.println("Successful recovery!");
}
else
{
System.out.println("String was NOT recovered!!");
}
}
}
|
|
|
|
|
Your code will run fine but you need to tweek your JDk and JRE.
1. Go to http://java.sun.com/javase/downloads/index.jsp and download Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 6.
2. In these directories C:\Program Files\Java\jdk1.6.0_16\jre\lib\security and C:\Program Files\Java\jre6\lib\security
3. Paste the two jars you downloaded and everything will work.
Regards
|
|
|
|
|
Thanks Member 4277480 for ur reply, but i did the same with jdk1.5_20 and did exactly what u said, but it isn't working for me.
Any other thing I should do?
Thanks again!!
|
|
|
|
|
Upgrade to 6u16! Always use latest JDK.
|
|
|
|
|
I will try just that and then c how it works.
I will give u a feed back later!
Thanks!
|
|
|
|
|
Thanks a lot Member, ur advice worked perfectly!
I'll now enjoy enciphering and deciphering I guess!!!
Thanks!
|
|
|
|
|
Good to hear your progress
|
|
|
|
|
Hi everybody !
Im now using TrayIcon . The tooltip message display two caption and the image belong to Message Type as bellow.
-Title :String
-Message :String.
-MessageType:INFO,WARNING,ERROR,NONE.
I now want to dis play the tooltip message with two caption and the Icon image that i specify the path as bellow:
-Title :String
-Message :String.
-IconImage : IconImage or path of the image.
Can anybody help me.
Thanks very much !
Best regards !
|
|
|
|
|
In short if the TrayIcon class was a JComponent then you can simply apply html tags to it. Therefore, to simulate what you need I will use the jdic.jar from https://jdic.dev.java.net/servlets/ProjectDocumentList?expandFolder=4183&folderID=5497.
import javax.swing.*;
import org.jdesktop.jdic.tray.*;
import java.awt.BorderLayout;
import java.awt.event.*;
public class SystemTrayDemo extends JFrame
{
public TrayIcon trayIcon;
public JDialog dialog;
public SystemTrayDemo()
{
JPopupMenu menu = new JPopupMenu("Menu");
JMenuItem menuItem1 = new JMenuItem("Menu1");
menu.add(menuItem1);
JMenuItem menuItem2 = new JMenuItem("Menu2");
menu.add(menuItem2);
JMenuItem menuItem3 = new JMenuItem("Menu3");
menu.add(menuItem3);
JMenuItem menuItem4 = new JMenuItem("Exit");
menu.add(menuItem4);
menuItem4.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent evt)
{
System.exit(0);
}
});
ImageIcon icon = new ImageIcon("middle.gif");
trayIcon = new TrayIcon(icon, "Hello System Tray", menu);
SystemTray tray = SystemTray.getDefaultSystemTray();
tray.addTrayIcon(trayIcon);
trayIcon.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dialog = new JDialog();
dialog.add(new JLabel("Title"), BorderLayout.NORTH);
dialog.add(new JLabel("Message"), BorderLayout.CENTER);
dialog.add(new JLabel(new ImageIcon("middle.gif")),BorderLayout.SOUTH);
dialog.setLocation(trayIcon.getLocationOnScreen().x - 50,trayIcon.getLocationOnScreen().y - 105);
dialog.setVisible(true);
dialog.setSize(100, 100);
dialog.setResizable(false);
dialog.addMouseListener(new MouseAdapter()
{
public void mouseReleased(MouseEvent e)
{
dialog.dispose();
}
});
}
});
}
public static void main(String[] args)
{
new SystemTrayDemo();
}
}
The presentation of it is close to aero peek in windows 7.
Hope this helps.
Regards
|
|
|
|
|
Hi !
I think you didn't understand my question.
I want to display the IconImage on the top-left of the title .
For example,
trayIcon = new TrayIcon(icon, "Hello System Tray", menu);
must be change to
trayIcon = new TrayIcon(icon, "<img src="image.gif">Hello System Tray",menu);
if we can use html tags in our code !
Thanks anyways !
Can anybody help me ?
Best regards !
|
|
|
|
|
I understood your question, if you read my first line "If the trayicon class was a Jcomponent then we can use html tags". You can display (as a balloon) the message type error,info,etc... use these in place of the dialog code depending on type:
trayIcon.displayMessage("Title", "Message", trayIcon.INFO_MESSAGE_TYPE);
trayIcon.displayMessage("Title", "Message", trayIcon.NONE_MESSAGE_TYPE);
trayIcon.displayMessage("Title", "Message", trayIcon.WARNING_MESSAGE_TYPE);
trayIcon.displayMessage("Title", "Message", trayIcon.ERROR_MESSAGE_TYPE);
otherwise what your asking can only be done if you write your own package.
Regards
|
|
|
|
|
If using a JDialog or JFrame or JPanel to display an image(instead of the tooltip of TrayIcon) i think it is very simple and i didn't post my question.
I posted this question because i saw the "beautiful tooltip" of trayIcon of windowXP "your computer might be at risk". The Iconimage of the tooltip is not in (WARNING,INFO,ERROR,NONE) images.
I'm waiting for a solution for this because Microsoft did it !
Any other ideas ?
Best regards !
modified on Friday, September 11, 2009 12:42 AM
|
|
|
|
|
I was cruising around to see if their is any third party packages that can do what your asking and I stumbled upon an article on codeproject.com but its not in Java its using windows pressentation foundation but it does exaclty what you ask:
http://www.codeproject.com/KB/WPF/wpf_notifyicon.aspx
All you need now is to get Visual C# express and get the risk icon (what i did in windows 7 rc go to windows firewall and click on turn of firewall you will get the red x snap it using the snap tool and go to photoshop to do some editing and you can then save it as 16 x 16 icon and name it Inactive.ico) then copy it and place it in the c:\...wpf-notifyicon\Sample Project\Icons folder, then rebuild the code and run, you will find at the bottom right corner custom notification message.
Hope this helps. I will try to ask sun about it but you said it your self Microsoft did it with their language not Java
Regards
|
|
|
|
|
Thank you for a clear solution from Microsoft Tech.
Im Still waiting for your "asking result" from Sun.
Best regards !
|
|
|
|
|
i want to develop a software by which once can remotely access one system, the program should be such that is should be platform independent, as in, a apple system can remote login a ubuntu system and the controls for the mouse, screen and board is transferred.
Also let me know, how to enable which port in that case, as port is dependent on the operating system as in 3389 for windows, 5900 for ubuntu i guess, any pointers for that.
Please let me know.
Regards
Ashish
|
|
|
|
|
These will do the job
http://sourceforge.net/projects/jrdesktop/
https://jxta-remote-desktop.dev.java.net/
http://jrdesktop.sourceforge.net/
http://www.codeproject.com/KB/IP/RemoteAdminJava.aspx
http://kenai.com/projects/jrdesktop
http://java-hush.sourceforge.net/prot-1.5.html which is from http://java-hush.sourceforge.net/
They have all the resources you need.
Good Luck
|
|
|
|
|
|
0. Remove you're e-mail address - it's a big invite to the Vikings.
1. Have you tried some diagnostics? Put some logging into your code and find out where things are going Lady Gaga, then post a nice little snippet to show what's gone wrong with an explanation of what you tried.
2. ??
3. Profit.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Sending an Email in Java (Servlet)
Prerequisites:
1. Java Mail API (mail.jar)
2. activation.jar
3. HTML Form (Optional)
4. Servlet or JSP (to send the email)
Steps:
1. Download and install JDK6U16
2. Download Apache Tomcat
3. Download Eclipse
4. In Eclipse, make sure to add the apache server first
5. Create a dynamic web project
6. Under the WEB-INF create a folder called lib and paste mail.jar and activation.jar
7. Create a jsp and call it index.jsp
8. Create a servlet and call it sendMail
9. Create a class called MyPasswordAuthenticator (will act as authentication or you can use the code inside the sendMail as you like)
10. Create two jsps (success and error)
11. Create a css file called style
index.jsp Code:
<html>
<head>
<title>Sending email</title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<center>
<form action="sendMail" method="get">
<table>
<tr>
<td>From</td>
<td><input type="text" name="from"></td>
</tr>
<tr>
<tr>
<td>To</td>
<td><input type="text" name="to"></td>
</tr>
<tr>
<td>Subject</td>
<td><input type="text" name="subject"></td>
</tr>
<tr>
<td>Message</td>
<td><textarea cols="25" rows="8" name="message"></textarea></td>
</tr>
</table>
<br>
<input type="submit" value="submit">
</form>
</center>
</body>
</html>
style.css
* { font-size: 12px; font-family: Verdana }
input, textarea { border: 1px solid #ccc }
textarea { text-align:left}
table { margin-top: 10% }
.error { margin-top: 10%; border: 1px dotted #db1f1f; width: 250px }
.msg { margin-top: 10%; border: 1px dotted #ccc; width: 250px }
sendMail Servlet
import java.util.Properties;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class sendMail extends HttpServlet
{
public void doGet(HttpServletRequest req, HttpServletResponse resp)
{
String username = "your gmail account";
String password = "your gmail password";
Properties props = new Properties();
props.put("mail.smtp.host", "smtp.gmail.com");
props.put("mail.smtp.starttls.enable", "true");
Session session = null;
if (username != null && password != null)
{
props.put("mail.smtp.auth", "true");
session = Session.getInstance(props, new MyPasswordAuthenticator(username, password));
}
else
{
session = Session.getDefaultInstance(props, null);
}
MimeMessage message = new MimeMessage(session);
try
{
message.setFrom(new InternetAddress(req.getParameter("from")));
InternetAddress[] address = InternetAddress.parse(req.getParameter("to"), false);
message.setRecipients(Message.RecipientType.TO, address);
message.setSubject(req.getParameter("subject"));
message.setText(req.getParameter("message"));
Transport.send(message);
RequestDispatcher d = req.getRequestDispatcher("success.jsp");
d.forward(req, resp);
}
catch (Exception e)
{
try
{
RequestDispatcher d = req.getRequestDispatcher("error.jsp");
d.forward(req, resp);
}
catch (Exception e2) {}
}
}
}
MyPasswordAuthenticator
import javax.mail.Authenticator;
import javax.mail.PasswordAuthentication;
class MyPasswordAuthenticator extends Authenticator
{
String user;
String pw;
public MyPasswordAuthenticator (String username, String password)
{
super();
this.user = username;
this.pw = password;
}
public PasswordAuthentication getPasswordAuthentication()
{
return new PasswordAuthentication(user, pw);
}
}
success.jsp
<html>
<head>
<title>Message</title>
</head>
<body>
<center>
<div class="msg">
<h2>Message</h2>
<p>
Email sent
</p>
</div>
</center>
</body>
</html>
error.jsp
<html>
<head>
<title>Error</title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<center>
<div class="error">
<h2>Error</h2>
<p>
Message: <%= request.getAttribute("ErrorMessage") %>
</p>
</div>
</center>
</body>
</html>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>SendingEmail</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<description></description>
<display-name>sendMail</display-name>
<servlet-name>sendMail</servlet-name>
<servlet-class>sendMail</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>sendMail</servlet-name>
<url-pattern>/sendMail</url-pattern>
</servlet-mapping>
</web-app>
Make sure to put your gmail username and password in sendMail servlet
Next run index.jsp
Good luck
modified on Tuesday, September 8, 2009 7:35 PM
|
|
|
|