|
Hi
This is suman.
we are using spring with Hibernate in to my application,but we want to implenting jasyptHibernateEncryptorin in to my application.
its working fine when storing a new entry into database table and fetching the same entry,
but problem here its how to encrypt my old data.
can you please any one help me , ASAP
|
|
|
|
|
Hi,
Is there any way to read the current time zone of the operating system? I need to check it to see if it has been updated.
I have to do this every minute, without restarting the application and without launching an external process.
Thank you very much for your attention.
|
|
|
|
|
Try the following:
TimeZone tz = Calendar.getInstance().getTimeZone();
System.out.println(tz.getDisplayName());
System.out.println(tz.getID());
Note that an application can set its own time zone, independently of the system.
Veni, vidi, abiit domum
|
|
|
|
|
Thank you Richard. But try this and you will see what I mean:
TimeZone tz = Calendar.getInstance().getTimeZone();
System.out.println(tz.getDisplayName());
System.out.println(tz.getID());
tz = Calendar.getInstance().getTimeZone();
System.out.println(tz.getDisplayName());
System.out.println(tz.getID());
The time zone is set at the beginning of the current JVM process. It is subsequently detached from the system time zone and it sadly seems that there is no orthodox way to reattach it...
Bogdan Rechi.
|
|
|
|
|
The timezone setting is part of the environment of every process and is set at the time the process is started. I cannot see any way to tell when it changes apart from some system process that can hook into the operating system in some way. Sorry.
Veni, vidi, abiit domum
|
|
|
|
|
From the other responses....
Windows has the following command line utility
tzutil.exe
It has an option '/g' which returns the current timezone.
You use java.lang.Process to run it and collect the results.
|
|
|
|
|
Just note that a process inherits the environment from its parent process - and when the time zone is part of the environment, then tzutil will report the time zone of the application it was started from, which may be different from the time zone of the system.
|
|
|
|
|
Bernhard Hiller wrote: Just note that a process inherits the environment from its parent process
I just tried the following
- Open a console window
- Run tzutil to report current TZ
- Leave console window running.
- Change the TZ using the tray applet
- In the same console window above use tzutil again
- It reports the new TZ.
The documentation also states that tzutil updates the TZ in the registry. Which wouldn't be an environment update. So that suggests that in terms of reporting it would report from the same source and not from the environment.
|
|
|
|
|
Thanks for that information.
|
|
|
|
|
Unfortunately that only works for a new execution of a program, e.g. tzutil. I just tried it with a running Java application, and the app did not see the change of timezone.
Veni, vidi, abiit domum
|
|
|
|
|
Not exactly sure what you mean.
My suggestion was that one needs to run tzutil from the java application via Process. One would need to run it each time one wanted an update.
You tried that and it didn't work?
|
|
|
|
|
jschell wrote: My suggestion was that one needs to run tzutil from the java application via Process. And it works as you described.
Veni, vidi, abiit domum
|
|
|
|
|
Hi, I have a code that just won't work and I can't figure out why.
It's supposed to go to a survey page and fill in radio buttons randomly. For instance a survey with 100 questions, 6 per question. It fills in one question. For some reason my Aunt really needs this? Any thought?
function randomFromTo(from, to) {
return Math.floor(Math.random() * to) + from;
}
function autoFill() {
var radioList = [];
for (var i = 0; i < document.forms.length; i++) {
for (j = 0; j < document.forms[i].length; j++) {
if (document.forms[i].elements[j].type == "radio") {
if(typeof radioList[document.forms[i].elements[j].name.substring(0, 10)] == 'undefined') {
radioList[document.forms[i].elements[j].name.substring(0, 10)] = [];
}
radioList[document.forms[i].elements[j].name.substring(0, 10)].push(document.forms[i].elements[j].id);
}
}
}
for (var radio in radioList) {
var rand = randomFromTo(0, radioList[radio].length-1);
document.getElementById(radioList[radio][rand]).checked = true;
}
}
window.onload = function(){
autoFill();
};
|
|
|
|
|
This is the Java forum, but your code looks like Javascript to me.
Veni, vidi, abiit domum
|
|
|
|
|
what is the database for a sudoku game??
|
|
|
|
|
|
Right now with this code showing label inside the text box
I want to use the content pane for giving space in between then .
void InboundCheque()
{
printbtn.setVisible(false);
SpringLayout groupL = new SpringLayout();
Inbound.setLayout(groupL);
Inbound.add(chqlbl);
Inbound.add(chqstartingdate);
}
|
|
|
|
|
I'm developing a multiplatform systems peer to peer LAN Mesengger, here I have a problem to save the chat history and message broadcast. please tell me the solution about it?
thank you
|
|
|
|
|
Member 10567150 wrote: I have a problem to save the chat history and message broadcast. please tell me the solution about it? Unless you explain your problem in clear detail it is not possible to offer you a solution.
Veni, vidi, abiit domum
|
|
|
|
|
previously would reply thanks for my question, I am a graduate student, I'm writing his thesis entitled S1 multiplatform peer to peer lan messenger is where I was required to have 4 service features such as chat rooms, chat one by one, file transmission and broadcast messages, I 've membat 2 yes it features transmission pembinbing files and chat and I require the charge in my sekripsi no chat history nah I confused on the chat history and implementing the broadcast message and what difference it makes chat rooms and chat one by one? thanks for willing to help
|
|
|
|
|
I have had difficulty with that translation. But it seems to me this is more about researching subjects for your thesis than actual programming help, and that is a bit more than we can provide in this forum.
Veni, vidi, abiit domum
|
|
|
|
|
do you think I should do? and what should I do or do? I've been confused by this thesis with pemrogam and coding,, please its support?
|
|
|
|
|
|
I tired this code for converting RGB image to Ycbcr but it doesnt work this code also contain to covert RGB to Grayscale
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.io.*;
import javax.swing.*;
import java.awt.image.*;
import javax.imageio.ImageIO;
public class Picture{
JFileChooser fileChooser = new JFileChooser();
final JFrame frame = new JFrame("Edit Image");
Container content;
static BufferedImage image;
BufferedImage image2;
JLabel imageLabel;
public Picture() {
//asks for image file as input
fileChooser.setDialogTitle("Choose an image file to begin:");
fileChooser.showOpenDialog(frame);
File selectedFile = fileChooser.getSelectedFile();
if (fileChooser.getSelectedFile() != null) {
try {
//reads File as image
image = ImageIO.read(selectedFile);
}
catch (IOException e) {
System.out.println("Invalid image file: " + selectedFile);
System.exit(0);
}
}
else {
System.out.println("No File Selected!");
}
}
public int width() {
//returns width of present image
int width = image.getWidth();
return width;
}
public int height() {
//returns height of present image
int height = image.getHeight();
return height;
}
/*
public void getImage() {
this.image = image2;
}
*/
public void saveImage() {
//saves current image as JPEG
fileChooser.setDialogTitle("Save this image?");
fileChooser.showSaveDialog(frame);
try {
//writes new file
ImageIO.write(this.image, "JPG", fileChooser.getSelectedFile());
}
catch (IOException f) {
System.out.println("Saving failed! Could not save image.");
}
}
public void show() {
//set frame title, set it visible, etc
content = frame.getContentPane();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setResizable(false);
//add the image to the frame
ImageIcon icon = new ImageIcon(image);
imageLabel = new JLabel(icon);
frame.setContentPane(imageLabel);
//add a menubar on the frame with a single option: saving the image
JMenuBar menuBar = new JMenuBar();
frame.setJMenuBar(menuBar);
JMenu progName = new JMenu("Edit Image");
progName.setBackground(Color.RED);
menuBar.add(progName);
JMenu fileMenu = new JMenu("File");
menuBar.add(fileMenu);
JMenu editMenu = new JMenu("Edit");
menuBar.add(editMenu);
ImageIcon exitIcon = new ImageIcon("app-exit.png");
JMenuItem exitAction = new JMenuItem("Exit", exitIcon);
progName.add(exitAction);
exitAction.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ImageIcon saveIcon = new ImageIcon("save-icon.png");
int askSave = JOptionPane.showConfirmDialog(null,"Save current image?", "", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, saveIcon);
if (askSave == JOptionPane.YES_OPTION) {
//opens save image method, then exits
saveImage();
System.exit(0);
}
else {
//exits without saving
System.exit(0);
}
}
});
ImageIcon newIcon = new ImageIcon("new-image.png");
JMenuItem newAction = new JMenuItem("Open Image", newIcon);
fileMenu.add(newAction);
newAction.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ImageIcon saveIcon = new ImageIcon("save-icon.png");
int askSave = JOptionPane.showConfirmDialog(null,"Save current image?", "", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, saveIcon);
if (askSave == JOptionPane.YES_OPTION) {
//opens save image method, then asks asks for new image file
saveImage();
Picture p = new Picture();
imageLabel.setIcon(new ImageIcon(image));
//resizes canvas to fit new image
frame.setSize(width(), height());
}
else {
//asks for new image file since user did not want to save original
Picture p = new Picture();
imageLabel.setIcon(new ImageIcon(image));
//resizes canvas to fit new image
frame.setSize(width(), height());
}
}
});
ImageIcon saveIcon = new ImageIcon("save-image.png");
JMenuItem saveAction = new JMenuItem("Save Image As...", saveIcon);
fileMenu.add(saveAction);
saveAction.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//opens save image method
saveImage();
}
});
ImageIcon gsIcon = new ImageIcon("grayscale-image.png");
JMenuItem grayScale = new JMenuItem("Grayscale", gsIcon);
editMenu.add(grayScale);
grayScale.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//grabs height and width of image, then grayscales it
grayscale(width(), height());
}
});
ImageIcon ycrbIcon = new ImageIcon("ycrcb-image.png");
JMenuItem ycrb = new JMenuItem("YCrCB", ycrbIcon);
editMenu.add(ycrb);
ycrb.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//RGB
int height=height();
int width=width();
getRGB_YCC( width,height,image);
}
});
ImageIcon scaleIcon = new ImageIcon("scale-image.png");
JMenuItem scaleImg = new JMenuItem("Scale Image", scaleIcon);
editMenu.add(scaleImg);
scaleImg.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//asks for height and width to create new image
ImageIcon widthIcon = new ImageIcon("LR-arrows.png");
String scaleWidth = (String)JOptionPane.showInputDialog(null,"What should the new width be?", "", JOptionPane.QUESTION_MESSAGE, widthIcon, null, null);
ImageIcon heightIcon = new ImageIcon("UD-arrows.png");
String scaleHeight = (String)JOptionPane.showInputDialog(null,"What should the new height be?", "", JOptionPane.QUESTION_MESSAGE, widthIcon, null, null);
//turns user input strings into doubles
double x = Double.parseDouble(scaleWidth);
double y = Double.parseDouble(scaleHeight);
//casts doubles as ints
int newWidth = (int)x;
int newHeight = (int)y;
//resizes frame to fit new image dimensions
frame.setSize(newWidth, newHeight);
//calls scale method to resize image using given dimensions
scale(newWidth, newHeight);
}
});
ImageIcon rotateIcon = new ImageIcon("rotate-image.png");
JMenuItem rotateImg = new JMenuItem("Rotate Image", rotateIcon);
editMenu.add(rotateImg);
rotateImg.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
//paint the frame
frame.pack();
frame.repaint();
frame.setVisible(true);
}
// convert to grayscale
public void grayscale(int width, int height) {
// create a grayscale image with original dimensions
image2 = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_GRAY);
// convert colored image to grayscale
ColorConvertOp grayScale = new ColorConvertOp(image.getColorModel().getColorSpace(),image2.getColorModel().getColorSpace(),null);
grayScale.filter(image,image2);
imageLabel.setIcon(new ImageIcon(image2));
//getImage();
image = image2;
}
// convert to ycrcb
/* public void rgbycbcr()
{
int r=255,g=255,b=255;
int h=height();
int w=width();
int total_pixels = (h * w);
Color[] colors = new Color[total_pixels];
int i = 0;
for (int x = 0; x < w; x++)
{
for (int y = 0; y < h; y++)
{
colors[i] = new Color(image.getRGB(x, y));
i++;
}
}
for (i = 0; i < total_pixels; i++)
{
Color c = colors[i];
r = c.getRed();
g = c.getGreen();
b = c.getBlue();
}
//rgb2ycbcr(int r,int g,int b, int[] ycbcr)
//{
int [] ycbcr={255,255,255};
int y = (int)( 0.299 * r + 0.587 * g + 0.114 * b);
int cb = (int)(-0.16874 * r - 0.33126 * g + 0.50000 * b);
int cr = (int)( 0.50000 * r - 0.41869 * g - 0.08131 * b);
ycbcr[0] = y;
ycbcr[1] = cb;
ycbcr[2] = cr;
//}
}*/
public void getRGB_YCC(int width,int height,String inFileName) {
R=new int[height][width];G=new int[height][width];
B=new int[height][width];Y=new int[height][width];
Cb1=new int[height][width];Cr1=new int[height][width];
final int values[] = new int[width * height];
int r, g, b, Y_ch,Cb,Cr, y, x;
final PixelGrabber grabber = new PixelGrabber(image.getSource(), 0, 0,width,height, values, 0, width);
try {
if (grabber.grabPixels() != true) {
try {
throw new AWTException("Grabber returned false: " + grabber.getStatus());
} catch (final Exception e) {};
}
} catch (final InterruptedException e) {};
int index = 0;
for (y = 0; y < height; ++y) {
for (x = 0; x < width; ++x) {
r = values[index] >> 16 & 0xff;
g = values[index] >> 8 & 0xff;
b = values[index] & 0xff;
Y_ch= (int)(0.299 * r + 0.587 * g + 0.114 * b);
Cb= 128 + (int) (-0.16874 * r - 0.33126 * g + 0.5 * b);
Cr= 128 + (int)(0.5 * r - 0.41869 * g - 0.08131 * b);
R [y][x]=r;
G [y][x]=g;
B [y][x]=b;
Y [y][x]=Y_ch;
Cb1[y][x]=Cb;
Cr1[y][x]=Cr;
index++;
}
}
BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
int[] pixels = ((DataBufferInt)img.getRaster().getDataBuffer()).getData();
for( y=0;y
|
|
|
|
|
This is the third time you have posted this question; please post only once. Also it is very difficult to read unformatted code blocks. Please edit your question, indent your code properly and add <pre> tags around it so it looks like:
try {
if (grabber.grabPixels() != true) {
try {
throw new AWTException("Grabber returned false: " + grabber.getStatus());
} catch (final Exception e) {};
Note that your null catch clause in the above is not good practice as it means you will ignore all the errors that get thrown.
Also you need to do some diagnosis of your own on this and explain to us what results you expect, what results you actually get, and where in the code the problems occur.
Veni, vidi, abiit domum
|
|
|
|
|