本文整理汇总了Java中java.awt.Insets类的典型用法代码示例。如果您正苦于以下问题:Java Insets类的具体用法?Java Insets怎么用?Java Insets使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Insets类属于java.awt包,在下文中一共展示了Insets类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addPapers
import java.awt.Insets; //导入依赖的package包/类
private void addPapers() {
//out("Add papers");
myPaperPanel.removeAll();
if (getPaperCount() == 0) {
updatePaperPanel();
return;
}
int gap = getGap();
GridBagConstraints c = new GridBagConstraints();
c.insets = new Insets(gap, gap, 0, 0);
if (isSingleMode()) {
myPaperPanel.add(myPapers.get(myPaperNumber - 1), c);
}
else {
for (Paper paper : myPapers) {
c.gridx = paper.getColumn();
c.gridy = paper.getRow();
myPaperPanel.add(paper, c);
}
}
updatePaperPanel();
}
示例2: centerWindow
import java.awt.Insets; //导入依赖的package包/类
/**
* Sets size of this window and centers it on the page
* @param width width of the window
* @param height height of the window
*/
public void centerWindow(int width, int height) {
//size of the screen
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
//reads insets given by task bars
Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(getGraphicsConfiguration());
int availableWidth = screenSize.width - insets.left - insets.right;
int availableHeight = screenSize.height - insets.top - insets.bottom;
// Avoid to draw screens that are not visible and above taskbar
if (width > availableWidth) {
width = availableWidth;
}
if (height > availableHeight) {
height = availableHeight;
}
//gets dimensions of the screen to center window.
int xOffset = insets.left + (availableWidth - width) / 2;
int yOffset = insets.top + (availableHeight - height) / 2;
setBounds(xOffset, yOffset, width, height);
}
示例3: Push
import java.awt.Insets; //导入依赖的package包/类
public Push() {
setUndecorated(true);
setSize(300, 100);
this.setAlwaysOnTop(true);
// size of the screen
final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
// height of the task bar
final Insets scnMax = Toolkit.getDefaultToolkit().getScreenInsets(
getGraphicsConfiguration());
final int taskBarSize = scnMax.bottom;
setLocation(screenSize.width - getWidth(), screenSize.height - taskBarSize
- getHeight());
// background paint
lpg = new LinearGradientPaint(0, 0, 0, getHeight() / 2, new float[] { 0f,
0.3f, 1f }, new Color[] { new Color(0.8f, 0.8f, 1f),
new Color(0.7f, 0.7f, 1f), new Color(0.6f, 0.6f, 1f) });
// blue background panel
setContentPane(new BackgroundPanel());
}
示例4: add
import java.awt.Insets; //导入依赖的package包/类
private void add(String labelKey, JComponent component, JComponent button) {
GridBagConstraints c = new GridBagConstraints();
c.anchor = 23;
c.weightx = 0.5D;
c.weighty = 1.0D;
c.fill = 1;
c.gridheight = 1;
ResourceLabel label = new ResourceLabel("manage_database_drivers." + labelKey, new Object[0]);
label.setLabelFor(component);
c.gridwidth = 0;
this.add(label, c);
c.insets = new Insets(0, 0, 5, 0);
if(button == null) {
c.gridwidth = 0;
this.add(component, c);
} else {
c.gridwidth = -1;
c.weightx = 1.0D;
this.add(component, c);
c.gridwidth = 0;
c.weightx = 0.0D;
c.insets = new Insets(0, 5, 5, 0);
this.add(button, c);
}
}
示例5: initLeft
import java.awt.Insets; //导入依赖的package包/类
private void initLeft() {
final JPanel pnlLeft = new JPanel(new GridBagLayout());
notificationTable = (NotificationTable) notificationManager.getComponent();
initNotificationTable();
notificationScroll = new JScrollPane(notificationTable);
pnlSearch = new JPanel(new GridBagLayout());
GridBagConstraints searchConstrains = new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
quickSearch = QuickSearch.attach(pnlSearch, searchConstrains, filterCallback, true);
pnlSearch.add(new JLabel(), new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
setSearchVisible(btnSearch.isSelected());
pnlLeft.add(pnlSearch, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.SOUTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
pnlLeft.add(notificationScroll, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
splitPane.setLeftComponent(pnlLeft);
}
示例6: getDetailsPanel
import java.awt.Insets; //导入依赖的package包/类
private static JComponent getDetailsPanel(String summary) {
JPanel details = new JPanel(new GridBagLayout());
details.setOpaque(false);
JLabel lblMessage = new JLabel(summary);
JButton reportLink = new JButton("<html><a href=\"_blank\">" + NbBundle.getMessage(NotifyExcPanel.class, "NTF_ExceptionalExceptionReport")); //NOI18N
reportLink.setFocusable(false);
reportLink.setBorder(BorderFactory.createEmptyBorder());
reportLink.setBorderPainted(false);
reportLink.setFocusPainted(false);
reportLink.setOpaque(false);
reportLink.setContentAreaFilled(false);
reportLink.addActionListener(flash);
reportLink.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
details.add(reportLink, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 0, 3, 0), 0, 0));
details.add(lblMessage, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 0, 3, 0), 0, 0));
return details;
}
示例7: rebuildContent
import java.awt.Insets; //导入依赖的package包/类
private JPanel rebuildContent(List<UnloadedProjectInformation> projects) {
JPanel panel = new JPanel( new GridBagLayout() );
panel.setOpaque( false );
int row = 0;
for( UnloadedProjectInformation p : projects ) {
addProject( panel, row++, p );
if( row >= MAX_PROJECTS )
break;
}
if( 0 == row ) {
panel.add( new JLabel(BundleSupport.getLabel( "NoRecentProject" )), //NOI18N
new GridBagConstraints( 0,row,1,1,1.0,1.0,
GridBagConstraints.CENTER, GridBagConstraints.NONE,
new Insets(10,10,10,10), 0, 0 ) );
} else {
panel.add( new JLabel(), new GridBagConstraints( 0,row,1,1,0.0,1.0,
GridBagConstraints.CENTER, GridBagConstraints.NONE,
new Insets(0,0,0,0), 0, 0 ) );
}
return panel;
}
示例8: addSwitchViewButton
import java.awt.Insets; //导入依赖的package包/类
/**
* Adds the switchView button the the panel
*
* @param gbc
* - the constraints used for this component
*/
private void addSwitchViewButton(GridBagConstraints gbc) {
gbc.insets = new Insets(UIConstants.COMPONENT_TOP_PADDING, UIConstants.COMPONENT_LEFT_PADDING,
UIConstants.COMPONENT_BOTTOM_PADDING, UIConstants.COMPONENT_RIGHT_PADDING);
gbc.anchor = GridBagConstraints.EAST;
gbc.fill = GridBagConstraints.NONE;
gbc.gridx = 2;
gbc.gridy = 0;
gbc.weightx = 0;
gbc.weighty = 0;
JToolBar toolbar = new JToolBar();
switchViewButton = new ToolbarButton(null, false);
switchViewButton.setToolTipText(translator.getTranslation(Tags.CHANGE_TREE_VIEW_BUTTON_TOOLTIP));
URL resource = currentViewMode == ResourcesViewMode.FLAT_VIEW
? getClass().getResource(ImageConstants.TREE_VIEW)
: getClass().getResource(ImageConstants.TABLE_VIEW);
if (resource != null) {
ImageIcon icon = (ImageIcon) imageUtilities.loadIcon(resource);
switchViewButton.setIcon(icon);
}
toolbar.add(switchViewButton);
toolbar.setFloatable(false);
toolbar.setOpaque(false);
this.add(toolbar, gbc);
}
示例9: zoomIn
import java.awt.Insets; //导入依赖的package包/类
public void zoomIn(Point p) {
if( image==null )return;
Insets ins = border.getBorderInsets(this);
Rectangle rect = getVisibleRect();
double zoomX = getZoomX();
double zoomY = getZoomY();
double x = (double) (p.x - ins.left) / zoomX;
double y = (double) (p.y - ins.top) / zoomY;
double w = (double) rect.width - ins.left - ins.right;
double h = (double) rect.height - ins.top - ins.bottom;
if(xAvg==1) xRep*=2;
else xAvg /=2;
if(yAvg==1) yRep*=2;
else yAvg /=2;
zoomX = getZoomX();
zoomY = getZoomY();
invalidate();
int newX = (int) (x*zoomX - rect.getWidth()*.5d);
int newY = (int) (y*zoomY - rect.getHeight()*.5d);
synchronized(this) {
scroller.validate();
}
scroller.scrollTo(new Point(newX, newY));
repaint();
}
示例10: initializeComboBoxes
import java.awt.Insets; //导入依赖的package包/类
private void initializeComboBoxes() throws Exception {
List<LocalidadeVO> localidades = this.cadastroRota.recuperarLocalidades();
this.cboxOrigem = new JComboBox<LocalidadeVO>();
this.startComboBoxValues(this.cboxOrigem, localidades);
GridBagConstraints gbc_comboBox = new GridBagConstraints();
gbc_comboBox.insets = new Insets(0, 0, 5, 5);
gbc_comboBox.fill = GridBagConstraints.HORIZONTAL;
gbc_comboBox.gridx = 3;
gbc_comboBox.gridy = 3;
this.panel.add(this.cboxOrigem, gbc_comboBox);
this.cboxDestino = new JComboBox<LocalidadeVO>();
this.startComboBoxValues(this.cboxDestino, localidades);
GridBagConstraints gbc_comboBox_1 = new GridBagConstraints();
gbc_comboBox_1.insets = new Insets(0, 0, 5, 5);
gbc_comboBox_1.fill = GridBagConstraints.HORIZONTAL;
gbc_comboBox_1.gridx = 3;
gbc_comboBox_1.gridy = 8;
this.panel.add(this.cboxDestino, gbc_comboBox_1);
}
示例11: addLink
import java.awt.Insets; //导入依赖的package包/类
private int addLink( int row, DataObject dob ) {
Action action = extractAction( dob );
if( null != action ) {
JPanel panel = new JPanel( new GridBagLayout() );
panel.setOpaque(false);
ActionButton lb = new ActionButton( action, Utils.getUrlString( dob ),
Utils.getLinkColor(), false, dob.getPrimaryFile().getPath() );
panel.add( lb, new GridBagConstraints(1,0,1,3,0.0,0.0,GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,0,0,0),0,0) );
lb.setFont( BUTTON_FONT );
panel.add( new JLabel(),
new GridBagConstraints(2,0,1,3,1.0,0.0,GridBagConstraints.WEST,GridBagConstraints.BOTH,new Insets(0,0,0,0),0,0) );
lb.getAccessibleContext().setAccessibleName( lb.getText() );
//TODO fix acn
lb.getAccessibleContext().setAccessibleDescription(
BundleSupport.getAccessibilityDescription( "GettingStarted", lb.getText() ) ); //NOI18N
add( panel, new GridBagConstraints( 0,row++,1,1,1.0,0.0,
GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL,
new Insets(0,0,7,0), 0, 0 ) );
}
return row;
}
示例12: add
import java.awt.Insets; //导入依赖的package包/类
/**
* Adds a subplot with a particular weight (greater than or equal to one). The weight
* determines how much space is allocated to the subplot relative to all the other subplots.
*
* @param subplot the subplot.
* @param weight the weight (must be 1 or greater).
*/
public void add(XYPlot subplot, int weight) {
// verify valid weight
if (weight <= 0) {
String msg = "CombinedRangeXYPlot.add(...): weight must be positive.";
throw new IllegalArgumentException(msg);
}
// store the plot and its weight
subplot.setParent(this);
subplot.setWeight(weight);
subplot.setInsets(new Insets(0, 0, 0, 0));
subplot.setRangeAxis(null);
subplot.addChangeListener(this);
this.subplots.add(subplot);
// keep track of total weights
this.totalWeight += weight;
configureRangeAxes();
notifyListeners(new PlotChangeEvent(this));
}
示例13: getBorderInsets
import java.awt.Insets; //导入依赖的package包/类
/**
* Reinitialize the insets parameter with this Border's current Insets.
* @param c the component for which this border insets value applies
* @param insets the object to be reinitialized
*/
public Insets getBorderInsets(Component c, Insets insets) {
if (!(c instanceof JPopupMenu)) {
return insets;
}
FontMetrics fm;
int descent = 0;
int ascent = 16;
String title = ((JPopupMenu)c).getLabel();
if (title == null) {
insets.left = insets.top = insets.right = insets.bottom = 0;
return insets;
}
fm = c.getFontMetrics(font);
if(fm != null) {
descent = fm.getDescent();
ascent = fm.getAscent();
}
insets.top += ascent + descent + TEXT_SPACING + GROOVE_HEIGHT;
return insets;
}
示例14: initialize
import java.awt.Insets; //导入依赖的package包/类
/**
* Initialise.
*/
private void initialize() {
GridBagLayout gridBagLayout = new GridBagLayout();
gridBagLayout.columnWidths = new int[]{0, 0};
gridBagLayout.rowHeights = new int[]{0, 0, 0};
gridBagLayout.columnWeights = new double[]{0.0, Double.MIN_VALUE};
gridBagLayout.rowWeights = new double[]{0.0, 0.0, Double.MIN_VALUE};
setLayout(gridBagLayout);
jLabelServerHeader = new JLabel();
jLabelServerHeader.setText("Agent.GUI Hintergrundsystem - Konfiguration");
jLabelServerHeader.setFont(new Font("Dialog", Font.BOLD, 12));
GridBagConstraints gbc_jLabelServerHeader = new GridBagConstraints();
gbc_jLabelServerHeader.anchor = GridBagConstraints.WEST;
gbc_jLabelServerHeader.insets = new Insets(0, 0, 5, 0);
gbc_jLabelServerHeader.gridx = 0;
gbc_jLabelServerHeader.gridy = 0;
this.add(jLabelServerHeader, gbc_jLabelServerHeader);
GridBagConstraints gbc_jCheckBoxAutoStart = new GridBagConstraints();
gbc_jCheckBoxAutoStart.anchor = GridBagConstraints.WEST;
gbc_jCheckBoxAutoStart.gridx = 0;
gbc_jCheckBoxAutoStart.gridy = 1;
this.add(getJCheckBoxAutoStart(), gbc_jCheckBoxAutoStart);
}
示例15: getBorderInsets
import java.awt.Insets; //导入依赖的package包/类
public Insets getBorderInsets(Component c) {
Insets insets = new Insets(0,0,0,0);
if (c instanceof BasicSplitPaneDivider) {
BasicSplitPaneUI bspui = ((BasicSplitPaneDivider)c).
getBasicSplitPaneUI();
if (bspui != null) {
JSplitPane splitPane = bspui.getSplitPane();
if (splitPane != null) {
if (splitPane.getOrientation() ==
JSplitPane.HORIZONTAL_SPLIT) {
insets.top = insets.bottom = 0;
insets.left = insets.right = 1;
return insets;
}
// VERTICAL_SPLIT
insets.top = insets.bottom = 1;
insets.left = insets.right = 0;
return insets;
}
}
}
insets.top = insets.bottom = insets.left = insets.right = 1;
return insets;
}