السلام عليكــم ورحمـة الله وبركاتــه ،،
هل استطيع ان انادي كلاس هو من امتداد
Applet
من خلال
JFrame
على سبيل المثال لو ضغطت على زر موجود داخل
JFRAME
وكان عليه ليسينر
كيف اربطه بال
applet
السلام عليكــم ورحمـة الله وبركاتــه ،،
هل استطيع ان انادي كلاس هو من امتداد
Applet
من خلال
JFrame
على سبيل المثال لو ضغطت على زر موجود داخل
JFRAME
وكان عليه ليسينر
كيف اربطه بال
applet
Applet عبارة عن برنامج يعمل عند العميل في صفحة إنترنت
Frame عبارة عن برنامج يعمل عند العميل على هيئة نافذة
رتب أفكارك وأعيد صياغة سؤالك
تحياتي
this is the applet
i... is the raduis from the frame class
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package monday26;
import java.applet.*;
import java.awt.*; // For Graphics, etc.
import java.awt.geom.*;
import javax.swing.*;
import javax.vecmath.*;
import java.awt.event.*;
import javax.media.j3d.*;
import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.geometry.*;
//import org.eclipse.*;
// For Ellipse2D, etc.
public class GradientPaintExample2 extends Applet {
int i;
private Ellipse2D.Double circle =
new Ellipse2D.Double(10, 10, i, i);
private GradientPaint gradient =
new GradientPaint(0, 0, Color.cyan, 175, 175, Color.magenta,
true); // true means to repeat pattern
public void init()
{ setLayout(new BorderLayout());
setSize (800,600);
//JPanel pan = new JPanel();
// pan.setBorder(new LineBorder(Color.GREEN));
// win.getContentPane().add(pan,"Center");
}
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D)g;
drawGradientCircle(g2d);
}
protected void drawGradientCircle(Graphics2D g2d) {
g2d.setPaint(gradient);
g2d.fill(getCircle());
g2d.setPaint(Color.black);
g2d.draw(getCircle());
g2d.setFont(new java.awt.Font("Arial Narrow", java.awt.Font.BOLD,15));
//g2d.Text3D textGeom = new Text3D(font3D, new String("3DText"));
// g2d.textGeom.setAlignment(Text3D.ALIGN_CENTER);
// g2d.Shape3D textShape = new Shape3D();
// g2d.textShape.setGeometry(textGeom);
// g2d.textShape.setAppearance(textAppear);
Appearance ap = new Appearance();
// Shape3D shape=new Shape3D(new Text3D(font,"hhh"),ap);
g2d.rotate(20.0d);
g2d.drawString("HelloWorld", 350,20);
//g2d.rotate(-2 * Math.PI / 240);
g2d.rotate(-30.0d);
// Appearance ap = new Appearance();
ap.setMaterial(new Material());
Font3D font = new Font3D(new Font("SanSerif", Font.PLAIN, 1),
new FontExtrusion());
Text3D x = new Text3D(font, "x");
Shape3D xShape = new Shape3D(x, ap);
// Text3D t = new Text3D(font3D, text, position, align);
//Shape3D sh = new Shape3D(t, appearance);
}
protected Ellipse2D.Double getCircle() {
return(circle);
}
}& this is from Jframe
/*
* NewJFrame.java
*
* Created on October 29, 2009, 7:18 PM
*/
package monday26;
import javax.swing.*;
/**
*
* @author co
*/
public class NewJFrame extends javax.swing.JFrame {
/** Creates new form NewJFrame */
public NewJFrame() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jTextField1 = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jPanel1.setBackground(new java.awt.Color(102, 102, 255));
jTextField1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField1ActionPerformed(evt);
}
});
jLabel1.setFont(new java.awt.Font("Bookman Old Style", 3, 18));
jLabel1.setForeground(new java.awt.Color(255, 204, 51));
jLabel1.setText("Enter Raduis please");
jButton1.setText("OK");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap(106, Short.MAX_VALUE)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 192, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(102, 102, 102))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(126, 126, 126)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(131, Short.MAX_VALUE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(170, 170, 170)
.addComponent(jButton1)
.addContainerGap(183, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(92, 92, 92)
.addComponent(jLabel1)
.addGap(29, 29, 29)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(29, 29, 29)
.addComponent(jButton1)
.addContainerGap(85, Short.MAX_VALUE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
pack();
}// </editor-fold>
private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String s = jTextField1.getText();
//int i= Integer.parseInt( s );
double i = Double.parseDouble(s);
new DrawTest();
System.out.println("s"+i);
// TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new NewJFrame().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel1;
private javax.swing.JTextField jTextField1;
// End of variables declaration
}ما اريده هو ان ادخل نصف القطر من خلال هدا ويقوم الابلت باستقباله رسم الدائره
ارجو ان تكون فهمت شو بدي
تم تعديل هذه المشاركة بواسطة angelita في 29 أكتوبر 2009 في 23:29
إنت عاوز تعمل إيه بالظبط ؟؟؟؟
انا بدي من هدا ال class
NewJFrame.java
لما ادخل عليه نصف قطر الدائره
ينادي ال ِapplet اللي بالكلاس التاني class GradientPaintExample2 extends Applet عشان
اقدر ارسم وارسل القيمه اللي دخلتها لهنا
new Ellipse2D.Double(10, 10, i, i);
ليه applet, إجعل الإثنين JFrame مثلا, أو إستبدل ال applet ب JDialog مثلا
هل أنت ترجو من وراء إستخدامك ال applet أن تستطيع إستخدام البرنامج من خلال متصفح الويب ؟ إذا كانت الإجابه لا, فلا تستخدم ال applets
تم تعديل هذه المشاركة بواسطة {هويدي} في 30 أكتوبر 2009 في 16:49
السناريو يفترض أن يكون على النحو التالي
زر موجود في الأبلت يقوم بفتح نافذة من النوع NewJFrame
بعدها يقوم المستخدم بإدخال البيانات في هذا الإطار ويضغط enter فيتم رسم دائرة في الأبلت
هذا هو السناريو الصحيح أما أن تقوم النافذة بمناداة الأبلت فهذا شيء غير منطقي
لماذا لا تستخدم JOptionPane.showInputDialog؟
تحياتي