japplet

Adding JFrame to JApplet

╄→尐↘猪︶ㄣ 提交于 2019-12-08 06:33:55
问题 Can I add program based on JFrame to JApplet ? How can I do that, when I try to do it like: public class Test extends JApplet{ public void init(){ JFrame frame=new JFrame(300,400); add(frame); frame.setVisible(true); } I got an error when i try to use appletviewer. Can anyone help me ? 回答1: You can't add a frame to an applet, but you can add an applet to a frame: import javax.swing.*; import javax.swing.event.*; import java.awt.*; import java.awt.event.*; public class AppletBasic extends

Launching another Applet from another Applet

为君一笑 提交于 2019-12-08 03:40:02
问题 I have made a Loader Applet which greets the user and when user clicks the button displayed on that Applet it then launches the main applet and the Loader Applet is destroyed. But on clicking Another applet is not launched ! Loader Applet: import java.awt.Button; import java.awt.FlowLayout; import java.awt.Graphics; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JApplet; public class Loader extends JApplet implements ActionListener{ Display

How to make an image blink in a random position?

徘徊边缘 提交于 2019-12-06 14:53:02
问题 I have an image inside the JApplet and I want it to appear in a random position. It will disappear after 1 second and appear again, in another random position. How do I implement 'blinking in a random position'? import javax.imageio.ImageIO; import javax.swing.*; import java.awt.*; import java.net.URL; public class Random extends JApplet { Image ball; public void init() { try { URL pic = new URL(getDocumentBase(), "ball.gif"); ball = ImageIO.read(pic); } catch (Exception e) { e

Change the JSlider look and feel

好久不见. 提交于 2019-12-06 01:39:22
问题 I have gone through this website Change look and feel of JSlider but except for Slider.altTrackColor nothing else is working. I want to do something like shown in pic1 any suggestion would be of great help. I'm working on JDK 1.6. UIDefaults defaults = UIManager.getDefaults(); defaults.put("Slider.altTrackColor", Color.red); defaults.put("Slider.thumb", Color.red); I have also tried this: WindowUtilities.setNativeLookAndFeel(); // WindowUtilities.setNimbuzzLookAndFeel(); // WindowUtilities

How to make an image blink in a random position?

你说的曾经没有我的故事 提交于 2019-12-04 22:17:21
I have an image inside the JApplet and I want it to appear in a random position. It will disappear after 1 second and appear again, in another random position. How do I implement 'blinking in a random position'? import javax.imageio.ImageIO; import javax.swing.*; import java.awt.*; import java.net.URL; public class Random extends JApplet { Image ball; public void init() { try { URL pic = new URL(getDocumentBase(), "ball.gif"); ball = ImageIO.read(pic); } catch (Exception e) { e.printStackTrace(); } } public void paint(Graphics g) { if (ball != null) { g.drawImage(ball,50,50,50,50,this); } } }

IllegalArgumentException at URLPermission in jre8

十年热恋 提交于 2019-12-04 22:02:00
when i run the code below, -in an Applet on JRE8, on the line con.getInputStream() it throws the exception -in an Applet on JRE7 or JRE6 it does not throws. -in a Desktop app on any JRE it does not throws. when i remove the lines starts with setRequestPropery , it does not throws the exception on any JRE. URLConnection con = new URL(adress).openConnection(); con.setDoOutput(true); con.setDoInput(true); con.setUseCaches(false); con.setRequestProperty("Content-Type", "application/octet-stream"); con.setRequestProperty("pragma:", "no-cache"); PrintStream ps = new PrintStream(con.getOutputStream()

How to set Http Proxy in an applet

核能气质少年 提交于 2019-12-04 18:49:18
问题 For a java desktop application after we set these properties System.setProperty("java.net.useSystemProxies","true"); System.setProperty("http.proxyHost", "1.1.1.1"); System.setProperty("http.proxyPort", "8080"); every http connection will be done through the defined proxy. But for an applet these does not work .(In an applet viewer it does but in a browser it doesnt.) Applet always uses these settings which are defined in control panel\java\network settings\proxy settings. How can i set the

Difference between JPanel, JFrame, JComponent, and JApplet

允我心安 提交于 2019-12-04 07:30:24
问题 I'm making a physics simulator for fun and I was looking up graphics tutorials when I tried to figure out the difference between all these J's. Can somebody elaborate on them or perhaps provide a link to a helpful source? 回答1: Those classes are common extension points for Java UI designs. First off, realize that they don't necessarily have much to do with each other directly, so trying to find a relationship between them might be counterproductive. JApplet - A base class that let's you write

How to set Http Proxy in an applet

▼魔方 西西 提交于 2019-12-03 12:17:33
For a java desktop application after we set these properties System.setProperty("java.net.useSystemProxies","true"); System.setProperty("http.proxyHost", "1.1.1.1"); System.setProperty("http.proxyPort", "8080"); every http connection will be done through the defined proxy. But for an applet these does not work .(In an applet viewer it does but in a browser it doesnt.) Applet always uses these settings which are defined in control panel\java\network settings\proxy settings. How can i set the proxy in an applet? (Using proxy class in every opening connection is not a solution for me.) Applet is

JDBC Connection: Access Denied for User even All Previlleges are Granted [closed]

左心房为你撑大大i 提交于 2019-12-02 22:45:10
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I have an JApplet that connects to the database via this code: String url = "jdbc:mysql://localhost:3306/moodlele_survey"; String user = "moodlele_garanti"; String password = "garanti"; try { panel.add( new JLabel("before driver")); Class.forName("com.mysql.jdbc.Driver"); panel.add( new JLabel("failed"));