Java Forum / General / October 2006
Java Windows question..
JTapio - 10 Oct 2006 03:34 GMT Hei!
I have an homepage www.eurojari.net containing an applet runnable.. if i add an image to my applet witch has an question of yes or no 'shall we open a window' then, how to i: open fullscreen sized window ready to receive Graphics2D commands from my applet run()..
thank you for helping a relative new person on java, c is more familiar to me but net and java is quite a new.. very much thank you..
Yours : JariTapio Homepage : www.EuroJari.net EMail : JariTapio@EuroJari.net
Andrew Thompson - 10 Oct 2006 05:08 GMT ...
> I have an homepage www.eurojari.net containing an applet runnable.. ..hmmm. After visiting your homepage, and waiting several minutes for the multitude of images and resources to load, I saw a message about how this site was best viewed at some 'screen resolution', and left.
I realise you were not asking us to critique the homepage, but I will. Remove most of the images, or include tiny versions (in both WxH and bytes) on the homepage, but link to large versions.
Move the applet from the homepage, onto a page where the user is warned to expect to 'wait a few moment' for it to load, or better, load it using webstart in a free floating window.
Designing for a particular screen size fell out of fashion last millenium, make web sites for the users' screen size instead.
The bottom line of the web page (re., updates) has a typo.
> if i add an image to my applet witch has an question of yes or no 'shall we > open a window' then, > how to i: > open fullscreen sized window <sscce> import java.awt.*; import java.applet.*;
public class AppletWindow extends Applet { public void init() { Frame f = Frame.getFrames()[0]; Window w = new Window(f); w.setSize( Toolkit.getDefaultToolkit().getScreenSize() ); w.setVisible(true); } } </sscce>
>.... ready to receive Graphics2D commands from my > applet run().. Is this an Applet or JApplet?
Andrew T.
JTapio - 10 Oct 2006 14:38 GMT > ... >> I have an homepage www.eurojari.net containing an applet runnable.. [quoted text clipped - 3 lines] > I saw a message about how this site was best viewed at > some 'screen resolution', and left. my images are something like 80k - 90k .jpg format.. their temporary on my page, for my friends.. but, several minutes, man, ADSL is not that expensive anymore on these days, and trust me it is worth of that 19e a month what it costs.. thank you for the function, anyway..
> import java.awt.*; > import java.applet.*; [quoted text clipped - 8 lines] > } > }
> Is this an Applet or JApplet? i dont have that deep knowledge of Java, im more like c++, but i think your asking am i using a swing or awt applet.. i would love to keep it simple, so just fullscreen window ready to receive images and some shapes.. and that would be fine..
thank you..
Yours : JariTapio Homepage : www.EuroJari.net EMail : JariTapio@EuroJari.net
Andrew Thompson - 10 Oct 2006 14:50 GMT > > ... > >> I have an homepage www.eurojari.net containing an applet runnable.. [quoted text clipped - 3 lines] > > I saw a message about how this site was best viewed at > > some 'screen resolution', and left. ..
> my images are something like 80k - 90k .jpg format.. their temporary on my > page, for my friends.. So given we are not your friends, and you are after technical help, I will point out that..
> but, several minutes, man, ADSL is not that expensive anymore on these days, ..neither is help from a help desk, or e-lance, or any other number of sources of specialised help, whereas the advantage of posting to usenet is that help is not just cheap, it's *free*.
> and trust me it is worth of that 19e a month what it costs.. Wherever "e's" are considered currency, it is not here, and is not relevant to here, but even mroe importantly, you are suggesting I pay (extra) money, just to help you out, for free?!?
> thank you for the function, anyway.. Yeh..
> > Is this an Applet or JApplet? > [quoted text clipped - 3 lines] > images and some shapes.. > and that would be fine.. Ummm.. and how much were you offering for this piece of ('simple') specialist coding? (Read - 'See elance').
Andrew T.
JTapio - 10 Oct 2006 15:04 GMT Jep!
I think i need a good tutorial here, would please receive few links, in need to get familiar with window opening, sizening and drawing images on it..
Yours : JariTapio Homepage : www.EuroJari.net EMail : JariTapio@EuroJari.net
Michael Rauscher - 10 Oct 2006 15:19 GMT JTapio schrieb:
> Jep! > > I think i need a good tutorial here, > would please receive few links, in need to get familiar with window opening, > sizening and drawing images on it.. Jep,
http://java.sun.com/docs/books/tutorial/uiswing/index.html
Bye Michael
JTapio - 10 Oct 2006 17:03 GMT Hei!
Java Sun is quite a too heavy reading for me who dont that much have studiet foreign languages.. i need a some kind of a for dummies page or an advice in a post..
if i have an Applet start() stop() run() init () destroy() paint() on Opera browser..
well, i just need the SIMPLEST fullscreen sizeble frame/window (hmm, how their different) with capabilities to receive a g.drawLine ( 0,0,100,100 ) function..
Yours : JariTapio Homepage : www.EuroJari.net EMail : JariTapio@EuroJari.net
JTapio - 10 Oct 2006 21:21 GMT Hei!
this is how far i have get.. please help to add canvas to frame..
public void init() { Canvas canvas = new myComponent (); canvas.addComponentListener( new ComponentListener ()); // this line needs help.. frame.add (canvas); }
class myComponent extends Canvas { // This method is called whenever the contents needs to be painted
public void paint(Graphics g) { // Retrieve the graphics context; this object is used to paint shapes Graphics2D g2d = (Graphics2D)g;
// Draw an oval that fills the window int x = 0; int y = 0; int width = getSize().width-1; int height = getSize().height-1; g2d.drawOval(x, y, width, height); }
}
Andrew Thompson - 11 Oct 2006 05:52 GMT ....
> this is how far i have get.. > please help to add canvas to frame.. Why do you want to create the canvas in the applet, rather than simply make it in the frame?
(Note that if overriding 'paint' I will usually choose a Container, since there is often no need for anything more.)
> public void init() > { > Canvas canvas = new myComponent (); > canvas.addComponentListener( new ComponentListener ()); // this line > needs help.. What is the purpose of listening to the canvas?
(I have done similar things, but until I understand exactly what you are trying to do, what it looks like in the applet, and what actions cause the frame/window to appear - I cannot help much)
As an aside, the difference between a frame and a window is that a window has no decorations - no 'title bar', no 'close box'..
The code example I posted earlier in the thread, showed a full-screen window popping from an applet (which is quite bad if it has no button to close it & the way I did it, meant the user could not get back to the web page with the applet!).
Andrew T.
JTapio - 11 Oct 2006 14:40 GMT --(I have done similar things, but until I understand exactly --what you are trying to do, what it looks like in the applet, --and what actions cause the frame/window to appear - I --cannot help much)
Hei!
if you look my homepage you can see an applet.. my applet is only for options and opening graphics.. my plan is to make a fullscreen window or frame (i dont know either is better) from this applet, then i mouselisten and keyboard listen this window/frame and then but my warboard graphics on it..
this is very basic information of Java but im a visualc++ programmer, dont that much of a own the depthness of Java..
Yours : JariTapio Homepage : www.EuroJari.net EMail : JariTapio@EuroJari.net
Andrew Thompson - 11 Oct 2006 15:33 GMT > --(I have done similar things, but until I understand exactly > --what you are trying to do, what it looks like in the applet, > --and what actions cause the frame/window to appear - I > --cannot help much) ...
> my applet is only for options and opening graphics.. > my plan is to make a fullscreen window or frame (i dont know either is > better) from this applet, then i mouselisten and keyboard listen this > window/frame and then but my warboard graphics on it.. Since the game play ends up with a free floating window, I think you should abandon the applet entirely and use webstart to launch the game.
You might have the options 'panel' appear in a JOptionPane before the game appears, but better might be putting it into a floatable JToolBar on one edge of the game play area, or showing it whenever a menu item is selected.
For the 'floating game area' a frame (JFrame) would probably be better than a JWindow, since a JFrame is more what the user expects, and can be resized to full screen if they want.
As far as the game goes, I would paint it in a Container that I then add to the other things (like the JFrame).
But having the applet itself, makes no sense to me.
Andrew T.
JTapio - 14 Oct 2006 07:46 GMT > But having the applet itself, makes no sense to me. You can feel safe and fine,with applet..
I need a code peek of putting an canvas to an frame..
JariTapio www.eurojari.net jaritapio@eurojari.net
Andrew Thompson - 14 Oct 2006 08:09 GMT > > But having the applet itself, makes no sense to me. > > You can feel safe and fine,with applet.. I feel 'safer and finer' with a sandboxed web start application*. There is really no difference in security.
Compare the sandboxed/all-permissions end-user difference. Sandboxed <http://www.physci.org/pc/jtest.jnlp> all-permissions <http://www.physci.org/giffer/giffer.jnlp> (both those were written and 'published' by me, though the second hooks into an open source GIF animation library.)
* I use IE, and have not bothered to remove the 3810 MSVM. If my settings get messed up and I cruise into a malicious page with the MSVM as the default VM, the web master has the potential to find the root location of the (MS) VM installation on my PC, using a *sandboxed* applet. That would not be possible with a sandboxed web start application or applet (or any other VM).
Andrew T.
Andrew Thompson - 14 Oct 2006 08:50 GMT ...
> I need a code peek of putting an canvas to an frame.. BTW - That reads as "I need to learn Java GUI toolkits", from this end. For (AWT) GUI's - start here.. <http://java.sun.com/developer/onlineTraining/awt/contents.html>
It mentions both using a Canvas (and adds that since 1.1, you can simply use a Component), and also shows examples of using a Frame.
Andrew T.
JTapio - 15 Oct 2006 17:34 GMT ---<http://java.sun.com/developer/onlineTraining/awt/contents.html>
wow.. that was about everything i been looking for.. greatly thank you A.T. the entire page was new to me, thanks..
Yours : JariTapio Homepage : www.EuroJari.net EMail : JariTapio@EuroJari.net
JTapio - 15 Oct 2006 20:52 GMT Hei!
heh, i get my Jframe visible.. now the problem is that my applet crashes on my homepage.. my project works fine with NetBeans IDE, but, crashes on my homepage..
can you please point the problem..
import java.applet.Applet; import java.awt.Canvas; import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Toolkit; import javax.swing.JFrame;
public class NewApplet extends Applet { JFrame frame;
public void init() { frame.setDefaultLookAndFeelDecorated(true); frame = new JFrame("my very first frame..");
BSMCanvas region = new BSMCanvas();
frame.add(region); frame.setSize(Toolkit.getDefaultToolkit().getScreenSize()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true);
}
public void stop () {} public void destroy () {}
public void run () {
} }
class BSMCanvas extends Canvas { public BSMCanvas () { setSize(800, 800); setBackground(Color.blue); }
public void paint(Graphics g){ update(g); }
public void update(Graphics g){ Graphics2D g2 = (Graphics2D)g; } }
Yours : JariTapio Homepage : www.EuroJari.net EMail : JariTapio@EuroJari.net
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|