62,614
社区成员
发帖
与我相关
我的任务
分享
import java.awt.*;
import javax.swing.*;
public class Circle extends JPanel {
private int positionX = 50;
private int positionY = 50;
ImageIcon image = new ImageIcon("Sample.jpg");
public Circle() {
super();
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
g2d.drawImage(image.getImage(), positionX, positionY, this);
g2d.dispose();
}
}
private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {
Circle c = new Circle();
c.setLocation(30, 30);
c.setSize(530, 160);
jPanel1.add(c);
}
import java.awt.*;
import javax.swing.*;
public class RotateImage extends JFrame {
MyPanel panel = new MyPanel();
public RotateImage() {
setSize(400, 400);
setContentPane(panel);
setVisible(true);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public class MyPanel extends JPanel {
ImageIcon image = new ImageIcon("Sample.jpg");
public MyPanel() {
super();
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
g2d.drawImage(image.getImage(), 0, 0, this);
g2d.dispose();
}
}
public static void main(String[] args) {
new RotateImage();
}
}
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class RotateImage extends JFrame implements ActionListener{
MyPanel jpanel1 = new MyPanel();
JButton b = new JButton("test");
public RotateImage() {
add(b, BorderLayout.NORTH);
b.addActionListener(this);
//setSize(400, 400);
setPreferredSize(new Dimension(400, 400));
pack();
setVisible(true);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent evt) {
Circle c = new Circle();
c.setLocation(30, 30);
c.setSize(530, 160);
//setVisible(false);
add(jpanel1);
//setVisible(true);
pack();
}
public class MyPanel extends JPanel {
ImageIcon image = new ImageIcon("Sample.jpg");
public MyPanel() {
super();
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
g2d.drawImage(image.getImage(), 0, 0, this);
g2d.dispose();
}
}
public static void main(String[] args) {
new RotateImage();
}
}
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class RotateImage extends JFrame implements ActionListener{
MyPanel jpanel1 = new MyPanel();
JButton b = new JButton("test");
public RotateImage() {
add(b, BorderLayout.NORTH);
b.addActionListener(this);
setSize(400, 400);
//setPreferredSize(new Dimension(400, 400));
//pack();
setVisible(true);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent evt) {
Circle c = new Circle();
c.setLocation(30, 30);
c.setSize(530, 160);
setVisible(false);
add(jpanel1);
setVisible(true);
//pack();
}
public class MyPanel extends JPanel {
ImageIcon image = new ImageIcon("Sample.jpg");
public MyPanel() {
super();
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
g2d.drawImage(image.getImage(), 0, 0, this);
g2d.dispose();
}
}
public static void main(String[] args) {
new RotateImage();
}
}
public class MyFrame extends JFrame
{
/////////......................
private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {
Circle c = new Circle();
c.setLocation(30, 30);
c.setSize(530, 160);
jPanel1.add(c);
pack();
}
////////......................
}
private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {
Circle c = new Circle();
c.setLocation(30, 30);
c.setSize(530, 160);
jPanel1.add(c);
××Frame.this.pack();
}