view release on metacpan or search on metacpan
examples/corpus/BorderLayoutTest.java view on Meta::CPAN
}
});
Container contentPane = f.getContentPane();
//the following is unnecessary since BorderLayout is default:
// contentPane.setLayout( new BorderLayout() );
//NORTH:
ImageIcon northIcon = new ImageIcon( "image/snowflake.gif" );
JLabel northLabel = new JLabel( "Frigid in the North",
northIcon,
JLabel.CENTER );
northLabel.setVerticalTextPosition( JLabel.BOTTOM );
northLabel.setHorizontalTextPosition( JLabel.CENTER );
contentPane.add( northLabel , BorderLayout.NORTH );
//SOUTH:
ImageIcon southIcon = new ImageIcon( "image/zwthr14.gif" );
JLabel southLabel = new JLabel( "Balmy in the South",
southIcon,
examples/corpus/BoxLayoutTest.java view on Meta::CPAN
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
Container contentPane = f.getContentPane(); //(A)
String[] data = {"sunny", "hot", "stormy", "balmy", //(B)
"cold", "frigid", "rainy", "windy",
"snowy", "blistery", "blizzardy"};
JList list = new JList( data ); //(C)
//this makes list the viewport of listscroller:
JScrollPane listScroller = new JScrollPane( list ); //(D)
listScroller.setPreferredSize( new Dimension( 300, 100 ) );
listScroller.setMinimumSize( new Dimension( 300, 100 ) );
listScroller.setAlignmentX( Component.LEFT_ALIGNMENT );
JPanel listPanel = new JPanel(); //(E)
listPanel.setLayout(
new BoxLayout( listPanel, BoxLayout.Y_AXIS ) );
JLabel label = new JLabel( "Select today's weather:" );
listPanel.add( label );
listPanel.add(
Box.createRigidArea( new Dimension( 0, 10 ) ) ); //(F)
listPanel.add( listScroller );
listPanel.setBorder(
BorderFactory.createEmptyBorder( 10, 10, 10, 10 ) ); //(G)
contentPane.add( listPanel, BorderLayout.CENTER ); //(H)
JButton cancelButton = new JButton( "Cancel" );
JButton selectButton = new JButton( "Select" );
JPanel buttonPanel = new JPanel(); //(I)
buttonPanel.setLayout(
new BoxLayout( buttonPanel, BoxLayout.X_AXIS ) );
buttonPanel.setBorder(
BorderFactory.createEmptyBorder(0,10,10,10 ) );
buttonPanel.add( Box.createHorizontalGlue() );
buttonPanel.add( cancelButton );
buttonPanel.add(
Box.createRigidArea( new Dimension( 10, 0 ) ) );
buttonPanel.add( selectButton );
contentPane.add( buttonPanel, BorderLayout.SOUTH ); //(J)
f.pack();
f.setLocation( 200, 300 );
f.setVisible( true );
}
}
examples/corpus/CardLayoutTest.java view on Meta::CPAN
//CardLayoutTest.java
import java.awt.*; // for Container, BorderLayout
import java.awt.event.*; // for WindowAdapter
import javax.swing.*;
import javax.swing.border.*; // for Border, BorderFactory
public class CardLayoutTest extends JFrame implements ItemListener {
JPanel cards;
final static String[] comboBoxItems
= {"frigid","balmy","stormy","sunny" };
public CardLayoutTest() {
Container contentPane = getContentPane();
JPanel comboPanel = new JPanel();
JComboBox c = new JComboBox( comboBoxItems ); //(A)
c.setEditable( false );
c.addItemListener( this ); //(B)
c.setBorder(
BorderFactory.createEmptyBorder( 20, 20, 20, 20 ) ); //(C)
examples/corpus/CardLayoutTest.java view on Meta::CPAN
size.width = 200;
size.height = 200;
return size;
}
};
cards.setLayout( new CardLayout() );
//Card 1:
ImageIcon firstIcon = new ImageIcon( "snowflake.gif" );
JLabel firstLabel = new JLabel( "Frigid in the North",
firstIcon,
JLabel.CENTER );
firstLabel.setVerticalTextPosition( JLabel.BOTTOM );
firstLabel.setHorizontalTextPosition( JLabel.CENTER );
firstLabel.setBorder(
BorderFactory.createLineBorder( Color.blue ) );
cards.add( firstLabel, "frigid" );
//Card 2:
ImageIcon secondIcon = new ImageIcon( "zwthr14.gif" );
JLabel secondLabel = new JLabel( "Balmy in the South",
secondIcon,
JLabel.CENTER );
secondLabel.setVerticalTextPosition( JLabel.BOTTOM );
secondLabel.setHorizontalTextPosition( JLabel.CENTER );
secondLabel.setBorder(
BorderFactory.createLineBorder( Color.green ) );
examples/corpus/FlowLayoutTest.java view on Meta::CPAN
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
Container contentPane = f.getContentPane(); //(A)
contentPane.setLayout( new FlowLayout() ); //(B)
//ITEM 1:
ImageIcon firstIcon = new ImageIcon( "snowflake.gif" );
JLabel firstLabel = new JLabel( "Frigid in the North",
firstIcon,
JLabel.CENTER );
firstLabel.setVerticalTextPosition( JLabel.BOTTOM );
firstLabel.setHorizontalTextPosition( JLabel.CENTER );
contentPane.add( firstLabel );
//ITEM 2:
ImageIcon secondIcon = new ImageIcon( "zwthr14.gif" );
JLabel secondLabel = new JLabel( "Balmy in the South",
secondIcon,
examples/corpus/GridLayoutTest.java view on Meta::CPAN
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
Container contentPane = f.getContentPane();
contentPane.setLayout( new GridLayout( 0, 2 ) );
//ITEM 1:
ImageIcon firstIcon = new ImageIcon( "snowflake.gif" );
JLabel firstLabel = new JLabel( "Frigid in the North",
firstIcon,
JLabel.CENTER );
firstLabel.setVerticalTextPosition( JLabel.BOTTOM );
firstLabel.setHorizontalTextPosition( JLabel.CENTER );
contentPane.add( firstLabel );
//ITEM 2:
ImageIcon secondIcon = new ImageIcon( "zwthr14.gif" );
JLabel secondLabel = new JLabel( "Balmy in the South",
secondIcon,
examples/corpus_with_java_and_cpp/BorderLayoutTest.java view on Meta::CPAN
}
});
Container contentPane = f.getContentPane();
//the following is unnecessary since BorderLayout is default:
// contentPane.setLayout( new BorderLayout() );
//NORTH:
ImageIcon northIcon = new ImageIcon( "image/snowflake.gif" );
JLabel northLabel = new JLabel( "Frigid in the North",
northIcon,
JLabel.CENTER );
northLabel.setVerticalTextPosition( JLabel.BOTTOM );
northLabel.setHorizontalTextPosition( JLabel.CENTER );
contentPane.add( northLabel , BorderLayout.NORTH );
//SOUTH:
ImageIcon southIcon = new ImageIcon( "image/zwthr14.gif" );
JLabel southLabel = new JLabel( "Balmy in the South",
southIcon,
examples/corpus_with_java_and_cpp/BoxLayoutTest.java view on Meta::CPAN
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
Container contentPane = f.getContentPane(); //(A)
String[] data = {"sunny", "hot", "stormy", "balmy", //(B)
"cold", "frigid", "rainy", "windy",
"snowy", "blistery", "blizzardy"};
JList list = new JList( data ); //(C)
//this makes list the viewport of listscroller:
JScrollPane listScroller = new JScrollPane( list ); //(D)
listScroller.setPreferredSize( new Dimension( 300, 100 ) );
listScroller.setMinimumSize( new Dimension( 300, 100 ) );
listScroller.setAlignmentX( Component.LEFT_ALIGNMENT );
JPanel listPanel = new JPanel(); //(E)
listPanel.setLayout(
new BoxLayout( listPanel, BoxLayout.Y_AXIS ) );
JLabel label = new JLabel( "Select today's weather:" );
listPanel.add( label );
listPanel.add(
Box.createRigidArea( new Dimension( 0, 10 ) ) ); //(F)
listPanel.add( listScroller );
listPanel.setBorder(
BorderFactory.createEmptyBorder( 10, 10, 10, 10 ) ); //(G)
contentPane.add( listPanel, BorderLayout.CENTER ); //(H)
JButton cancelButton = new JButton( "Cancel" );
JButton selectButton = new JButton( "Select" );
JPanel buttonPanel = new JPanel(); //(I)
buttonPanel.setLayout(
new BoxLayout( buttonPanel, BoxLayout.X_AXIS ) );
buttonPanel.setBorder(
BorderFactory.createEmptyBorder(0,10,10,10 ) );
buttonPanel.add( Box.createHorizontalGlue() );
buttonPanel.add( cancelButton );
buttonPanel.add(
Box.createRigidArea( new Dimension( 10, 0 ) ) );
buttonPanel.add( selectButton );
contentPane.add( buttonPanel, BorderLayout.SOUTH ); //(J)
f.pack();
f.setLocation( 200, 300 );
f.setVisible( true );
}
}
examples/corpus_with_java_and_cpp/CardLayoutTest.java view on Meta::CPAN
//CardLayoutTest.java
import java.awt.*; // for Container, BorderLayout
import java.awt.event.*; // for WindowAdapter
import javax.swing.*;
import javax.swing.border.*; // for Border, BorderFactory
public class CardLayoutTest extends JFrame implements ItemListener {
JPanel cards;
final static String[] comboBoxItems
= {"frigid","balmy","stormy","sunny" };
public CardLayoutTest() {
Container contentPane = getContentPane();
JPanel comboPanel = new JPanel();
JComboBox c = new JComboBox( comboBoxItems ); //(A)
c.setEditable( false );
c.addItemListener( this ); //(B)
c.setBorder(
BorderFactory.createEmptyBorder( 20, 20, 20, 20 ) ); //(C)
examples/corpus_with_java_and_cpp/CardLayoutTest.java view on Meta::CPAN
size.width = 200;
size.height = 200;
return size;
}
};
cards.setLayout( new CardLayout() );
//Card 1:
ImageIcon firstIcon = new ImageIcon( "snowflake.gif" );
JLabel firstLabel = new JLabel( "Frigid in the North",
firstIcon,
JLabel.CENTER );
firstLabel.setVerticalTextPosition( JLabel.BOTTOM );
firstLabel.setHorizontalTextPosition( JLabel.CENTER );
firstLabel.setBorder(
BorderFactory.createLineBorder( Color.blue ) );
cards.add( firstLabel, "frigid" );
//Card 2:
ImageIcon secondIcon = new ImageIcon( "zwthr14.gif" );
JLabel secondLabel = new JLabel( "Balmy in the South",
secondIcon,
JLabel.CENTER );
secondLabel.setVerticalTextPosition( JLabel.BOTTOM );
secondLabel.setHorizontalTextPosition( JLabel.CENTER );
secondLabel.setBorder(
BorderFactory.createLineBorder( Color.green ) );
examples/corpus_with_java_and_cpp/FlowLayoutTest.java view on Meta::CPAN
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
Container contentPane = f.getContentPane(); //(A)
contentPane.setLayout( new FlowLayout() ); //(B)
//ITEM 1:
ImageIcon firstIcon = new ImageIcon( "snowflake.gif" );
JLabel firstLabel = new JLabel( "Frigid in the North",
firstIcon,
JLabel.CENTER );
firstLabel.setVerticalTextPosition( JLabel.BOTTOM );
firstLabel.setHorizontalTextPosition( JLabel.CENTER );
contentPane.add( firstLabel );
//ITEM 2:
ImageIcon secondIcon = new ImageIcon( "zwthr14.gif" );
JLabel secondLabel = new JLabel( "Balmy in the South",
secondIcon,
examples/corpus_with_java_and_cpp/GridLayoutTest.java view on Meta::CPAN
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
Container contentPane = f.getContentPane();
contentPane.setLayout( new GridLayout( 0, 2 ) );
//ITEM 1:
ImageIcon firstIcon = new ImageIcon( "snowflake.gif" );
JLabel firstLabel = new JLabel( "Frigid in the North",
firstIcon,
JLabel.CENTER );
firstLabel.setVerticalTextPosition( JLabel.BOTTOM );
firstLabel.setHorizontalTextPosition( JLabel.CENTER );
contentPane.add( firstLabel );
//ITEM 2:
ImageIcon secondIcon = new ImageIcon( "zwthr14.gif" );
JLabel secondLabel = new JLabel( "Balmy in the South",
secondIcon,