本文整理汇总了Java中java.awt.LayoutManager类的典型用法代码示例。如果您正苦于以下问题:Java LayoutManager类的具体用法?Java LayoutManager怎么用?Java LayoutManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LayoutManager类属于java.awt包,在下文中一共展示了LayoutManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import java.awt.LayoutManager; //导入依赖的package包/类
/**
* Initialisationsmethode, die in jedem Konstruktor benutzt wird
* @param layout
* @param panels
*/
void initialize(LayoutManager layout, ArrayList<JPanel> panels){
this.setLayout(layout);
for(JPanel panel: panels){
this.add(panel);
}
this.setTitle("Random Music Generator Canon");
this.setSize(1200, 700);
//places Frame in the middle of the screen
this.setLocationRelativeTo(null);
this.setResizable(true);
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
this.addWindowListener(new defaultWindowListener());
//adjusting look to local system
try {
UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
} catch (ClassNotFoundException | InstantiationException
| IllegalAccessException | UnsupportedLookAndFeelException e) {
e.printStackTrace();
}
//shows the Frame on the screen
this.setVisible(true);
}
示例2: GridBagInfoProvider
import java.awt.LayoutManager; //导入依赖的package包/类
public GridBagInfoProvider(Container container, LayoutSupportManager layoutManager) {
this.container = container;
this.layoutManager = layoutManager;
LayoutManager containerLayout = container.getLayout();
if (!(containerLayout instanceof GridBagLayout)) {
throw new IllegalArgumentException();
}
try {
tempXField = GridBagConstraints.class.getDeclaredField("tempX"); // NOI18N
tempXField.setAccessible(true);
tempYField = GridBagConstraints.class.getDeclaredField("tempY"); // NOI18N
tempYField.setAccessible(true);
tempHeightField = GridBagConstraints.class.getDeclaredField("tempHeight"); // NOI18N
tempHeightField.setAccessible(true);
tempWidthField = GridBagConstraints.class.getDeclaredField("tempWidth"); // NOI18N
tempWidthField.setAccessible(true);
} catch (NoSuchFieldException nsfex) {
FormUtils.LOGGER.log(Level.INFO, nsfex.getMessage(), nsfex);
}
containerEmphColor = deriveEmphColor(container);
}
示例3: createButtonPanel
import java.awt.LayoutManager; //导入依赖的package包/类
/** Create a panel with buttons that will be placed according
* to the required alignment */
private JPanel createButtonPanel( JButton[] buttons, boolean sidebuttons ) {
int count = buttons.length;
JPanel outerPanel = new JPanel( new BorderLayout() );
outerPanel.setBorder( new EmptyBorder( new Insets(
sidebuttons ? 5 : 0, sidebuttons ? 0 : 5, 5, 5 ) ) );
LayoutManager lm = new GridLayout( // GridLayout makes equal cells
sidebuttons ? count : 1, sidebuttons ? 1 : count, 5, 5 );
JPanel innerPanel = new JPanel( lm );
for( int i = 0; i < count; i++ ) innerPanel.add( buttons[i] );
outerPanel.add( innerPanel,
sidebuttons ? BorderLayout.NORTH : BorderLayout.EAST ) ;
return outerPanel;
}
示例4: resolveToolbarConstraint
import java.awt.LayoutManager; //导入依赖的package包/类
/**
* Package private method which returns either BorderLayout.NORTH,
* BorderLayout.SOUTH, BorderLayout.EAST, or BorderLayout.WEST depending
* on the location of the toolbar in its parent. The toolbar might be
* in PAGE_START, PAGE_END, CENTER, or some other position, but will be
* resolved to either NORTH,SOUTH,EAST, or WEST based on where the toolbar
* actually IS, with CENTER being NORTH.
*
* This code is used to determine where the border line should be drawn
* by the custom toolbar states, and also used by NimbusIcon to determine
* whether the handle icon needs to be shifted to look correct.
*
* Toollbars are unfortunately odd in the way these things are handled,
* and so this code exists to unify the logic related to toolbars so it can
* be shared among the static files such as NimbusIcon and generated files
* such as the ToolBar state classes.
*/
static Object resolveToolbarConstraint(JToolBar toolbar) {
//NOTE: we don't worry about component orientation or PAGE_END etc
//because the BasicToolBarUI always uses an absolute position of
//NORTH/SOUTH/EAST/WEST.
if (toolbar != null) {
Container parent = toolbar.getParent();
if (parent != null) {
LayoutManager m = parent.getLayout();
if (m instanceof BorderLayout) {
BorderLayout b = (BorderLayout)m;
Object con = b.getConstraints(toolbar);
if (con == SOUTH || con == EAST || con == WEST) {
return con;
}
return NORTH;
}
}
}
return NORTH;
}
示例5: createSnapshotLayout
import java.awt.LayoutManager; //导入依赖的package包/类
@Override
public void createSnapshotLayout(final SnapshotContext context,
final JComponent parent,
final RadContainer container,
final LayoutManager layout) {
GridLayout gridLayout = (GridLayout) layout;
int ncomponents = parent.getComponentCount();
int nrows = gridLayout.getRows();
int ncols = gridLayout.getColumns();
if (nrows > 0) {
ncols = (ncomponents + nrows - 1) / nrows;
} else {
nrows = (ncomponents + ncols - 1) / ncols;
}
container.setLayout(new GridLayoutManager(nrows, ncols,
new Insets(0, 0, 0, 0),
gridLayout.getHgap(), gridLayout.getVgap(),
true, true));
}
示例6: getMainJPanel
import java.awt.LayoutManager; //导入依赖的package包/类
private JPanel getMainJPanel() {
JPanel mainJPanel = new JPanel();
LayoutManager layout = new BoxLayout(mainJPanel, BoxLayout.Y_AXIS);
mainJPanel.setLayout(layout);
JPanel logPatternJPanel = getLogPatternJPanel();
JPanel buttonsJPanel = getButtonsJPanel();
mainJPanel.add(logPatternJPanel);
mainJPanel.add(Box.createRigidArea(new Dimension(4, 2)));
mainJPanel.add(buttonsJPanel);
mainJPanel.add(Box.createRigidArea(new Dimension(4, 4)));
// mainJPanel.add(Box.createHorizontalGlue());
return mainJPanel;
}
示例7: setLayout
import java.awt.LayoutManager; //导入依赖的package包/类
/**
* Sets the <code>LayoutManager</code>. Overridden to conditionally forward
* the call to the <code>contentPane</code>. Refer to
* {@link javax.swing.RootPaneContainer} for more information.<p>
*
* <b>Wichtig:</b><br>
* Der neue <code>LayoutManager</code> sollte ein
* <code>PRoBorderLayout</code> sein, da das Hinzuf�gen der Komponenten in
* der Methode <code>init()</code> sich auf das Layout
* <code>PRoBorderLayout</code> bezieht.<br>
* M�chten Sie ein anderes Layout implementieren, dann ist die Methode
* <code>init()</code> zu �berlagern.
*
* @param manager the <code>LayoutManager</code>
* @see #setRootPaneCheckingEnabled
* @see javax.swing.RootPaneContainer
*/
@Override
public final void setLayout(final LayoutManager manager) {
if (init) {
ppPRoDialog.removeAll();
ppPRoDialog.setLayout(manager);
this.getContentPane().removeAll();
this.init();
}
if (!init) {
if (rootPaneCheckingEnabled) {
this.getContentPane().setLayout(manager);
} else {
super.setLayout(manager);
}
}
}
示例8: addGridBagComponent
import java.awt.LayoutManager; //导入依赖的package包/类
public static void addGridBagComponent( Container container,
Component component,
int gridX, int gridY,
int gridWidth, int gridHeight,
int fill, int anchor, Insets insets )
throws AWTException {
LayoutManager lm = container.getLayout();
if ( !( lm instanceof GridBagLayout ) ) {
throw new AWTException( "Invalid layout: " + lm );
}
else {
GridBagConstraints gbc = getGridBagConstraints( gridX, gridY,
gridWidth, gridHeight, fill, anchor );
gbc.insets = insets;
( (GridBagLayout) lm ).setConstraints( component, gbc );
container.add( component );
}
}
示例9: getTracerInfoJPanel
import java.awt.LayoutManager; //导入依赖的package包/类
private JPanel getTracerInfoJPanel() {
JPanel infoJPanel = new JPanel();
LayoutManager layout = new BoxLayout(infoJPanel, BoxLayout.X_AXIS);
infoJPanel.setLayout(layout);
// Dimension preferredSize = new Dimension(300, 30);
// infoJPanel.setPreferredSize(preferredSize);
JPanel incompleteTracerJPanel = getIncompleteTracerJPanel();
JPanel charsetJPanel = getCharsetJPanel();
JPanel sizeJPanel = getSizeJPanel();
infoJPanel.add(incompleteTracerJPanel);
infoJPanel.add(charsetJPanel);
infoJPanel.add(sizeJPanel);
return infoJPanel;
}
示例10: setLayout
import java.awt.LayoutManager; //导入依赖的package包/类
@Override
public void setLayout(LayoutManager mgr) {
if (mgr != null) {
throw new UnsupportedOperationException(
"PlaceholderPanel's layout manager cannot be changed.");//NOI18N
}
}
示例11: createLayoutManager
import java.awt.LayoutManager; //导入依赖的package包/类
@Override
protected LayoutManager createLayoutManager() {
if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) {
// can't override because private class..
return super.createLayoutManager();
} else {
// override for docking framework spacing fix!
return new BasicTabbedPaneUI.TabbedPaneLayout() {
@Override
protected void calculateTabRects(int tabPlacement, int tabCount) {
final int spacer = -5;
final int indent = 0;
super.calculateTabRects(tabPlacement, tabCount);
for (int i = 1; i < rects.length; i++) {
// hack to get the tabs closer together. Don't shift leftmost tab(s)
if (rects[i].x > 0) {
rects[i].x += i * spacer + indent;
}
}
}
};
}
}
示例12: setVisible
import java.awt.LayoutManager; //导入依赖的package包/类
/**
* This funcion is overridden to make sure that the parent layout
* is redone when the GlobalMap is shown.
*/
public void setVisible(boolean visible) {
super.setVisible(visible);
if (visible) {
final LayoutManager l = getParent().getLayout();
if (l instanceof Map.InsetLayout) {
l.layoutContainer(getParent());
}
}
}
示例13: getLayout
import java.awt.LayoutManager; //导入依赖的package包/类
private LayoutManager getLayout(Container c) {
if (fixed) {
return new GridLayout(0, nColumns);
}
else {
return new BoxLayout(c, vertical ? BoxLayout.Y_AXIS : BoxLayout.X_AXIS);
}
}
示例14: setupGui
import java.awt.LayoutManager; //导入依赖的package包/类
protected void setupGui()
{
final JLabel canvasUrlLabel = new JLabel(getString("label.canvasurl"));
final JLabel clientIdLabel = new JLabel(getString("label.clientid"));
final JLabel secretLabel = new JLabel(getString("label.secret"));
preamble = new JLabel(getString("preamble", CANVAS_SIGNUP_URL));
preamble.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
preamble.addMouseListener(this);
canvasUrl = new JTextField(20);
clientId = new JTextField(20);
secret = new JPasswordField(20);
bypassLogon = new JCheckBox();
bypassLogon.setText(getString("label.bypasslogon"));
final LayoutManager layout = new MigLayout("wrap", "[fill][fill,grow]");
setLayout(layout);
setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
add(preamble, "span 2, gapbottom 20");
add(canvasUrlLabel);
add(canvasUrl);
add(clientIdLabel);
add(clientId);
add(secretLabel);
add(secret);
add(bypassLogon, "span 2");
validate();
}
示例15: init
import java.awt.LayoutManager; //导入依赖的package包/类
private void init(LayoutManager layout, Rectangle radioPosition)
{
setLayout(layout);
if( radioPosition == null )
{
add(radio);
}
else
{
add(radio, radioPosition);
}
radio.addItemListener(this);
}