AnaPencere.java
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
public class AnaPencere {
JFrame anaPencere;
BufferedImage bImageLEFT;
BufferedImage bImageRIGHT;
public static void main(String[] args){
AnaPencere apencere = new AnaPencere();
}
public AnaPencere() {
anaPencere = new JFrame("Main Window");
anaPencere.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
anaPencere.setSize(613, 253);
anaPencere.setLocationRelativeTo(null);
anaPencere.setVisible(true);
anaPencere.add(new left());
anaPencere.add(new right());
}
private class left extends JPanel{
private left() {
this.setBounds(0, 0, 313, 253);
this.setFocusable(true);
bImageLEFT = new BufferedImage(313, 253, BufferedImage.TYPE_INT_ARGB);
paintComponent(bImageLEFT.createGraphics());
}
public void paintComponent(Graphics g){
Graphics2D g2 = (Graphics2D)g;
g2.drawString("> LEFT <", Font.BOLD, 13);
}
}
private class right extends JPanel{
private right() {
this.setBounds(313, 0, 300, 253);
this.setFocusable(true);
bImageRIGHT = new BufferedImage(313, 253, BufferedImage.TYPE_INT_ARGB);
paintComponent(bImageRIGHT.createGraphics());
}
public void paintComponent(Graphics g){
Graphics2D g2 = (Graphics2D)g;
g2.drawString("> RIGHT <", Font.BOLD, 13);
}
}
}
(jpanelsの座標を左右のクラスに設定します)コードを実行すると、> LEFT <テキストのみが表示され、 >RIGHT<テキストは表示されません。この問題を解決するにはどうすればよいですか?
私の悪い英語のために申し訳ありません。