初心者歓迎! Java相談室 その6
■ このスレッドは過去ログ倉庫に格納されています
0643デフォルトの名無しさん
NGNG「Write Once Run Anywhere!!」
っていうけど、だったらWindows上でMacルック使える?
標準では入ってないから使えない
だから、おれはMac使ったことないからわかんないけど
コレの逆もありえるかなって思い「使ってるOSは?」って書きました
>>620
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.plaf.metal.MetalLookAndFeel;
import com.sun.java.swing.plaf.motif.MotifLookAndFeel;
import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;
/*
<APPLET CODE=plaf.class WIDTH=210 HEIGHT=200 ></APPLET>
*/
public class plaf extends JApplet{
JRadioButton b1 = new JRadioButton("Metal"),
b2 = new JRadioButton("Motif"),
b3 = new JRadioButton("Windows");
public void init(){
Container contentPane = getContentPane();
contentPane.add(new jpanel(), BorderLayout.CENTER);}
class jpanel extends JPanel implements ActionListener{
public jpanel(){
add(new JButton("JButton",new ImageIcon("My.gif")));
ButtonGroup group = new ButtonGroup();
group.add(b1);
group.add(b2);
group.add(b3);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
add(b1);
add(b2);
add(b3);}
public void actionPerformed(ActionEvent e){
JRadioButton src = (JRadioButton)e.getSource();
try {if((JRadioButton)e.getSource() == b1)
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
else if((JRadioButton)e.getSource() == b2)
UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
else if((JRadioButton)e.getSource() == b3)
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
}catch(Exception ex) {}
SwingUtilities.updateComponentTreeUI(getContentPane());
}}}
//すまん、俺はJDK1.4.0だが勘弁してくれ
//画像ファイル「My.gif」は自分で用意してくれ
//appletviewer で、見てくれ
//これで、成功するんだったら
//[SwingUtilities.updateComponentTreeUI(getContentPane());]を
//呼び出すタイミングが間違っていると思われ
■ このスレッドは過去ログ倉庫に格納されています