Japplet Open File - Zoom In And Out Buttons For Pictures

Dec 16, 2014

I am trying to make a japplet that has open, zoom in and zoom out buttons for pictures. I am not sure how to go about an open button that will read the file. I have the picture url hard coded in the file to open but would like an open button with a file/folder dialogue.

This is what I have so far

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.event.ActionEvent;

[Code] ......

View Replies


ADVERTISEMENT

Java Applet - Open / Zoom In / Out Of Image

Jul 29, 2014

Working on an assignment for a class: Create a DESKTOP application that allows you to open an image file and enables you to zoom in on or out from an image. I believe all I need is too create an open button to open the actual image file, instead of the html link, this code is an example that the teacher provided.My current code:

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.net.URL;
import java.io.*;
import javax.imageio.*;

[code]....

how to add an open file button so I can search for the file and then open it into my program.

View Replies View Related

Applets :: Drawing Ovals And Rectangles In JApplet With Two Separate Buttons

Apr 15, 2014

I'm not exactly sure what the draw button is supposed to do specifically, all i know is that it is supposed to draw both rectangles and ovals. The problem I am having is that when ever I click Draw Rectangle, it draws rectangles jusst the way I want but when ever I click Draw Oval, the program keeps drawing rectangles. I've tried repaint and clearRect methods but I did not manage to get them to work. I'm not sure what the problem is right here, I just cannot get it to work. Is there anything you guys can see that might be causing this? It's always good to have a different person look at it then myself. Also, I'm trying to implement a boolean for draw oval but I don't know where to put the if then.

