当前位置: 首页>>代码示例>>Java>>正文


Java Dimension类代码示例

本文整理汇总了Java中java.awt.Dimension的典型用法代码示例。如果您正苦于以下问题:Java Dimension类的具体用法?Java Dimension怎么用?Java Dimension使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Dimension类属于java.awt包,在下文中一共展示了Dimension类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateComponent

import java.awt.Dimension; //导入依赖的package包/类
/**
 * 
 */
public void updateComponent(mxCellState state, Component c)
{
	int x = (int) state.getX();
	int y = (int) state.getY();
	int width = (int) state.getWidth();
	int height = (int) state.getHeight();

	Dimension s = c.getMinimumSize();

	if (s.width > width)
	{
		x -= (s.width - width) / 2;
		width = s.width;
	}

	if (s.height > height)
	{
		y -= (s.height - height) / 2;
		height = s.height;
	}

	c.setBounds(x, y, width, height);
}
 
开发者ID:GDSRS,项目名称:TrabalhoFinalEDA2,代码行数:27,代码来源:mxGraphComponent.java

示例2: doClose

import java.awt.Dimension; //导入依赖的package包/类
@Override
protected void doClose() {
	// Ends simulation process if active
	mediator.stopSimulation();
	// Disposes resultsWindow (if present) and mainwindow
	if (mediator.getResultsWindow() != null) {
		mediator.getResultsWindow().dispose();
	}
	if (mediator.getPAProgressWindow() != null) {
		mediator.getPAProgressWindow().stopAnimation();
		mediator.getPAProgressWindow().dispose();
	}
	Dimension d = getSize();
	Defaults.set("JSIMWindowWidth", String.valueOf(d.width));
	Defaults.set("JSIMWindowHeight", String.valueOf(d.height));
	Defaults.save();
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:18,代码来源:MainWindow.java

示例3: getJComboBoxProjectSelector

import java.awt.Dimension; //导入依赖的package包/类
/**
 * This method initializes jComboBoxProjectSelector	
 * @return javax.swing.JComboBox	
 */
private JComboBox<String> getJComboBoxProjectSelector() {
	if (jComboBoxProjectSelector == null) {
		
		DefaultComboBoxModel<String> comboBoxModel = new DefaultComboBoxModel<String>();
		comboBoxModel.addElement("");
		String[] projectFolders = getGlobalInfo().getProjectSubDirectories();
		if (projectFolders!=null && projectFolders.length>0) {
			for (int i = 0; i < projectFolders.length; i++) {
				comboBoxModel.addElement(projectFolders[i]);	
			}	
		}
		jComboBoxProjectSelector = new JComboBox<String>(comboBoxModel);
		jComboBoxProjectSelector.setPreferredSize(new Dimension(300, 26));
		jComboBoxProjectSelector.setActionCommand("esaProjectSelected");
		jComboBoxProjectSelector.addActionListener(this);
	}
	return jComboBoxProjectSelector;
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:23,代码来源:JPanelEmbeddedSystemAgent.java

示例4: getControls

import java.awt.Dimension; //导入依赖的package包/类
public Component getControls() {
  if (panel == null) {
    panel = Box.createHorizontalBox();
    panel.add(new JLabel(name));
    box = new JComboBox(validValues);
    box.setMaximumSize(new Dimension(box.getMaximumSize().width,box.getPreferredSize().height));
    if (isValidValue(getValue())) {
      box.setSelectedItem(getValue());
    }
    else if (validValues.length > 0) {
      box.setSelectedIndex(0);
    }
    box.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        noUpdate = true;
        setValue(box.getSelectedItem());
        noUpdate = false;
      }
    });
    panel.add(box);
  }
  return panel;
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:24,代码来源:StringEnumConfigurer.java

示例5: refresh

