How to get real path of an image in Java?

Can someone help with my java code?

  • Well im very very new to java programming and i really need some help. i was finally able to create my own program and my teacher is very proud of me but he wants me to make it a little better in the GUI. so i did some research and found this program that really helps with with building a GUI. but is there anyway to implement my own source code with this new code? Source code: import java.awt.*; import java.io.IOException; public class GUImath extends EasyApp { public static void main(String[] args) throws IOException { new GUImath(); } TextField answerBox = addTextField(" Please enter the path of the command",50,100,300,40,this); Button GO = addButton("GO!",160,200,50,40,this); public GUImath() throws IOException { setTitle("BETA 0.0.5"); setSize(400,300); answerBox.setFont(new Font("Ariel",0,15) ); } public void actions(Object source,String command) { if (source == GO) { try { GO(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } public void GO() throws IOException { Runtime CMD = Runtime.getRuntime(); String text = answerBox.getText(); CMD.exec(text ); } } New code (GUI): import java.awt.*; import java.awt.event.*; import java.applet.Applet; import javax.swing.*; public class Test2 extends Applet { JButton Go; JTextField Enter; public void init() { Test2Layout customLayout = new Test2Layout(); setFont(new Font("Helvetica", Font.PLAIN, 12)); setLayout(customLayout); Go = new JButton("go"); add(Go); Enter = new JTextField("Enter"); add(Enter); setSize(getPreferredSize()); } public static void main(String args[]) { Test2 applet = new Test2(); Frame window = new Frame("Test2"); window.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); applet.init(); window.add("Center", applet); window.pack(); window.setVisible(true); } } class Test2Layout implements LayoutManager { public Test2Layout() { } public void addLayoutComponent(String name, Component comp) { } public void removeLayoutComponent(Component comp) { } public Dimension preferredLayoutSize(Container parent) { Dimension dim = new Dimension(0, 0); Insets insets = parent.getInsets(); dim.width = 320 + insets.left + insets.right; dim.height = 240 + insets.top + insets.bottom; return dim; } public Dimension minimumLayoutSize(Container parent) { Dimension dim = new Dimension(0, 0); return dim; } public void layoutContainer(Container parent) { Insets insets = parent.getInsets(); Component c; c = parent.getComponent(0); if (c.isVisible()) {c.setBounds(insets.left+104,insets.top+… c = parent.getComponent(1); if (c.isVisible()) {c.setBounds(insets.left+104,insets.top+… } } Essentially what my source code does is Runs a .exe if the path is written correctly and allows you to run it from the program. and i just want to know if there would be a way to implement that runtime code into the GO Variable and allow it to call a runtime? Also if someone can also help me with making a drop down box of "Previously used paths"? that would be a god send!. thank you for any help and i really hope i can get this program up and running. (it's my very first ever program!)

  • Answer:

    Well im very very new to java programming and i really need some help. i was finally able to create my own program and my teacher is very proud of me but he wants me to make it a little better in the GUI. so i did some research and found this program that really helps with with building a GUI. but is there anyway to implement my own source code with this new code?

abraham at Yahoo! Answers Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.