More Related Content
More from MirOmranudinAbhar (20)
java-12
- 1. JAVA
JAVA HOW TO PROGRAM
12
Prepared by: Mir Omranudin Abhar
Email : MirOmran@Gmail.com
1
- 20. JAVA
20
• GUI Component
1. Displaying text and Image in a Window
◦ Jlable
◦ Icon
◦ setToolTipText
◦ setVerticalTextPosition
◦ setHorizontalTextPosition
- 21. JAVA
21
• GUI Component
1. Displaying text and Image in a Window
◦ Jlable
◦ Icon
◦ setToolTipText
◦ setVerticalTextPosition
◦ setHorizontalTextPosition
◦ setIcon
- 39. Question
.1
برنامه
بنویسید
که
توسط
ان
بتوانیم
logo
سافت
ویر
خویش
را
در
قسمت
Title-Bar
برنامه
اضافه
کنیم؟
39
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package jframe2;
import java.awt.FlowLayout;
import java.util.Date;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
/**
*
* @author DELL
*/
public class frame extends JFrame {
frame() {
super("JAVA");
setLayout(new FlowLayout());
JLabel label1 = new JLabel("Date & Time : ");
Date di = new Date();
String[] arra = di.toLocaleString().split(" ");
JTextField name = new JTextField("Date : " + arra[0]);
JTextField name1 = new JTextField("Time :" + arra[1]);
ImageIcon img = new ImageIcon(getClass().getResource("123.jpg"));
this.setIconImage(img.getImage());
// add(label1);
// add(name);
// add(name1);
}
}
- 40. Question
.1
برنامه
بنویسید
که
توسط
ان
بتوانیم
رنگ
background frame
را
تغیر
بدهیم
و
همچنان
رنگ
نوشته
و
background
,
JTextField
را
تغیر
بدهیم؟
40
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package jframe2;
import java.awt.Color;
import java.awt.FlowLayout;
import java.util.Date;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
/**
*
* @author DELL
*/
public class frame extends JFrame {
frame() {
super("JAVA");
setLayout(new FlowLayout());
JLabel label1 = new JLabel("Date & Time : ");
Date di = new Date();
String[] arra = di.toLocaleString().split(" ");
JTextField name = new JTextField("Date : " + arra[0]);
ImageIcon img = new ImageIcon(getClass().getResource("123.jpg"));
JTextField name1 = new JTextField("Time :" + arra[1]);
JButton bu=new JButton("Button",img);
bu.setBackground(Color.BLUE);
name.setBackground(Color.red);
getContentPane().setBackground(java.awt.Color.g etHSBColor(120, 202,122));
// this.setIconImage(img.getImage());
// add(label1);
add(name);
// add(bu);
// add(name1);
}
}