本文整理汇总了Java中java.awt.Panel.setLayout方法的典型用法代码示例。如果您正苦于以下问题:Java Panel.setLayout方法的具体用法?Java Panel.setLayout怎么用?Java Panel.setLayout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Panel
的用法示例。
在下文中一共展示了Panel.setLayout方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import java.awt.Panel; //导入方法依赖的package包/类
@Override
public void init() {
tf = new TextField(20);
tf.setText("0123456789");
tf.select(0, 6);
final TextArea ta = new TextArea("INSTRUCTIONS:\n"
+ "The text 012345 should be selected in the TextField.\n"
+ "If this is what you observe, then the test passes.\n"
+ "Otherwise, the test fails.", 40, 5,
TextArea.SCROLLBARS_NONE);
ta.setEditable(false);
ta.setPreferredSize(new Dimension(300, 70));
final Panel panel = new Panel();
panel.setLayout(new FlowLayout());
panel.add(tf);
setLayout(new BorderLayout());
add(ta, BorderLayout.CENTER);
add(panel, BorderLayout.PAGE_END);
}
示例2: createObjects
import java.awt.Panel; //导入方法依赖的package包/类
void createObjects() {
textArea = new TextArea( bigString() );
robot = Util.createRobot();
Panel panel = new Panel();
panel.setLayout( new GridLayout(3,3) );
for( int y=0; y<3; ++y ) {
for( int x=0; x<3; ++x ) {
if( x==1 && y==1 ) {
panel.add( textArea );
} else {
panel.add( new Panel() );
}
}
}
Frame frame = new Frame( "TextArea cursor icon test" );
frame.setSize( 300, 300 );
frame.add( panel );
frame.setVisible( true );
}
示例3: init
import java.awt.Panel; //导入方法依赖的package包/类
@Override
public void init() {
ta = new TextArea(4, 20);
ta.setText("01234\n56789");
ta.select(3, 9);
final TextArea instruction = new TextArea("INSTRUCTIONS:\n"
+ "The text 34567 should be selected in the TextArea.\n"
+ "If this is what you observe, then the test passes.\n"
+ "Otherwise, the test fails.", 40, 5,
TextArea.SCROLLBARS_NONE);
instruction.setEditable(false);
instruction.setPreferredSize(new Dimension(300, 70));
final Panel panel = new Panel();
panel.setLayout(new FlowLayout());
panel.add(ta);
setLayout(new BorderLayout());
add(instruction, BorderLayout.CENTER);
add(panel, BorderLayout.PAGE_END);
}
示例4: createBorderPanel
import java.awt.Panel; //导入方法依赖的package包/类
/**
* Method declaration
*
*
* @param center
*
* @return
*/
protected static Panel createBorderPanel(Component center) {
Panel p = new Panel();
p.setBackground(SystemColor.control);
p.setLayout(new BorderLayout());
p.add("Center", center);
p.add("North", createLabel(""));
p.add("South", createLabel(""));
p.add("East", createLabel(""));
p.add("West", createLabel(""));
p.setBackground(SystemColor.control);
return p;
}
示例5: createRowHeaderTable
import java.awt.Panel; //导入方法依赖的package包/类
private static RowHeaderTable createRowHeaderTable(final Composite composite, final int width, final int height, final int rowHeaderWidth, final int rowHeight, final boolean iconEnable, final boolean editable) {
final Frame frame = SWT_AWT.new_Frame(composite);
final FlowLayout frameLayout = new FlowLayout();
frameLayout.setVgap(0);
frame.setLayout(frameLayout);
final Panel panel = new Panel();
final FlowLayout panelLayout = new FlowLayout();
panelLayout.setVgap(0);
panel.setLayout(panelLayout);
frame.add(panel);
final RowHeaderTable table = new RowHeaderTable(width, height, rowHeaderWidth, rowHeight, iconEnable, editable);
panel.add(table);
return table;
}
示例6: Simbatch
import java.awt.Panel; //导入方法依赖的package包/类
/** Construct a batch version of Simbad simulator */
public Simbatch(EnvironmentDescription ed, boolean do3DRendering) {
counter = 0;
world = new World(ed);
// !!!!
// We need absolutly to show the 3d world in a window
// otherwise it reveal a memory bug in java3d
// see Bug ID: 4727054
// !!!!!
canvas3d = world.getCanvas3D();
frame = new Frame();
panel = new Panel();
panel.setLayout(new BorderLayout());
panel.add(canvas3d);
frame.add(panel);
frame.pack();
frame.setSize(100, 100);
frame.setVisible(true);
if (!do3DRendering) {
frame.hide();
// Do not render
canvas3d.stopRenderer();
}
simulator = new Simulator(null, world, ed);
}
示例7: addFileField
import java.awt.Panel; //导入方法依赖的package包/类
/**
* Adds the file field.
*
* @param label
* the label
* @param defaultPath
* the default path
* @param columns
* the columns
*/
public void addFileField(String label, String defaultPath, int columns) {
addStringField(label, defaultPath, columns);
if (isHeadless())
return;
TextField text = (TextField) stringField.lastElement();
GridBagLayout layout = (GridBagLayout) getLayout();
GridBagConstraints constraints = layout.getConstraints(text);
Button button = new Button("Browse...");
FileListener listener = new FileListener("Browse for " + label, text);
button.addActionListener(listener);
button.addKeyListener(this);
Panel panel = new Panel();
panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
panel.add(text);
panel.add(button);
layout.setConstraints(panel, constraints);
add(panel);
}
示例8: addDirectoryField
import java.awt.Panel; //导入方法依赖的package包/类
/**
* Adds the directory field.
*
* @param label
* the label
* @param defaultPath
* the default path
* @param columns
* the columns
*/
public void addDirectoryField(String label, String defaultPath, int columns) {
addStringField(label, defaultPath, columns);
if (isHeadless())
return;
TextField text = (TextField) stringField.lastElement();
GridBagLayout layout = (GridBagLayout) getLayout();
GridBagConstraints constraints = layout.getConstraints(text);
Button button = new Button("Browse...");
DirectoryListener listener = new DirectoryListener("Browse for " + label, text);
button.addActionListener(listener);
button.addKeyListener(this);
Panel panel = new Panel();
panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
panel.add(text);
panel.add(button);
layout.setConstraints(panel, constraints);
add(panel);
}
示例9: main
import java.awt.Panel; //导入方法依赖的package包/类
/**
* Run a demonstration.
*
* @param args ignored.
*
* @throws Exception when an error occurs.
*/
public static void main(final String[] args) throws Exception {
final Frame frame = new Frame();
final Panel panel = new Panel();
panel.setLayout(new RadialLayout());
panel.add(new Checkbox("One"));
panel.add(new Checkbox("Two"));
panel.add(new Checkbox("Three"));
panel.add(new Checkbox("Four"));
panel.add(new Checkbox("Five"));
panel.add(new Checkbox("One"));
panel.add(new Checkbox("Two"));
panel.add(new Checkbox("Three"));
panel.add(new Checkbox("Four"));
panel.add(new Checkbox("Five"));
frame.add(panel);
frame.setSize(300, 500);
frame.setVisible(true);
}
示例10: memoDialog
import java.awt.Panel; //导入方法依赖的package包/类
public memoDialog(Frame fr, Field f)
{
super(fr, f.getName(), true);
addWindowListener(this);
f1 = f;
text.setText(f1.get());
this.add("Center", text);
Panel p = new Panel();
p.setLayout(new FlowLayout(FlowLayout.CENTER, 15, 15));
p.add(Okay);
Okay.addActionListener(this);
this.add("East", p);
p.add(Cancel);
Cancel.addActionListener(this);
this.add("West", p);
this.pack();
}
示例11: createRowHeaderTable
import java.awt.Panel; //导入方法依赖的package包/类
private static RowHeaderTable createRowHeaderTable(Composite composite,
int width, int height, int rowHeaderWidth, int rowHeight,
boolean iconEnable, boolean editable) {
Frame frame = SWT_AWT.new_Frame(composite);
FlowLayout frameLayout = new FlowLayout();
frameLayout.setVgap(0);
frame.setLayout(frameLayout);
Panel panel = new Panel();
FlowLayout panelLayout = new FlowLayout();
panelLayout.setVgap(0);
panel.setLayout(panelLayout);
frame.add(panel);
RowHeaderTable table = new RowHeaderTable(width, height,
rowHeaderWidth, rowHeight, iconEnable, editable);
panel.add(table);
return table;
}
示例12: addSaveAsFileField
import java.awt.Panel; //导入方法依赖的package包/类
public static void addSaveAsFileField( final GenericDialogPlus dialog, final String label, final String defaultPath, final int columns) {
dialog.addStringField( label, defaultPath, columns );
final TextField text = ( TextField ) dialog.getStringFields().lastElement();
final GridBagLayout layout = ( GridBagLayout ) dialog.getLayout();
final GridBagConstraints constraints = layout.getConstraints( text );
final Button button = new Button( "Browse..." );
final ChooseXmlFileListener listener = new ChooseXmlFileListener( text );
button.addActionListener( listener );
button.addKeyListener( dialog );
final Panel panel = new Panel();
panel.setLayout( new FlowLayout( FlowLayout.LEFT, 0, 0 ) );
panel.add( text );
panel.add( button );
layout.setConstraints( panel, constraints );
dialog.add( panel );
}
示例13: PointListDialog
import java.awt.Panel; //导入方法依赖的package包/类
/**
* Constructs an empty PointListDialog
*
* @param owner
*/
public PointListDialog(final Frame owner) {
super(owner, "Point list");
panel = new Panel();
gridbag = new GridBagLayout();
panel.setLayout(gridbag);
panel.setBackground(Color.WHITE);
c = new GridBagConstraints();
c.gridx = 0;
c.gridy = 0;
c.anchor = GridBagConstraints.NORTHWEST;
c.weighty = 0.1f;
c.fill = GridBagConstraints.NONE;
final ScrollPane scroll = new ScrollPane();
scroll.add(panel);
add(scroll);
}
示例14: ConsolePanel
import java.awt.Panel; //导入方法依赖的package包/类
/**
* Create a new panel to display the console output
*
* @param e The exception causing the console to be displayed
*/
public ConsolePanel(Exception e) {
setLayout(new BorderLayout());
setBackground(Color.black);
setForeground(Color.white);
Font consoleFont = new Font("Arial", Font.BOLD, 14);
Label slickLabel = new Label("SLICK CONSOLE", Label.CENTER);
slickLabel.setFont(consoleFont);
add(slickLabel, BorderLayout.PAGE_START);
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw));
textArea.setText(sw.toString());
textArea.setEditable(false);
add(textArea, BorderLayout.CENTER);
// add a border on both sides of the console
add(new Panel(), BorderLayout.LINE_START);
add(new Panel(), BorderLayout.LINE_END);
Panel bottomPanel = new Panel();
bottomPanel.setLayout(new GridLayout(0, 1));
Label infoLabel1 = new Label("An error occured while running the applet.", Label.CENTER);
Label infoLabel2 = new Label("Plese contact support to resolve this issue.", Label.CENTER);
infoLabel1.setFont(consoleFont);
infoLabel2.setFont(consoleFont);
bottomPanel.add(infoLabel1);
bottomPanel.add(infoLabel2);
add(bottomPanel, BorderLayout.PAGE_END);
}
示例15: createBorderPanel
import java.awt.Panel; //导入方法依赖的package包/类
/**
* Method declaration
*
*
* @param center
*/
private Panel createBorderPanel(Component center) {
Panel p = new Panel();
p.setBackground(SystemColor.control);
p.setLayout(new BorderLayout());
p.add("Center", center);
p.add("South", createLabel(""));
p.add("East", createLabel(""));
p.add("West", createLabel(""));
p.setBackground(SystemColor.control);
return p;
}