本文整理匯總了Java中java.awt.Container.getWidth方法的典型用法代碼示例。如果您正苦於以下問題:Java Container.getWidth方法的具體用法?Java Container.getWidth怎麽用?Java Container.getWidth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.Container
的用法示例。
在下文中一共展示了Container.getWidth方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: saveGameRecord
import java.awt.Container; //導入方法依賴的package包/類
public void saveGameRecord(JFrame frame, String competidores, PvpScore pvpScore) {
try {
frame.validate();
frame.repaint();
Container c = frame.getContentPane();
c.validate();
c.repaint();
BufferedImage im = new BufferedImage(c.getWidth(), c.getHeight(), BufferedImage.TYPE_INT_ARGB);
c.paint(im.getGraphics());
pvpScore.setGameRecord(im);
} catch (Exception ex) {
Logger.getLogger(OthelloTournament.class
.getName()).log(Level.SEVERE, null, ex);
}
}
示例2: layoutContainer
import java.awt.Container; //導入方法依賴的package包/類
public void layoutContainer(Container container) {
Dimension tabSize = tabDisplayer.getPreferredSize();
Insets ins = container.getInsets();
int w = container.getWidth() - (ins.left + ins.right);
tabDisplayer.setBounds (ins.left, ins.top,
w,
tabSize.height);
if( tabDisplayer.getModel().size() > 1 ) {
//#214427 - check the preferred size again, during the first pass
//the tab displayer may not know the available width
Dimension newTabSize = tabDisplayer.getPreferredSize();
if( newTabSize.height != tabSize.height ) {
tabSize = newTabSize;
tabDisplayer.setBounds (ins.left, ins.top,
w,
tabSize.height);
}
}
contentDisplayer.setBounds(ins.left,
ins.top + tabSize.height, w,
container.getHeight() - (ins.top + ins.bottom + tabSize.height));
}
示例3: layoutContainer
import java.awt.Container; //導入方法依賴的package包/類
@Override
public void layoutContainer(Container parent) {
Insets in = parent.getInsets();
int maxWidth = parent.getWidth() - (in.left + in.right);
int maxHeight = parent.getHeight() - (in.top + in.bottom);
int split;
if (fraction <= 0.0) {
split = 0;
} else if (fraction >= 1.0) {
split = maxWidth;
} else {
split = (int) Math.round(maxHeight * fraction);
split = Math.min(split, maxHeight - comp1.getMinimumSize().height);
split = Math.max(split, comp0.getMinimumSize().height);
}
comp0.setBounds(in.left, in.top, maxWidth, split);
comp1.setBounds(in.left, in.top + split, maxWidth, maxHeight - split);
dragbar.setBounds(in.left, in.top + split - DRAG_TOLERANCE, maxWidth, 2 * DRAG_TOLERANCE);
}
示例4: layoutContainer
import java.awt.Container; //導入方法依賴的package包/類
/**
* Lays out the specified container.
*
* @param parent the container to be laid out
* @throws IllegalStateException if any of the components added to
* this layout are not in both a horizontal and vertical group
*/
public void layoutContainer(Container parent) {
// Step 1: Prepare for layout.
prepare(SPECIFIC_SIZE);
Insets insets = parent.getInsets();
int width = parent.getWidth() - insets.left - insets.right;
int height = parent.getHeight() - insets.top - insets.bottom;
boolean ltr = isLeftToRight();
if (getAutoCreateGaps() || getAutoCreateContainerGaps() ||
hasPreferredPaddingSprings) {
// Step 2: Calculate autopadding springs
calculateAutopadding(horizontalGroup, HORIZONTAL, SPECIFIC_SIZE, 0,
width);
calculateAutopadding(verticalGroup, VERTICAL, SPECIFIC_SIZE, 0,
height);
}
// Step 3: set the size of the groups.
horizontalGroup.setSize(HORIZONTAL, 0, width);
verticalGroup.setSize(VERTICAL, 0, height);
// Step 4: apply the size to the components.
for (ComponentInfo info : componentInfos.values()) {
info.setBounds(insets, width, ltr);
}
}
示例5: layoutContainer
import java.awt.Container; //導入方法依賴的package包/類
@Override
public void layoutContainer(Container parent) {
Insets in = parent.getInsets();
int maxWidth = parent.getWidth() - (in.left + in.right);
int maxHeight = parent.getHeight() - (in.top + in.bottom);
int split;
if (fraction <= 0.0) {
split = 0;
} else if (fraction >= 1.0) {
split = maxWidth;
} else {
split = (int) Math.round(maxWidth * fraction);
split = Math.min(split, maxWidth - comp1.getMinimumSize().width);
split = Math.max(split, comp0.getMinimumSize().width);
}
comp0.setBounds(in.left, in.top, split, maxHeight);
comp1.setBounds(in.left + split, in.top, maxWidth - split, maxHeight);
dragbar.setBounds(in.left + split - HorizontalSplitPane.DRAG_TOLERANCE, in.top,
2 * HorizontalSplitPane.DRAG_TOLERANCE, maxHeight);
}
示例6: layoutContainer
import java.awt.Container; //導入方法依賴的package包/類
@Override
public void layoutContainer(Container container) {
ComponentElement parent = (ComponentElement) container;
CssStyleDeclaration style = ((ComponentElement) parent).getComputedStyle();
float scale = parent.getOwnerDocument().getSettings().getScale();
float containingBoxWidth = container.getWidth() / scale;
float left = style.getPx(CssProperty.BORDER_LEFT_WIDTH, containingBoxWidth) +
style.getPx(CssProperty.PADDING_LEFT, containingBoxWidth);
float top = style.getPx(CssProperty.BORDER_TOP_WIDTH, containingBoxWidth) +
style.getPx(CssProperty.PADDING_TOP, containingBoxWidth);
float right = style.getPx(CssProperty.BORDER_RIGHT_WIDTH, containingBoxWidth) +
style.getPx(CssProperty.PADDING_RIGHT, containingBoxWidth);
layout.layout(parent, left, top, container.getWidth() - left - right, false);
}
示例7: layoutContainer
import java.awt.Container; //導入方法依賴的package包/類
/**
* {@inheritDoc}
*/
public void layoutContainer(Container parent) {
Insets insets = parent.getInsets();
int maxWidth = parent.getWidth() - (insets.left + insets.right);
int maxHeight = parent.getHeight() - (insets.top + insets.bottom);
int width = 0;
int height = 0;
width = ((maxWidth - gap * (MAX_COLUMNS + 1)) / MAX_COLUMNS);
height = ((maxHeight - gap * (MAX_ROWS + 1)) / MAX_ROWS);
componentDimension = new Dimension(width, height);
for (Component comp : parent.getComponents()) {
RCPosition position = components.get(comp);
int row = position.getRow();
int column = position.getColumn();
if (position != null) {
int x = insets.left + column * gap + (column - 1)
* componentDimension.width;
int y = insets.top + row * gap + (row - 1)
* componentDimension.height;
if (row == 1 && column == 1) {
comp.setBounds(x, y,
componentDimension.width * 5 + 4 * gap,
componentDimension.height);
} else {
comp.setBounds(x, y, componentDimension.width,
componentDimension.height);
}
}
}
}
示例8: layoutContainer
import java.awt.Container; //導入方法依賴的package包/類
public void layoutContainer(Container parent) {
int width = parent.getWidth();
for (int i = 0; i < parent.getComponentCount(); i++) {
ChartContext context = chart.getRow(i).getContext();
parent.getComponent(i).setBounds(0, Utils.checkedInt(context.getViewportOffsetY() + chart.getOffsetY()),
width, context.getViewportHeight());
}
}
示例9: getScrollableTracksViewportWidth
import java.awt.Container; //導入方法依賴的package包/類
@Override
public boolean getScrollableTracksViewportWidth() {
Container parent = SwingUtilities.getUnwrappedParent(this);
if (parent instanceof JViewport) {
return parent.getWidth() > getPreferredSize().width;
}
return false;
}
示例10: UpperPane
import java.awt.Container; //導入方法依賴的package包/類
public UpperPane(Container paneParent)
{
setLayout(LAYOUT);
int nWidth = paneParent.getWidth();
int nHeight = (int) ((double) paneParent.getHeight() * 0.065);
setSize(nWidth, nHeight);
}
示例11: layoutContainer
import java.awt.Container; //導入方法依賴的package包/類
/**
* Lays out the specified container.
*
* @param parent the container to be laid out
* @throws IllegalStateException if any of the components added to
* this layout are not in both a horizontal and vertical group
*/
public void layoutContainer(Container parent) {
// Step 1: Prepare for layout.
prepare(SPECIFIC_SIZE);
Insets insets = parent.getInsets();
int width = parent.getWidth() - insets.left - insets.right;
int height = parent.getHeight() - insets.top - insets.bottom;
boolean ltr = isLeftToRight();
if (getAutocreateGaps() || getAutocreateContainerGaps() ||
hasPreferredPaddingSprings) {
// Step 2: Calculate autopadding springs
calculateAutopadding(horizontalGroup, HORIZONTAL, SPECIFIC_SIZE, 0,
width);
calculateAutopadding(verticalGroup, VERTICAL, SPECIFIC_SIZE, 0,
height);
}
// Step 3: set the size of the groups.
horizontalGroup.setSize(HORIZONTAL, 0, width);
verticalGroup.setSize(VERTICAL, 0, height);
// Step 4: apply the size to the components.
Iterator componentInfo = componentInfos.values().iterator();
while (componentInfo.hasNext()) {
ComponentInfo info = (ComponentInfo)componentInfo.next();
Component c = info.getComponent();
info.setBounds(insets, width, ltr);
}
}
示例12: LHSListPane
import java.awt.Container; //導入方法依賴的package包/類
public LHSListPane(Container paneParent, JList lst)
{
lst.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
setViewportView(lst);
int nWidth = (int) ((double) paneParent.getWidth() * PERCENTAGE_WIDTH);
setSize(nWidth, paneParent.getHeight());
}
示例13: saveFinal
import java.awt.Container; //導入方法依賴的package包/類
public void saveFinal(JPanel panel, String jogoNro) {
try {
panel.validate();
panel.repaint();
panel.validate();
panel.repaint();
Container c = panel;
BufferedImage im = new BufferedImage(c.getWidth(), c.getHeight(), BufferedImage.TYPE_INT_ARGB);
c.paint(im.getGraphics());
ImageIO.write(im, "PNG", new File(PATH + File.separator + "jogo" + jogoNro + ".png"));
} catch (IOException ex) {
Logger.getLogger(OthelloTournament.class.getName()).log(Level.SEVERE, null, ex);
}
}
示例14: setText
import java.awt.Container; //導入方法依賴的package包/類
@Override
public void setText(String str) {
// System.out.println("setText(\""+str+"\")");
super.setText(str);
Container parent=getParent();
if(parent!=null){
int w=getWidth();
int p=parent.getWidth();
if(w>=p){
formComponentResized(null);
}
}
}
示例15: updateOrientation
import java.awt.Container; //導入方法依賴的package包/類
/** Checks the position of the tabbed container relative to its parent
* window, and potentially updates its orientation client property.
*
* @see TabDisplayer#PROP_ORIENTATION
*/
protected final void updateOrientation() {
if (!container.isDisplayable()) {
return;
}
if (Boolean.FALSE.equals(container.getClientProperty (TabbedContainer.PROP_MANAGE_TAB_POSITION))) {
//The client has specified that it does not want automatic management
//of the displayer orientation
return;
}
Object currOrientation = tabDisplayer.getClientProperty(TabDisplayer.PROP_ORIENTATION);
Container window = container.getTopLevelAncestor();
Rectangle containerBounds = container.getBounds();
containerBounds = SwingUtilities.convertRectangle(container, containerBounds, window);
boolean longestIsVertical = containerBounds.width < containerBounds.height;
int distanceToLeft = containerBounds.x;
int distanceToTop = containerBounds.y;
int distanceToRight = window.getWidth() - (containerBounds.x + containerBounds.width);
int distanceToBottom = window.getHeight() - (containerBounds.y + containerBounds.height);
Object orientation;
if (!longestIsVertical) {
if (distanceToBottom > distanceToTop) {
orientation = TabDisplayer.ORIENTATION_NORTH;
} else {
orientation = TabDisplayer.ORIENTATION_SOUTH;
}
} else {
if (distanceToLeft > distanceToRight) {
orientation = TabDisplayer.ORIENTATION_EAST;
} else {
orientation = TabDisplayer.ORIENTATION_WEST;
}
}
if (currOrientation != orientation) {
tabDisplayer.putClientProperty(
TabDisplayer.PROP_ORIENTATION, orientation);
container.validate();
}
}