本文整理匯總了Java中java.awt.Container.setLayout方法的典型用法代碼示例。如果您正苦於以下問題:Java Container.setLayout方法的具體用法?Java Container.setLayout怎麽用?Java Container.setLayout使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.Container
的用法示例。
在下文中一共展示了Container.setLayout方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: Swing02
import java.awt.Container; //導入方法依賴的package包/類
public Swing02() throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException {
setSize(200, 200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setResizable(false);
Container c = getContentPane();
c.setLayout(new BorderLayout());
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
setVisible(true);
}
示例2: InfoWindow
import java.awt.Container; //導入方法依賴的package包/類
protected InfoWindow(Frame parent, Color borderColor) {
super(parent);
setType(Window.Type.POPUP);
container = new Container() {
@Override
public Insets getInsets() {
return new Insets(1, 1, 1, 1);
}
};
setLayout(new BorderLayout());
setBackground(borderColor);
add(container, BorderLayout.CENTER);
container.setLayout(new BorderLayout());
closer = new Closer();
}
示例3: demoMenu
import java.awt.Container; //導入方法依賴的package包/類
/** Start a menu that allows the user to launch a number of demos for the
* JSpikeStack package. To add a new demo to the menu:
* 1) Add the appropriate element to the "Demos" enumerator (above);
* 2) Add the button in demoMenu()
* 3) Connect the enumerator element to the appropriate function in DemoLauncher through the switch statement.
*/
public static void demoMenu()
{
JFrame frm=new JFrame();
frm.setTitle("JSpikeStack demos");
Container pane=frm.getContentPane();
JButton button;
pane.setLayout(new GridBagLayout());
addDemoButton("Network Generation Demo","Read a network From XML and let it generate",Demos.GENERATE,pane);
addDemoButton("Learning Demo","Read an AER file, initialize a random net, and run STDP learning",Demos.LEARN,pane);
addDemoButton("Convolution Demo", "Here we read data from the Silicon retina. Two output layers respond to vertically and horizontally oriented features.",Demos.CONV,pane);
addDemoButton("RC Network", "Takes retina inputs and fires them to a smoothing network.",Demos.RCNET,pane);
addDemoButton("Retina", "In this demo we mimic the behaviour of a variety of types of retinal ganglion cell.",Demos.RETINA,pane);
frm.setPreferredSize(new Dimension(500,500));
frm.pack();
frm.setVisible(true);
frm.toFront();
frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
示例4: init
import java.awt.Container; //導入方法依賴的package包/類
private static void init(Container container) {
container.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.BOTH;
gbc.gridx = 0;
gbc.gridy = 1;
JLabel label = new JLabel();
Dimension size = new Dimension(111, 0);
label.setPreferredSize(size);
label.setMinimumSize(size);
container.add(label, gbc);
gbc.gridx = 1;
gbc.weightx = 1;
container.add(new JScrollBar(JScrollBar.HORIZONTAL, 1, 111, 1, 1111), gbc);
gbc.gridx = 2;
gbc.gridy = 0;
gbc.weightx = 0;
gbc.weighty = 1;
container.add(new JScrollBar(JScrollBar.VERTICAL, 1, 111, 1, 1111), gbc);
}
示例5: Swing04
import java.awt.Container; //導入方法依賴的package包/類
public Swing04() {
setTitle("null");
setSize(200, 200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
c.setLayout(null);
JButton btn1 = new JButton("One");
btn1.setBounds(10, 10, 100, 50);
JButton btn2 = new JButton("Two");
btn2.setBounds(100, 100, 100, 50);
c.add(btn1);
c.add(btn2);
setVisible(true);
}
示例6: initPageDialog
import java.awt.Container; //導入方法依賴的package包/類
/**
* Initialize "page setup" dialog
*/
void initPageDialog(int x, int y,
PrintService ps,
DocFlavor flavor,
PrintRequestAttributeSet attributes)
{
this.psCurrent = ps;
this.docFlavor = flavor;
this.asOriginal = attributes;
this.asCurrent = new HashPrintRequestAttributeSet(attributes);
Container c = getContentPane();
c.setLayout(new BorderLayout());
pnlPageSetup = new PageSetupPanel();
c.add(pnlPageSetup, BorderLayout.CENTER);
pnlPageSetup.updateInfo();
JPanel pnlSouth = new JPanel(new FlowLayout(FlowLayout.TRAILING));
btnApprove = createExitButton("button.ok", this);
pnlSouth.add(btnApprove);
getRootPane().setDefaultButton(btnApprove);
btnCancel = createExitButton("button.cancel", this);
handleEscKey(btnCancel);
pnlSouth.add(btnCancel);
c.add(pnlSouth, BorderLayout.SOUTH);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent event) {
dispose(CANCEL);
}
});
getAccessibleContext().setAccessibleDescription(getMsg("dialog.pstitle"));
setResizable(false);
setLocation(x, y);
pack();
}
示例7: ShowGPL
import java.awt.Container; //導入方法依賴的package包/類
/**
* The class constructor puts all graphics application's components.
*/
public ShowGPL() {
super("DicomReader is under the GNU General Public License");
// Main container
Container c = getContentPane();
c.setLayout(new BorderLayout(10, 10));
// resultPanel resultArea
JPanel resultPanel = new JPanel();
resultPanel.setLayout(new BorderLayout(10, 10));
resultArea = new JTextArea();
resultArea.setLineWrap(true);
resultArea.setWrapStyleWord(true);
resultArea.setOpaque(false);
resultArea.setEditable(false);
//resultArea.setFont(new Font("Lucida Console", Font.PLAIN, 12));
//resultArea.setFont(new JLabel().getFont());
JScrollPane scrollPanel = new JScrollPane(resultArea);
resultPanel.add(scrollPanel);
c.add(resultPanel, BorderLayout.CENTER);
// bottomPanel
JPanel bottomPanel = new JPanel();
JLabel bottomLabel = new JLabel(appName);
bottomLabel.setEnabled(false);
bottomPanel.add(bottomLabel);
c.add(bottomPanel, BorderLayout.SOUTH);
}
示例8: StatisticsDialog
import java.awt.Container; //導入方法依賴的package包/類
private StatisticsDialog(JFrame parent, String circuitName, StatisticsTableModel model) {
super(parent, true);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
setTitle(Strings.get("statsDialogTitle", circuitName));
JTable table = new StatisticsTable();
TableSorter mySorter = new TableSorter(model, table.getTableHeader());
Comparator<String> comp = new CompareString("", Strings.get("statsTotalWithout"),
Strings.get("statsTotalWith"));
mySorter.setColumnComparator(String.class, comp);
table.setModel(mySorter);
JScrollPane tablePane = new JScrollPane(table);
JButton button = new JButton(Strings.get("statsCloseButton"));
button.addActionListener(this);
JPanel buttonPanel = new JPanel();
buttonPanel.add(button);
Container contents = this.getContentPane();
contents.setLayout(new BorderLayout());
contents.add(tablePane, BorderLayout.CENTER);
contents.add(buttonPanel, BorderLayout.PAGE_END);
this.pack();
this.setLocationRelativeTo(null);
Dimension pref = contents.getPreferredSize();
if (pref.width > 750 || pref.height > 550) {
if (pref.width > 750)
pref.width = 750;
if (pref.height > 550)
pref.height = 550;
this.setSize(pref);
}
}
示例9: createDialog
import java.awt.Container; //導入方法依賴的package包/類
/**
* Creates and returns a new <code>JDialog</code> wrapping
* <code>this</code> centered on the <code>parent</code>
* in the <code>parent</code>'s frame.
* This method can be overriden to further manipulate the dialog,
* to disable resizing, set the location, etc. Example:
* <pre>
* class MyFileChooser extends JFileChooser {
* protected JDialog createDialog(Component parent) throws HeadlessException {
* JDialog dialog = super.createDialog(parent);
* dialog.setLocation(300, 200);
* dialog.setResizable(false);
* return dialog;
* }
* }
* </pre>
*
* @param parent the parent component of the dialog;
* can be <code>null</code>
* @return a new <code>JDialog</code> containing this instance
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
* returns true.
* @see java.awt.GraphicsEnvironment#isHeadless
* @since 1.4
*/
protected JDialog createDialog(Component parent) throws HeadlessException {
FileChooserUI ui = getUI();
String title = ui.getDialogTitle(this);
putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY,
title);
JDialog dialog;
Window window = JOptionPane.getWindowForComponent(parent);
if (window instanceof Frame) {
dialog = new JDialog((Frame)window, title, true);
} else {
dialog = new JDialog((Dialog)window, title, true);
}
dialog.setComponentOrientation(this.getComponentOrientation());
Container contentPane = dialog.getContentPane();
contentPane.setLayout(new BorderLayout());
contentPane.add(this, BorderLayout.CENTER);
if (JDialog.isDefaultLookAndFeelDecorated()) {
boolean supportsWindowDecorations =
UIManager.getLookAndFeel().getSupportsWindowDecorations();
if (supportsWindowDecorations) {
dialog.getRootPane().setWindowDecorationStyle(JRootPane.FILE_CHOOSER_DIALOG);
}
}
dialog.pack();
dialog.setLocationRelativeTo(parent);
return dialog;
}
示例10: Wizard
import java.awt.Container; //導入方法依賴的package包/類
public Wizard() {
super(true);
panels = new ArrayList<WizardPanel>();
currentIndex = -1;
panelCount = 0;
tabbedPane = makeTabbedPane();
buttons = makeButtons();
Container cp = getContentPane();
cp.setLayout(new BorderLayout());
cp.add(tabbedPane, BorderLayout.CENTER);
cp.add(buttons, BorderLayout.SOUTH);
updateActions();
}
示例11: prepareControls
import java.awt.Container; //導入方法依賴的package包/類
@Override
protected void prepareControls() {
JFrame frame = new JFrame("Glass Pane children test");
frame.setLayout(null);
Container contentPane = frame.getContentPane();
contentPane.setLayout(new BorderLayout());
super.propagateAWTControls(contentPane);
Container glassPane = (Container) frame.getRootPane().getGlassPane();
glassPane.setVisible(true);
glassPane.setLayout(null);
internalFrame = new JInternalFrame("Internal Frame", true);
internalFrame.setBounds(50, 0, 200, 100);
internalFrame.setVisible(true);
glassPane.add(internalFrame);
internalFrame.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
lwClicked = true;
}
});
frame.setSize(300, 180);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
示例12: setupGUI
import java.awt.Container; //導入方法依賴的package包/類
private void setupGUI()
{
Container contents = getContentPane();
contents.setLayout(new MigLayout("wrap 3", "[grow][grow][grow]"));
configs = new ArrayList<ConfigProfile>();
lblConfig = new JLabel("Configurations: ");
cmbConfigs = new JComboBox<ConfigProfile>();
btnNew = new JButton("New");
btnNew.addActionListener(this);
btnApply = new JButton("Apply Configuration");
btnApply.addActionListener(this);
btnEdit = new JButton("Edit");
btnEdit.addActionListener(this);
sep = new JSeparator();
btnDelete = new JButton("Delete");
btnDelete.addActionListener(this);
contents.add(lblConfig, "growx, spanx 3");
contents.add(cmbConfigs, "growx, spanx 3");
contents.add(btnNew, "growx, center");
contents.add(btnEdit, "growx, center");
contents.add(btnDelete, "growx, center");
contents.add(sep, "growx, spanx 3");
contents.add(btnApply, "center, growx, spanx 3");
}
示例13: start
import java.awt.Container; //導入方法依賴的package包/類
public void start() {
frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container contentPane = frame.getContentPane();
comboBox = new JComboBox<String>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" });
contentPane.setLayout(new FlowLayout());
contentPane.add(comboBox);
frame.setLocationRelativeTo(null);
frame.pack();
frame.setVisible(true);
}
示例14: OkCancelDialog
import java.awt.Container; //導入方法依賴的package包/類
public OkCancelDialog(String title, JPanel panel, boolean modal)
{
setTitle(title);
setModal(modal);
Container pane = getContentPane();
pane.setLayout(new BorderLayout());
pane.add(panel, "Center");
pane.add(new OkCancelButtonPanel(this), "South");
pack();
CommonUI.centerComponent(this);
}
示例15: init
import java.awt.Container; //導入方法依賴的package包/類
public void init() {
Container content = getContentPane();
content.setLayout(new BorderLayout());
// Proxy info table
grid = getPanel(new GridLayout(2,3,2,2));
grid.add(getHeaderLabel("URL"));
grid.add(getHeaderLabel("Proxy Host"));
grid.add(getHeaderLabel("Proxy Port"));
grid.add(urlTextField);
hostLabel = getLabel("");
portLabel = getLabel("");
grid.add(hostLabel);
grid.add(portLabel);
grid.validate();
content.add(grid, BorderLayout.CENTER);
// Button panel - SOUTH
JPanel buttonPanel = getPanel(new FlowLayout());
JButton button = new JButton("Detect Proxy");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
detectProxy();
}
});
}
});
buttonPanel.add(button);
content.add(buttonPanel, BorderLayout.SOUTH);
// version panel - NORTH
JPanel versionPanel = getPanel(new FlowLayout());
String javaVersion = System.getProperty("java.runtime.version");
JLabel versionLabel = getLabel("Java Version: "+javaVersion);
versionPanel.add(versionLabel);
content.add(versionPanel, BorderLayout.NORTH);
validate();
super.setSize(400,100);
}