import java.awt.Dimension; //导入依赖的package包/类
public void refresh() {
    Point p = resizingComponent.getLocationOnScreen();
    int width = resizingComponent.getWidth();
    int height = resizingComponent.getHeight();
    
    p.x += width/2;
    p.y += height/2;
    
    lbl.setText( width + " x " + height ); //NOI18N
    
    SwingUtilities.convertPointFromScreen( p, this );
    Dimension size = panel.getPreferredSize();
    p.x -= size.width/2;
    p.y -= size.height/2;
    panel.setLocation( p );
    panel.setSize( size );
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:ModeResizer.java

示例6: createToggleButton

import java.awt.Dimension; //导入依赖的package包/类
private static JToggleButton createToggleButton (final String id, String iconName, String tooltip) {
    Icon icon = loadIcon(iconName);
    boolean isSelected = isButtonSelected(id);
    final JToggleButton toggleButton = new JToggleButton(icon, isSelected);
    // ensure small size, just for the icon
    Dimension size = new Dimension(icon.getIconWidth() + 8, icon.getIconHeight() + 8);
    toggleButton.setPreferredSize(size);
    toggleButton.setMargin(new Insets(1, 1, 1, 1));
    if (!"Aqua".equals(UIManager.getLookAndFeel().getID())) { //NOI18N
        // We do not want an ugly border with the exception of Mac, where it paints the toggle state!
        toggleButton.setBorder(new EmptyBorder(toggleButton.getBorder().getBorderInsets(toggleButton)));
    }
    toggleButton.setToolTipText(tooltip);
    toggleButton.setFocusable(false);
    return toggleButton;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:VariablesViewButtons.java

示例7: position

import java.awt.Dimension; //导入依赖的package包/类
public void position() {
	// Set label bounds
	speedT.setBounds(180, frame.getHeight()-88, 60, 20);
	speedC.setBounds(224, frame.getHeight()-88, 60, 20);
	openT.setBounds(254, frame.getHeight()-92, 60, 20);
	openC.setBounds(300, frame.getHeight()-92, 60, 20);
	closedT.setBounds(254, frame.getHeight()-76, 60, 20);
	closedC.setBounds(300, frame.getHeight()-76, 60, 20);
	pathT.setBounds(254, frame.getHeight()-60, 60, 20);
	pathC.setBounds(300, frame.getHeight()-60, 60, 20);
	Dimension size = modeText.getPreferredSize();
	modeText.setBounds(20, frame.getHeight() - 39, size.width, size.height);
	
	// Set check box bounds
	showStepsCheck.setBounds(20, frame.getHeight()-88, 90, 20);
	diagonalCheck.setBounds(20, frame.getHeight()-64, 90, 20);
	trigCheck.setBounds(112, frame.getHeight()-63, 50, 20);
	
	// Set slider bounds
	speed.setBounds(178, frame.getHeight()-63, 68, 20);
	
	// Set button bounds
	run.setBounds(116, frame.getHeight()-88, 52, 22);
}
 
开发者ID:DevonCrawford,项目名称:A-Pathfinding-Visualization,代码行数:25,代码来源:ControlHandler.java

示例8: jbInit

import java.awt.Dimension; //导入依赖的package包/类
void jbInit() throws Exception {
    projectsTable.getTableHeader().setFont(new java.awt.Font("Dialog", 1, 10));
    projectsTable.setFont(new java.awt.Font("Dialog", 0, 11));
    projectsTable.setMinimumSize(new Dimension(200, 100));
    projectsTable.setMaximumSize(new Dimension(32767, 32767));
    //projectsTable.setPreferredSize(new Dimension(400, 100));
    projectsTable.setGridColor(new Color(230, 230, 230));
    projectsTable.setShowHorizontalLines(false);
    /*projectsTable.setSelectionBackground(Color.white);
    projectsTable.setSelectionForeground(Color.blue);*/
    scrollPane.getViewport().setBackground(Color.white);
    scrollPane.getViewport().add(projectsTable, null);
    this.setLayout(borderLayout1);
    this.add(scrollPane, BorderLayout.CENTER);
    initProjectsTable();
}
 
开发者ID:ser316asu,项目名称:SER316-Ingolstadt,代码行数:17,代码来源:ProjectsTablePanel.java

示例9: getDialog

import java.awt.Dimension; //导入依赖的package包/类
/**
 * Returns modal dialog box showing given panel and with given title
 * @param panel to be shown on the center area of this dialog
 * @param title title of this dialog
 */
public void getDialog(final JComponent panel, String title, int width, int height, boolean saveSize, String defaultWidthProp, String defaultHeightProp) {
	createDialog(width, height);
	// Adds input panel
	dialogFrame.getContentPane().add(panel, BorderLayout.CENTER);
	// Sets title
	if (title != null) {
		dialogFrame.setTitle(title);
	}
	// If this is a wizard panel call gotFocus() method
	if (panel instanceof WizardPanel) {
		((WizardPanel) panel).gotFocus();
	}
	// Shows dialog
	dialogFrame.setVisible(true);
	if (saveSize) {
		Dimension d = dialogFrame.getSize();
		Defaults.set(defaultWidthProp, String.valueOf(d.width));
		Defaults.set(defaultHeightProp, String.valueOf(d.height));
		Defaults.save();                        
	}
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:27,代码来源:DialogFactory.java

示例10: getPreferredSize

import java.awt.Dimension; //导入依赖的package包/类
@Override
public Dimension getPreferredSize(PaintContext context)
{
  Dimension size = null;

  // Get a shared buffer to use for measuring
  BufferedImage buffer = _createOffscreenBuffer(context, 1, 1);

  if (buffer != null)
  {
    Graphics g = _getInitializedGraphics(context, buffer);
    size = super.getPreferredSize(new ProxyContext(context, g));

    // Clean up
    g.dispose();
    buffer.flush();
  }
  else
  {
    // If we didn't get a buffer, just paint the contents directly
    size = super.getPreferredSize(context);
  }

  return size;
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:26,代码来源:OffscreenWrappingPainter.java

示例11: ensureMinimumSize

import java.awt.Dimension; //导入依赖的package包/类
public static void ensureMinimumSize(Component c, int width, int height)
{
	Dimension size = c.getSize();

	if( size.width < width )
	{
		size.width = width;
	}

	if( size.height < height )
	{
		size.height = height;
	}

	c.setSize(size);
}
 
开发者ID:equella,项目名称:Equella,代码行数:17,代码来源:ComponentHelper.java

示例12: testResizeImage_04

import java.awt.Dimension; //导入依赖的package包/类
@Test
public void testResizeImage_04() {
    final String testDescription = "----------resizeImage_04----------\n"
            + " Summary: Test of resizeImage(BufferedImage) method, of class Resize\n"
            + " Description: Check if the approximation of the upscale works as expected. 333.3334 shall be aproximated to 333. Input image has a size of 100x100, the resize is set to (0.3, 0.3).\n"
            + " Pre-conditions: none\n"
            + " Conditions: none\n"
            + " Expected result: It shall output an image of size 333x333; no errors or exceptions shall occur.\n";
    System.out.println(testDescription);

    BufferedImage origImg = new BufferedImage(100, 100, BufferedImage.TYPE_3BYTE_BGR);
    Resize instance = new Resize(0.3, 0.3);
    Dimension expDim = new Dimension(333, 333);
    BufferedImage resultImg = instance.resizeImage(origImg);
    Dimension resultDim = new Dimension(resultImg.getWidth(), resultImg.getHeight());
    assertEquals(expDim, resultDim);
}
 
开发者ID:buni-rock,项目名称:Pixie,代码行数:18,代码来源:ResizeTest.java

示例13: main

import java.awt.Dimension; //导入依赖的package包/类
public static void main(final String[] args) {
    final Dimension expected = new Dimension(300, 300);
    final Frame frame = new Frame();
    final ScrollPane sp = new ScrollPane();
    sp.setSize(expected);
    frame.add(sp);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    sleep();
    final Dimension size = frame.getSize();
    if (size.width < expected.width || size.height < expected.height) {
        throw new RuntimeException(
                "Expected size: >= " + expected + ", actual size: " + size);
    }
    frame.dispose();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:ScrollPanePreferredSize.java

示例14: customizePanel

import java.awt.Dimension; //导入依赖的package包/类
public void customizePanel(JPanel valuePanel, Container buttonsPanel) {
     valuePanel.setLayout(new BorderLayout());
     valuePanel.add(jComboBoxColumns);
     jComboBoxColumns.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
             setJavelinZoneFromProperty();
         }
     });
     
     addButton = new JButton();
     addButton.setFocusPainted(false);
     addButton.setEnabled(false);
     addButton.setPreferredSize(new Dimension(24, 24));
     addButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/twinsoft/convertigo/eclipse/property_editors/images/table_editor/new_line.png")));
     addButton.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/com/twinsoft/convertigo/eclipse/property_editors/images/table_editor/new_line.d.png")));
     addButton.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent actionEvent) {
             addButtonActionPerformed();
         }
     });
     buttonsPanel.add(addButton);
     
     if (javelin != null) {
javelin.addZoneListener(this);
     }
 }
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:27,代码来源:ColumnEditor.java

