| ページ一覧 | ブログ | twitter |  書式 | 書式(表) |

MyMemoWiki

差分

ナビゲーションに移動 検索に移動
編集の要約なし
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.[[JFrame]];
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.JTextField;
import javax.swing.SwingUtilities[[Swing]]Utilities;
import javax.swing.UIManager;
import javax.swing.event.ChangeEvent;
@SuppressWarnings("serial")
public class LayoutTest extends [[JFrame ]] {
/**
* BorderLayout test
*/
public void testBorderLayout() {
[[JFrame ]] frame = new [[JFrame]]("BorderLayout Test");
Container pane = frame.getContentPane();
pane.setLayout(new BorderLayout());
pane.add(new JButton("NORTHNO[[R]]TH"), BorderLayout.NORTHNO[[R]]TH);
pane.add(new JButton("WEST"), BorderLayout.WEST);
pane.add(new JButton("CENTERCENTE[[R]]"), BorderLayout.CENTERCENTE[[R]]);
pane.add(new JButton("EAST"), BorderLayout.EAST);
pane.add(new JButton("SOUTH"), BorderLayout.SOUTH);
*/
public void testBoxLayout() {
[[JFrame ]] frame = new [[JFrame]]("BoxLayout Test");
Container pane = frame.getContentPane();
JButton btn1 = new JButton("button1");
btn1.setAlignmentX(Component.CENTER_ALIGNMENTCENTE[[R]]_ALIGNMENT); // 0.5f
JButton btn2 = new JButton("button2");
btn2.setAlignmentX(Component.CENTER_ALIGNMENTCENTE[[R]]_ALIGNMENT); // 0.5f
JButton btn3 = new JButton("button3");
btn3.setAlignmentX(Component.CENTER_ALIGNMENTCENTE[[R]]_ALIGNMENT); // 0.5f
pane.add(btn1);
*/
public void testCardLayout() {
[[JFrame ]] frame = new [[JFrame]]("CardLayout Test");
Container pane = frame.getContentPane();
final String BUTTON_CARD BUTTON_CA[[R]]D = "buttons"; final String TEXT_CARD TEXT_CA[[R]]D = "texts";
final JPanel cards = new JPanel(new CardLayout());
card2.add(new JTextField("TextField", 10));
cards.add(card1, BUTTON_CARDBUTTON_CA[[R]]D); cards.add(card2, TEXT_CARDTEXT_CA[[R]]D);
pane.add(ctrlPane, BorderLayout.NORTHNO[[R]]TH); pane.add(cards, BorderLayout.CENTERCENTE[[R]]);
frame.pack();
public static void main(String[] args) {
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel[[Windows]]LookAndFeel");
// UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
} catch (Exception e) {
e.printStackTrace();
}
SwingUtilities[[Swing]]Utilities.invokeLater( new Runnable[[R]]unnable() {
public void run() {
LayoutTest lt = new LayoutTest();
lt.setDefaultCloseOperation([[JFrame]].EXIT_ON_CLOSE);
lt.setVisible(true);
}

案内メニュー