0
これは私のTextEditorプロジェクトです。ユーザーがイメージをアップロードすると、デフォルトのイメージサイズは400x400ピクセルになります。 ExpandImage
とShrinkImage
という2つのボタンを追加しました。 ExpandImageボタンをクリックするたびに、50ピクセルに拡大する必要があります。各クリックで画像サイズのピクセルを10%に拡大するJButton?
image = new ImageIcon(filename);
icon = new ImageIcon(image.getImage().getScaledInstance(400, 400, Image.SCALE_DEFAULT));
editorText.insertIcon(icon);
editorText.setEditable(true);
editorText.setFocusable(true);
ExpandImage.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
// do stuff here
// 400 += 50;
// 400 += 50;
System.out.println("You clicked me!");
}
});
ありがとうございました!以前の画像も表示されます。あなたはそれをクリアする方法を知っていますか? – user6042355
画像アイコンを消去していますか?またはデフォルトのサイズに戻す – Priyamal
私は古いイメージを取り除きたいので、私は拡大ボタンをクリックした後に2つのイメージを表示しています。 – user6042355