public void init() {
length = new JTextField(10);
width = new JTextField(10);
btnDraw = new JButton("Draw");
btnClear = new JButton("Clear");
btnDrawRectangle = new JButton("Draw Rectangle");
btnDrawOval = new JButton("Draw Oval");

[Code] .....

View Replies View Related

Unable To Read Input File When Adding Pictures To A JFrame

Aug 25, 2014

i've tried changing the path 10000 times. idk if its wrong in the code.

Java Code: import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

[Code]...

View Replies View Related

HTML File - JApplet Content Blocked

Feb 6, 2014

I just created an applet that I want to call from a html file.

The applet code looks like this (and works):

package jav12;
 
import java.awt.*;
import javax.swing.*;
public class Welcome extends JApplet {
public Welcome(){
}
public void init() {
getContentPane().add(new Label("Yessss it works",Label.CENTER));

[Code] ....

When I click on the html file the content of the page is blocked and the applet isn't loaded. What can I do to fix this. I think it has something to do with rights. This is a crosspost to JApplet content blocked

View Replies View Related

Cannot Open Jar File In Eclipse

Feb 27, 2015

i have an older file I was working on 2 months ago and when i try to open it in eclipse I get a message corruption error. I know this is not possible since I was just working on it a while back, and it's the same program version as what i am currently using..Or would I do a file import instead?

View Replies View Related

JSP / JSTL :: How To Open CHM File

Sep 13, 2012

Is there a way we can open a .chm file stored at server through jsp application without downloading the file and saving it to the local machine.

What I googled is : we cannot download .chm files from a web browser and simply click Open.  Download the .chm file to your computer first, right-mouse click it in Windows Explorer and select Properties.  Then click Unblock.

But I want my users to simply view the file without downloading it.

View Replies View Related

How To Open Random Input File

Oct 30, 2014

i dont know how to write main that would open the input file and read using this method...

[/package AssignmentSeven;
import java.io.*;
import java.util.Scanner;
public class Assignment7
{
public static void Towers(int nTowers, int fromTower1, int workTower2, int toTower3) {
if(nTowers == 1)

[code].....

View Replies View Related

Create A Jar File That Would Open 3 Other Jar Files

Jan 13, 2015

I was just wondering how would I create a jar file that would open 3 other jar files when I open the jar file with my batch file it and when I type stop in the batch file it will out put the stop command into all 3 of the other jar files.

This is for my Minecraft server so I can launch them all at the same time and inStead of having to enter the commands in all the server batch files I just have to do the command in 1 I know their is things like multi craft to do this but I want the code so I don't have to use multicraft.

View Replies View Related

Code To Open Up TXT File And Display Only First Five Lines?

Apr 7, 2013

I am trying to write a java code for a homework problem in my intro java class but im having problems. This is the problem:

Write a program that open the MyFile.txt and read from a file with these criteria.

1)-The program should display the first five lines of the file’s contents only.

2)-If the file contains less than five lines, it should display the file’s entire content. You must check for end of file and less than 6 lines on the loop iterations.

3)- your program should use loop to read the line by line of the file MyFile.txt.

The serperate myfile.txt has this

I can still remember, at the end of that year, we sat for the last time in our circle together. She played us her favorite song, "like a bridge over troubled water" and quietly passed out a gift she had made for each of us.She had made each of us a pottery heart with our name and the date on it on the back each read "I believe in ME".We all cried including her. She told us she would always remember US. We believed she would.

and this is what the code is suppose to look like after you run it : Java33.png

And this is what i have so far : Java22.png

what needs to go next to complete the javascript to show the first 5 lines of the text files?

View Replies View Related

JSP :: Excel Unable To Open Downloaded File

Aug 1, 2014

In jsp, In windows 7 , IE 11 , I am able to get the downloaded file but still unable to open it.

View Replies View Related

Errors When Attempting To Open New Build Jar File

Nov 2, 2014

I have recently taken up some java after a period of time learning batch scripting. the issue I have run into is that my build compiled and ran just

fine when invoking from within the netbeans IDE but after that I 'cleaned and built' the jar and the IDE stored it in the directory that I specified while installing.

I went to that folder, double clicked on my gui and go nothing. So then I opened a command prompt did, "java -jar myapp.jar" and got the following of which has me completely lost:

Exception in thread "AWT-EventQueue-0" javax.persistence.PersistenceException: No Persistence provider for EntityManager named

at javax.persistence.Persistence.createEntityManagerF actory(Persistence.java:85)
at javax.persistence.Persistence.createEntityManagerF actory(Persistence.java:54)
at my.numberaddition.NumberAdditionUI.initComponents( NumberAdditionUI.java:31)
at my.numberaddition.NumberAdditionUI.<init>(NumberAd ditionUI.java:18)

[Code] ....

View Replies View Related

Use 2D Array To Layout Map With Pictures

Jun 2, 2014

I'm making a Pacman look-a-like game, now I'm making the map out of an 2D array (as a grid). I already initialized the 2d array spots with "0" and "1". I managed to do this but now I'm stuck.

I want to use the "0" and "1" to print the map. For example the "0" are grass and the "1" are walls. The map should be printed within a JFrame. And I would like to make the width and height 32x32 pixels.

I searched on the internet and i found a couple of example codes but non of it seems to work properly. This is the code I'm using to make the 2D array and initialize the spots.:

public class Level1 extends javax.swing.JFrame{
final int ROWS = 17;
final int COLS = 17;
int[][] field = new int[ROWS][COLS];
public Level1() {
initComponents();
setLocationRelativeTo(null);

[Code] .....

View Replies View Related

Adding Pictures To Button

May 18, 2014

I want to add a picture to my buttons. The end statement will be a path finding algorithm that will with show the picture on all the buttons on the shortest path. I am using a constructor at the moment passing a picture object to it. It is suppose to work but its not on line 30...

Java Code:

import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.*;
public class Screen implements ActionListener {
public JButton[][] b=new JButton[20][20];

[Code] ....

View Replies View Related

Tic Tac Toe With GUI Using JButtons That Will Hold X And O Pictures

Jan 8, 2015

I am in the process of creating a Tic Tac Toe game with a GUI using JButtons that will hold the X and O pictures. I have the picture appearing when i click it once but it jumbles up all the other buttons which is why i have to run the method resetAllButton() to set everything back. Once i click the x again it puts everything back how it is supposed to be and works normal. How can i get this to work in one click.

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class TicTacToeGui extends JFrame implements ActionListener {

[Code] .....

View Replies View Related

PDF Viewer / Zoom / Editor?

Jun 27, 2014

I am starting a project of a little game for my brother and I wanted to know whether a few things were possible using Java (I know the basics and am currently learning more, but I have about a year to complete this so I have time to learn what is needed).What I need to be able to do:Be able to view a PDF as well as zoom in and pan around itBe able to enter/edit text in said PDF fileBe able to hide some of the text in this PDFBe able to do this on several PDFs in one program (They won't be open at the same time)

Is it possible to do this in Java? If so, how? (As in, what things would I need to learn or what would I need to complete it)If it makes my question easier, what it will be is a London Underground Tube Map (Which is a PDF file)where some station names disappear and the player has to guess which station(s) are missing.

View Replies View Related

Swing/AWT/SWT :: How To Zoom JtextPane

Jan 9, 2014

How to zoom the following jtextpane

package openurdu.page;

import java.awt.Color;
import java.awt.ComponentOrientation;
import java.awt.EventQueue;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.RenderingHints;

[code]....

View Replies View Related

Excel Cannot Open File Because Format Or Extension Is Not Valid

Apr 6, 2015

I am currently working on an application with java and I want to do is upload and download details in .xlsx file. Uploading process is successfully worked but the problem is that when I download the file .xlsx with details at opening the file it gives me the following message :

Excel cannot open the file '(filename)'.xlsx' because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file.

View Replies View Related

Open A File And Store Contents Into A Two Dimensional Array

Feb 11, 2014

So I am trying to open a file and store the contents into a two dimensional array. I seem to have no problem using this same basic code to read the file and output it. But when I try to change it so that all the data is stored into the array, it does not work.

Java Code:

public void convertFile()
{
String filePath = ("C:UsersBradDownloadsFB1.csv");
String [][] rowCol = new String [429][6];
try
{
BufferedReader br = new BufferedReader(new FileReader(filePath));
StringTokenizer st = null;
System.out.println("Your file is being converted to an array. This may take several minutes.");

[code]....

View Replies View Related

JSF :: How To Open A File / Folder Directories In Firefox Browser

Jun 15, 2014

In our currenr project we have a requirement to open a local/network driver file/folder using JSF 2.0 <h:outputLink> in Firefox browser find the below sample code & correct it, how to achieve the above requirment

Sample.xhtml
<h:form>

<h:outputLink id="linkID" value="#{demoDataBean.dataLink}" target="_blank" >
<h:outputLabel value="#{demoDataBean.dataLink}" />
</h:outputLink>

[code]...

View Replies View Related

Use FileInputStream To Open A File That Contains Name Of User Favorite Book And Then Displays It

Aug 9, 2014

I'm working on a problem where I have to use the FileInputStream to opens a file that contains the name of a user's favorite book and then displays it.

If the file doesn't exist, then I prompt for the book title and write it to the file using FileOutputStream. This is what I have so far but I'm lost because if I put a file that exists in line 8 then it closes, but if I don't and the user puts their favorite book nothing happens. Or, as far as I can tell nothing does.

import java.io.*;
class DisplayBook {
public static void main(String[] args)

[code]....

View Replies View Related

JavaFX 2.0 :: JFreeChart - When Zoom In Or Out Repaint Works Not Well

May 8, 2015

I have a problem using JFreeChart with JavaFX. I wrote a small program here . At first the graph likes this:

I use fullScreen function to display the JFreeChart Line Chart Demo 2. Here I use SwingNode, ChartPanel to embedded JFreeChart into JavaFX Panel.(Detail part will be included in code later)

Then I press ESC to exit fullScreen. Then it looks like this:

So far, it's as expected. Then I use mouse drag to enlarge the window. Here comes the problem, as the following picture.
 
Can you see that, seems like appear another graph. And I must click on the window, then everything will become good. I wish the graph shows well even when I drag the window to enlarge, is there something I missed? And here is my code:

package testxychart; 
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

[Code] ....

I think, when I use several graphs in one JavaFX Panel, this will becomes a big problem.

View Replies View Related

Servlets :: Submit Buttons In JSP File

Apr 30, 2014

A user can dislike/like a topic. However I have to submit buttons in my jsp file, the issue is that when a user presses like/dislike it should print out on the consile line. It does that perfectly but it prints out both when it should only print out either like or dislike.

My JSP code:

<form name = "ViewTripServlet" action="ViewTripServlet" method="post">

</br>
</br>
</br>
<input type="image" name = "like" value="submit" src=images/like.png onMouseOver="this.src='images/like.png'">
</br>
</br>
</br>
<input type="image" name = "dislike" value="submit" src=images/dislike.png onMouseOver="this.src='images/dislike.png'">

</form>

Servlet Code:

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
ViewTri vT = new ViewTrip();
vT.user_like(request.getParameter("like"));

vT.user_dislike(request.getParameter("dislike"));

[code]....

View Replies View Related

JApplet Is Not Running Smoothly?

Jun 11, 2014

I've got a problem with my home made game. When I created it as a JFrame application it runs smoothly, but when I tried to convert it to a JApplet the graphic is "lagging". I can see the graphics blinking/flashing .....

Here is the code:

public class FallingBalls extends JApplet implements KeyListener,
ActionListener {
// VARIABLES //
boolean gameOver;
boolean win;
// Buttons
JButton start, pause, restart;
// Character "The Runner" (32px x 32 px)

[code]....

View Replies View Related

JApplet Content Blocked

Feb 6, 2014

I just created an applet that I want to call from a html file.The applet code looks like this (and works):

Java Code:

package jav12
import java.awt.*;
import javax.swing.*;
public class Welcome extends JApplet {
public Welcome(){

[code]...

When I click on the html file the content of the page is blocked and the applet isn't loaded. URL...

View Replies View Related

Adding Image To JApplet In A Browser

Jun 12, 2014

I've got a problem with my applet when I run it in a browser (firefox mainly but nothing else is working neither). First of all, the program is "unsigned" according to firefox security system, but I don't think that's where to problem lies. When I start the applet (as an html application) it says:

AccessControlException

Then it says: Access denied ("java.io.FilePermission" "bla, bla, bla (img source on my harddrive)" "read")

How do I get this to work? This is the picture I'm trying to implement: [URL]...

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved