I made a little java game and if you beat it, it loads embarrassing pictures of my friends.
The problem is they can cheat and open the jar with WinRar and look at all the pictures.
How can I prevent this?
(This is with their consent. It's completely friendly.)
You could convert the image to a hexidecimal String and store it in a file without an extension inside the .jar file.
To make things even more difficult for them you could add a non-hexidecimal character into the text periodically and then remove that character from the String in your code before converting the text back into an image. That way, even if they recognize the text file as an image in text they wouldn't be able to convert it unless they spotted the extra illegal hex characters.
There is no way I know of to do that programmatically. However, what I would do is use an obscure format for the pictures (e.g. .tif, .ico), then name them things like library1.jar or data.dat. Last, add a lot of dummy files that have no purpose. This makes it hard for your friends to tell which files are pictures and how to view them.
Related
I am using a Vaadin 10 (Flow) Grid to stream data to new rows, and I am trying to add a custom image icon to my TemplateRenderer.
I have a TemplateRenderer setup like this:
TemplateRenderer<TradeUni> sizee = TemplateRenderer.<TradeUni>
of("<div class$=\"[[item.class]]\">[[item.size]]</div>")
.withProperty("class", cssClassProvider)
.withProperty("size", TradeUni::getSize);
Which displays my numbers correctly in the grid cell like this:
I would like to have my image rendered inside the same cell, to the left of the numbers.
This was my (very crude) attempt to import it using html:
TemplateRenderer<TradeUni> sizee = TemplateRenderer.<TradeUni>
of("<div class$=\"[[item.class]]\"><img src=\"i.imgur.com/3LQBglR.png\">[[item.size]]</div>")
.withProperty("class", cssClassProvider)
.withProperty("size", TradeUni::getSize);
Which give's me this:
I think that I might have to wrap the image and numbers into a HorizontalLayout with the image being a separate component - I think I could handle that, but I am unsure of how to do the actual rendering of the image. I can probably accomplish it simply with the internal Vaadin Icons set, but I need to use my own little images.. all icons that I am going to use will be at or less than 25 x 25px.
Thank you so much in advance!
I think you're on the right track, but there's one small detail that causes you trouble. The URL i.imgur.com/3LQBglR.png doesn't define a protocol, which means that the entire string will be treated as a path relative to the location of the hosting page. It will thus try to find a file in a directory named i.imgur.com on your own server.
To fix this, you need to also include the protocol in the image URL, i.e. https://i.imgur.com/3LQBglR.png.
I can also offer a small suggestion for how to make the code easier to read. HTML also supports using ' for enclosing attribute values. This is more convenient to use from Java string since you don't need to use \ to escape ' characters. Your template string could thus be "<div class$='[[item.class]]'><img src='https://i.imgur.com/3LQBglR.png'>[[item.size]]</div>".
Ok I can type into the JTextArea and save it to a file, however when I open the file in notepad for example it has no breaklines. When loaded back into my program the file has the breaklines again.
I want to know why this happens, whats the point why not just have it the same?
and how to make the format be the same when outputting to file so it is the same as it looks in the JTextArea.
In the JTextArea api I do not see any methods that give me any clue on how to do this.
Thanks!
Your version of Notepad is most probably not recognizing "unix" end of line sequences (also used/produced by some Java libraries). Try with another text editor. If I remember correctly, Wordpad makes a better job. If not this, you should post code and operating environment.
I can type into the JTextArea and save it to a file,
How are you saving the file?
In the JTextArea api I do not see any methods that give me any clue on how to do this
Use the textArea.write(...) method to save the file. It will save the file with the proper end of line string for the current platform you are using.
See Text and New Lines for more information.
I'm looking for a solution to this and I have searched the web for an answer with nothing. I need a scrolling message on my webpage that can be updated by the same website but on a different page. (e.g www.webpage.com <-- has the scrolling message on it, www.webpage.com/settings <-- has a form in which you can change/update the scrolling message)
I'm pretty sure this is achievable with Java, but my knowledge on Java is slim and all my efforts have come to a fail. I have managed to get a scrolling message on my webpage and I'm sure if I could read a text file (with the message in) then assign that to a 'var', I could make that scroll but I don't know how to do that.
If you know a completely different method of doing this I am happy to change mine.
Thanks in advance,
Tom.
I would recommend javascript instead of java, since java is not really conventional anymore and looks ugly too (and requires a special plugin).
It depends on how fast you want to update the scrolling text how you want to do this. I would say save the text to a .txt or database from settings, and then have your page get it.
You can then use php to read the value from the .txt file or database to display it on your website.
If you want it to be extremely up to date you can let javasript call a little .php file that reads the file and gives you the content.
To make your text scroll you don't really need anything other than html, like so:
<marquee behavior="scroll" direction="left">Your scrolling text goes here</marquee>
You can read more about that here: http://www.quackit.com/html/codes/scrolling_text.cfm
I have an word template. There is an word photo that has to be replaced with an image. This has to be done with Docx4Java.
How do I do this?
If specifically looking to replace a text with an image(which is not possible using docx4j as answered above), you can use replace bookmark with image as an alternative.
Just open your templated word file, position the cursor at desired location and insert->bookmark and name your bookmark.
I followed the instructions here to replace this bookmark with an image
Disclosure: I manage the docx4j project
The VariableReplace code doesn't handle images.
The best way to do this would be to use data bound content controls, specifically a picture content control pointing via XPath at a base-64 encoded image in an XML document (see Getting Started for details).
However, if you want to replace a word with an image, you can do so, but you'll have to write a bit of glue code. It is pretty straightforward.
First, find the word. You can do this using XPath or TraversalUtil (again, see Getting Started for details).
Hopefully it is in a run (w:r/w:t) by itself. If not, you'll need to split the run up so you don't replace adjacent text.
Then, add the image. See the sample ImageAdd.
I suggest you have a look at the XML created when you add an image in Word (ie save and unzip your docx, then look at document.xml). Take care that the XML representing the image is at the correct level (eg child of w:p).
everybody. I have completed my code two txt files by showing on the same area.
but I want to compare two txt files line by line. and I want to show the differences with Colored lines and finally, The letter or words that are different, different line I'm going to bold.
how can i start?
thanks for now, my code is here.
JTextArea might make a suitable view, but you still need to model the differences. I'd look at the Eclipse or NetBeans platforms, or perhaps svnview.
You might need to ask user to upload both versions of file.
In the server you need to compare line by line, and store the line numbers of the file differences in another file or location
Then, while displaying, get the line numbers and give them proper decoration (i.e bold etc.).