amir-haghighi
چهارشنبه 03 مهر 1387, 11:02 صبح
به ياد او::
با سلام نميدونم سوالم مسخره هستش يا اينكه قبلا بهش جواب داده شده ميخواستم بدونم كه آيا ميشه با جاوا برنامه گرافيكي تحت ويندوز نوشت مثل c#.برنامه اي كه داراي فرم باشه و رابط گرافيكي داشته باشه ؟
saeed_Z_F
چهارشنبه 03 مهر 1387, 12:08 عصر
بله میشه به لینک زیر سر بزنید :
http://java.sun.com/docs/books/tutorial/ui/index.html
unix_svr4
چهارشنبه 03 مهر 1387, 13:18 عصر
بله! اینکار بکمک کتابخانه کلاس Swing امکانپذیره!
موفق باشید.
mm2236
پنج شنبه 04 مهر 1387, 16:57 عصر
سلام امیر جان یه مثال ساده از GUI جاوا که بهش Swing میگن
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class SwingSample4 extends JFrame implements ActionListener{
ImageIcon ic=new ImageIcon("c:\\Icon.jpg");
JCheckBox cb=new JCheckBox("Enable Radio Buttons");
JRadioButton rb1=new JRadioButton("Male");
JRadioButton rb2=new JRadioButton("Female");
JTextField tf=new JTextField(20);
JButton b=new JButton("Submit");
JButton b2=new JButton("Question");
JButton b3=new JButton("Confirm",ic);
ButtonGroup bg=new ButtonGroup();
JToggleButton tb=new JToggleButton("OFF");
SwingSample4(){
setIconImage(ic.getImage());
Container c=getContentPane();
c.setLayout(new FlowLayout());
c.add(cb);
c.add(rb1);
c.add(rb2);
c.add(b);
c.add(b2);
c.add(b3);
c.add(tb);
c.add(tf);
bg.add(rb1);
bg.add(rb2);
b.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
cb.addActionListener(this);
rb1.addActionListener(this);
rb2.addActionListener(this);
cb.setSelected(true);
tb.addActionListener(this);
}
public static void main(String[] args) {
SwingSample4 sw=new SwingSample4();
//sw.pack();
sw.setSize(300,140);
sw.setVisible(true);
sw.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource()==b){
if (rb1.isSelected())
JOptionPane.showMessageDialog(this,"Male is selected.","Information",JOptionPane.INFORMATION_MESSAGE);
else if (rb2.isSelected())
JOptionPane.showMessageDialog(this,"Female is selected.","Information",JOptionPane.INFORMATION_MESSAGE);
else
JOptionPane.showMessageDialog(this,"Please select one of the Radiobuttons.","Error",JOptionPane.ERROR_MESSAGE);
}
if (e.getSource()==cb){
if (cb.isSelected()){
rb1.setEnabled(true);
rb2.setEnabled(true);
}
else {
rb1.setEnabled(false);
rb2.setEnabled(false);
}
}
if (e.getSource()==rb1){
tf.setText("Male");
}
if (e.getSource()==rb2){
tf.setText("Female");
}
if (e.getSource()==b2){
String st=JOptionPane.showInputDialog(this,"What is your name?","Question",JOptionPane.QUESTION_MESSAGE);
if (st!=null)
tf.setText(st);
}
if (e.getSource()==b3){
int r=JOptionPane.showConfirmDialog(this,"Are you sure?","Confirmation",JOptionPane.YES_NO_CANCEL_OPTION,JOptionPane.QUES TION_MESSAGE);
if (r==0)
tf.setText("Yes");
if (r==1)
tf.setText("No");
if (r==2)
tf.setText("Cancel");
}
if (e.getSource()==tb){
if (tb.isSelected())
tb.setText("ON");
else
tb.setText("OFF");
}
}
}
vBulletin® v4.2.5, Copyright ©2000-1404, Jelsoft Enterprises Ltd.