示例15: DebugFrame

import java.awt.Dimension; //导入依赖的package包/类
/**
 * Creates a new DebugFrame used for the logger to log its messages onto.
 */
public DebugFrame() {
	this.setUndecorated(true);
	this.setBackground(new Color(0, 0, 0, 0));
	this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
	this.setSize(Display.WINDOW_WIDTH / 3, Display.WINDOW_HEIGHT);
	this.setLayout(new GridLayout(2, 5));
	this.setLocation(Display.WINDOW_POSITION);
	this.setResizable(false);

	this.textPane = new ColorableTextPane();
	this.textPane.setFont(new Font("Arial", Font.BOLD, 15));
	this.setPreferredSize(new Dimension(Display.WINDOW_WIDTH / 3, Display.WINDOW_HEIGHT));
	DefaultCaret caret = (DefaultCaret) this.textPane.getCaret();
	caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

	final JScrollPane sp = new JScrollPane(this.textPane);
	sp.getViewport().setBackground(Color.GRAY);
	sp.getViewport().setFocusable(false);
	sp.setBorder(BorderFactory.createLineBorder(Color.BLACK, 3));
	this.add(sp);

	this.setVisible(true);
}
 
开发者ID:Ativelox,项目名称:LeagueStats,代码行数:27,代码来源:DebugFrame.java


注:本文中的java.awt.Dimension类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。