Java Code Examples for java.awt.Dimension

The following are top voted examples for showing how to use java.awt.Dimension. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: TrabalhoFinalEDA2   File: mxGraphComponent.java   View source code 6 votes vote down vote up
/**
 * 
 */
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);
}
 
Example 2
Project: jmt   File: MainWindow.java   View source code 6 votes vote down vote up
@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();
}
 
Example 3
Project: AgentWorkbench   File: JPanelEmbeddedSystemAgent.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 4
Project: VASSAL-src   File: StringEnumConfigurer.java   View source code 6 votes vote down vote up
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;
}
 
Example 5
Project: incubator-netbeans   File: ModeResizer.java   View source code 6 votes vote down vote up
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 );
}
 
Example 6
Project: incubator-netbeans   File: VariablesViewButtons.java   View source code 6 votes vote down vote up
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;
}
 
Example 7
Project: A-Pathfinding-Visualization   File: ControlHandler.java   View source code 6 votes vote down vote up
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);
}
 
Example 8
Project: SER316-Ingolstadt   File: ProjectsTablePanel.java   View source code 6 votes vote down vote up
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();
}
 
Example 9
Project: jmt   File: DialogFactory.java   View source code 6 votes vote down vote up
/**
 * 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();                        
	}
}
 
Example 10
Project: myfaces-trinidad   File: OffscreenWrappingPainter.java   View source code 6 votes vote down vote up
@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;
}
 
Example 11
Project: Equella   File: ComponentHelper.java   View source code 6 votes vote down vote up
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);
}
 
Example 12
Project: Pixie   File: ResizeTest.java   View source code 6 votes vote down vote up
@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);
}
 
Example 13
Project: openjdk-jdk10   File: ScrollPanePreferredSize.java   View source code 6 votes vote down vote up
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();
}
 
Example 14
Project: convertigo-eclipse   File: ColumnEditor.java   View source code 6 votes vote down vote up
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);
     }
 }
 
Example 15
Project: LeagueStats   File: DebugFrame.java   View source code 6 votes vote down vote up
/**
 * 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);
}
 
Example 16
Project: openvisualtraceroute   File: PacketTablePanel.java   View source code 6 votes vote down vote up
@Override
public Component getTableCellEditorComponent(final JTable table, final Object value, final boolean isSelected, final int row, final int column) {
	final Component c = super.getTableCellEditorComponent(table, value, isSelected, row, column);
	final JButton button = new JButton("?");
	button.setMargin(new Insets(0, 0, 0, 0));
	button.setToolTipText(Column.WHO_IS.getLabel());
	button.setPreferredSize(new Dimension(Column.WHO_IS.getWidth(), c.getHeight()));
	if (Env.INSTANCE.getOs() == OS.win) {
		button.setBorder(null);
	}
	button.addActionListener(e -> {
		final AbstractPacketPoint point = _sniffer.getCapture().get(_table.convertRowIndexToModel(row));
		WhoIsPanel.showWhoIsDialog(PacketTablePanel.this, _services, point);
		if (table.isEditing()) {
			table.getCellEditor().stopCellEditing();
		}
		_whois.clear();
	});
	return button;
}
 
Example 17
Project: PengueeBot   File: GrabPanel.java   View source code 6 votes vote down vote up
private void showMonoImage() {
	try {
		imageFragment = copyImage(imageFragment);
		final int bgColor = (pixel_color_num == -16777216) ? -1 : -16777216;
		for (int i = 0; i < imageFragment.getHeight(); i++) {
			for (int j = 0; j < imageFragment.getWidth(); j++) {
				if (imageFragment.getRGB(j, i) != pixel_color_num)
					imageFragment.setRGB(j, i, bgColor);
			}
		}

		imageFragment = optimizeMonoImage(imageFragment);
		panel_fragment_zoom.setPreferredSize(new Dimension(imageFragment
				.getWidth() * previewScaleRate, imageFragment.getHeight()
				* previewScaleRate));
		SwingUtilities.updateComponentTreeUI(frame);
		// panel_fragment_zoom.repaint();
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
Example 18
Project: VASSAL-src   File: ShowServerStatusAction.java   View source code 6 votes vote down vote up
public Window(ServerStatus status, boolean includeMessageControls) {
  super(Resources.getString("Chat.server_status")); //$NON-NLS-1$
  setJMenuBar(MenuManager.getInstance().getMenuBarFor(this));

  view = new ServerStatusView(status);
  view.addPropertyChangeListener(ServerStatusView.SELECTION_PROPERTY,this);
  add(view);
  if (includeMessageControls) {
    messageMgr = new MessageBoardControls();
    final JToolBar toolbar = new JToolBar();
    toolbar.setFloatable(false);
    toolbar.add(messageMgr.getCheckMessagesAction());
    toolbar.add(messageMgr.getPostMessageAction());
    add(toolbar, BorderLayout.NORTH);
  }
  pack();
  setSize(Math.max(getSize().width,400),Math.max(getSize().height,300));
  Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
  setLocation(d.width / 2 - getSize().width / 2,
              d.height / 2 - getSize().height / 2);
}
 
Example 19
Project: trashjam2017   File: ImagePanel.java   View source code 5 votes vote down vote up
/**
 * Set the image to be displayed
 * 
 * @param image The image to be displayed
 */
public void setImage(BufferedImage image) {
	this.image = image;
	setPreferredSize(new Dimension(image.getWidth(), image.getHeight()));
	setSize(new Dimension(image.getWidth(), image.getHeight()));
	getParent().repaint(0);
}
 
Example 20
Project: jdk8u-jdk   File: MultiButtonUI.java   View source code 5 votes vote down vote up
/**
 * Invokes the <code>getMinimumSize</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public Dimension getMinimumSize(JComponent a) {
    Dimension returnValue =
        ((ComponentUI) (uis.elementAt(0))).getMinimumSize(a);
    for (int i = 1; i < uis.size(); i++) {
        ((ComponentUI) (uis.elementAt(i))).getMinimumSize(a);
    }
    return returnValue;
}
 
Example 21
Project: geomapapp   File: WWSCS.java   View source code 5 votes vote down vote up
@Override
public boolean loadDB() {
	if (!super.loadDB())
		return false;
	
	trackLayer = new RenderableLayer();
	
	iconLayer = new IconLayer();
	icon = new UserFacingIcon("org/geomapapp/resources/icons/wdot.png", Position.fromDegrees(0, 0, 0));
	icon.setSize( new Dimension(16,16));
	icon.setVisible(false);
	iconLayer.addIcon(icon);
	
	layerSet = new LayerSet();
	layerSet.setName(getDBName());
	layerSet.add( trackLayer );
	layerSet.add( iconLayer );

	layer = new WWLayer(layerSet) {
		public void close() {
			((MapApp)map.getApp()).closeDB(WWSCS.this);
		}
		public Database getDB() {
			return WWSCS.this;
		}
	};
	
	scsTiles = new SCSTileLayer(
			new SCSTrackTiler(cruises));
	
	layerSet.add(scsTiles);
	
	ww.getInputHandler().addMouseListener(terrainListener);
	
	return true;
}
 
Example 22
Project: JavaGraph   File: ListPanel.java   View source code 5 votes vote down vote up
@Override
public Dimension getPreferredSize() {
    if (getContentSize() == 0) {
        return new Dimension();
    } else {
        return super.getPreferredSize();
    }
}
 
Example 23
Project: ObsidianSuite   File: ImportModelFrame.java   View source code 5 votes vote down vote up
private FileSelectionPanel(String title, final FileNameExtensionFilter filter) {
	setLayout(new GridBagLayout());

	titleLabel = new JLabel(title);
	titleLabel.setHorizontalAlignment(JLabel.HORIZONTAL);

	locationLabel = new JLabel("No location set");
	locationLabel.setPreferredSize(new Dimension(150, 25));

	chooseFileButton = new JButton("Choose File");
	chooseFileButton.addActionListener(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
			try {
				targetFile = FileChooser.loadImportFile(frame, filter);
				String path = targetFile.getAbsolutePath();
				locationLabel.setText(path);
				locationLabel.setToolTipText(path);
				modelFile = targetFile;
				refresh();
			} catch (FileNotChosenException e1) {
			}
		}
	});

	GridBagConstraints c = new GridBagConstraints();
	c.insets = new Insets(5, 5, 5, 5);

	c.gridwidth = 2;
	add(titleLabel, c);

	c.gridwidth = 1;
	c.gridy = 1;
	add(locationLabel, c);

	c.gridx = 1;
	add(chooseFileButton, c);
}
 
Example 24
Project: SER316-Munich   File: AppFrame_AboutBox.java   View source code 5 votes vote down vote up
private void jbInit() throws Exception  {    
  String text = "<html>";
  text += "<b>"+product+"</b><br><br>";
  text += copyright + "<br>" + url + "<br><br>";
  text += "<b>" + developersHead + "</b><br>";    
  for (int i = 0; i < developers.length; i++)
      text += developers[i]+"<br>";    
  text += "<br><b>" + othersHead + "</b><br>";    
  for (int i = 0; i < others.length; i++)
      text += others[i]+"<br>"; 
  
  text += "</html>";
  
  image = new ImageIcon(AppFrame_AboutBox.class.getResource("resources/memoranda.png"));
  this.setTitle(Local.getString("About Memoranda"));
  setResizable(false);
  // Initialize Objects
  lblText.setFont(new java.awt.Font("Dialog", 0, 11));
  lblText.setText(text);
  lblText.setBounds(10, 55, 300, 400);

  
  button1.setText(Local.getString("Ok"));
  button1.setBounds(150, 415, 95, 30);
  button1.addActionListener(this);
  button1.setPreferredSize(new Dimension(95, 30));
  button1.setBackground(new Color(69, 125, 186));
  button1.setForeground(Color.white);
  layeredPane = getLayeredPane();
  //layeredPane.setPreferredSize(new Dimension(300, 300));
  imgLabel = new JLabel(image);
  imgLabel.setBounds(0, 0, image.getIconWidth(), image.getIconHeight());
  layeredPane.add(imgLabel, new Integer(1));
  layeredPane.add(lblText, new Integer(2));    
  layeredPane.add(button1, new Integer(2));
  this.getContentPane().setBackground(new Color(251, 197, 63));
}
 
Example 25
Project: jmt   File: AllBlockingRegionsPanel.java   View source code 5 votes vote down vote up
/**
 * Initialize all components of this panel
 */
private void initComponents() {
	setLayout(new BorderLayout(5, 5));
	this.setBorder(new EmptyBorder(20, 20, 20, 20));
	// Builds upper panel
	JPanel upperPanel = new JPanel(new BorderLayout());
	JLabel description = new JLabel(BLOCKING_DESCRIPTION);
	upperPanel.add(description, BorderLayout.CENTER);

	//build upper right corner of the main panel
	JPanel upRightPanel = new JPanel(new BorderLayout());
	addRegion = new JButton("Add Region");
	addRegion.setMinimumSize(DIM_BUTTON_S);
	upRightPanel.add(addRegion, BorderLayout.CENTER);
	upperPanel.add(upRightPanel, BorderLayout.EAST);

	//build spinner panel
	JPanel spinnerPanel = new JPanel();
	JLabel spinnerDescrLabel = new JLabel("Regions:");
	regionsNumSpinner = new JSpinner();
	regionsNumSpinner.setPreferredSize(DIM_BUTTON_XS);
	spinnerPanel.add(spinnerDescrLabel);
	spinnerPanel.add(regionsNumSpinner);
	upRightPanel.add(spinnerPanel, BorderLayout.SOUTH);

	add(upperPanel, BorderLayout.NORTH);

	// Creates blocking regions list
	regions = new RegionTable();
	JScrollPane jsp = new JScrollPane(regions, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
			ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	jsp.setPreferredSize(new Dimension(500, 200));
	add(jsp, BorderLayout.WEST);
	update();
}
 
Example 26
Project: snake_classic   File: ButtonBack.java   View source code 5 votes vote down vote up
public ButtonBack(String text) {
	super(text);
	// TODO Auto-generated constructor stub
	Dimension dimension = getPreferredSize();
	dimension.width = dimension.height = (int) Math.max(dimension.width,
			dimension.getHeight());
	setPreferredSize(dimension);
	setContentAreaFilled(false);
	this.setForeground(Color.GREEN);
	this.setBackground(Color.YELLOW);
}
 
Example 27
Project: school-game   File: ToolsLauncher.java   View source code 5 votes vote down vote up
/**
 * Ermittelt die Größe des Bildschirms.
 *
 * @return die Größe
 */
private Dimension getScreenSize()
{
    if (screenSize == null)
        screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    return screenSize;
}
 
Example 28
Project: incubator-netbeans   File: GlyphGutter.java   View source code 5 votes vote down vote up
/** Check whether it is not necessary to resize the gutter */
protected void checkSize() {
    int count = getLineCount();
    if (count != highestLineNumber) {
        highestLineNumber = count;
    }
    Dimension dim = getPreferredSize();
    if (getWidthDimension() != dim.width ||
        getHeightDimension() > dim.height) {
        resize();
    }
    putDimensionForPrinting();
}
 
Example 29
Project: jdk8u-jdk   File: MultiSeparatorUI.java   View source code 5 votes vote down vote up
/**
 * Invokes the <code>getMaximumSize</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public Dimension getMaximumSize(JComponent a) {
    Dimension returnValue =
        ((ComponentUI) (uis.elementAt(0))).getMaximumSize(a);
    for (int i = 1; i < uis.size(); i++) {
        ((ComponentUI) (uis.elementAt(i))).getMaximumSize(a);
    }
    return returnValue;
}
 
Example 30
Project: incubator-netbeans   File: ALT_SizeDefinition05Test.java   View source code 5 votes vote down vote up
/**
 * Set text of the toggle button to "jToggelButon1jToggelButon1".
 * This grows the toggle button and also the button. As the button grows
 * over its default size, its preferred size definition is set from 0 to
 * default. The 0 size was just set by mouse resizing (in previous step) so
 * the definition is considered flexible - can change to default when 0 is
 * no longer needed.
 */
public void doChanges1() {
    ld.externalSizeChangeHappened();
    // > UPDATE CURRENT STATE
    compBounds.put("Form", new Rectangle(0, 0, 400, 300));
    contInterior.put("Form", new Rectangle(0, 0, 400, 300));
    compBounds.put("jLabel1", new Rectangle(146, 103, 34, 14));
    baselinePosition.put("jLabel1-34-14", new Integer(11));
    compBounds.put("jButton1", new Rectangle(184, 103, 141, 23));
    baselinePosition.put("jButton1-141-23", new Integer(15));
    compBounds.put("jToggleButton1", new Rectangle(146, 74, 179, 23));
    baselinePosition.put("jToggleButton1-179-23", new Integer(15));
    compMinSize.put("Form", new Dimension(335, 137));
    compBounds.put("Form", new Rectangle(0, 0, 400, 300));
    compPrefSize.put("jButton1", new Dimension(73, 23));
    prefPaddingInParent.put("Form-jToggleButton1-0-1", new Integer(10)); // parentId-compId-dimension-compAlignment
    prefPaddingInParent.put("Form-jButton1-0-1", new Integer(10)); // parentId-compId-dimension-compAlignment
    prefPaddingInParent.put("Form-jLabel1-1-1", new Integer(11)); // parentId-compId-dimension-compAlignment
    prefPaddingInParent.put("Form-jButton1-1-1", new Integer(11)); // parentId-compId-dimension-compAlignment
    compBounds.put("Form", new Rectangle(0, 0, 400, 300));
    contInterior.put("Form", new Rectangle(0, 0, 400, 300));
    compBounds.put("jLabel1", new Rectangle(146, 103, 34, 14));
    baselinePosition.put("jLabel1-34-14", new Integer(11));
    compBounds.put("jButton1", new Rectangle(184, 103, 141, 23));
    baselinePosition.put("jButton1-141-23", new Integer(15));
    compBounds.put("jToggleButton1", new Rectangle(146, 74, 179, 23));
    baselinePosition.put("jToggleButton1-179-23", new Integer(15));
    compMinSize.put("Form", new Dimension(335, 137));
    compBounds.put("Form", new Rectangle(0, 0, 400, 300));
    compPrefSize.put("jButton1", new Dimension(73, 23));
    prefPaddingInParent.put("Form-jToggleButton1-0-1", new Integer(10)); // parentId-compId-dimension-compAlignment
    prefPaddingInParent.put("Form-jButton1-0-1", new Integer(10)); // parentId-compId-dimension-compAlignment
    prefPaddingInParent.put("Form-jLabel1-1-1", new Integer(11)); // parentId-compId-dimension-compAlignment
    prefPaddingInParent.put("Form-jButton1-1-1", new Integer(11)); // parentId-compId-dimension-compAlignment
    ld.updateCurrentState();
    // < UPDATE CURRENT STATE
}
 
Example 31
Project: OpenJSharp   File: MetalworksPrefs.java   View source code 5 votes vote down vote up
public void layoutContainer(Container c) {
    Insets insets = c.getInsets();
    int height = yInset + insets.top;

    Component[] children = c.getComponents();
    Dimension compSize = null;
    for (Component child : children) {
        compSize = child.getPreferredSize();
        child.setSize(compSize.width, compSize.height);
        child.setLocation(xInset + insets.left, height);
        height += compSize.height + yGap;
    }

}
 
Example 32
Project: jdk8u-jdk   File: MultiViewportUI.java   View source code 5 votes vote down vote up
/**
 * Invokes the <code>getMinimumSize</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public Dimension getMinimumSize(JComponent a) {
    Dimension returnValue =
        ((ComponentUI) (uis.elementAt(0))).getMinimumSize(a);
    for (int i = 1; i < uis.size(); i++) {
        ((ComponentUI) (uis.elementAt(i))).getMinimumSize(a);
    }
    return returnValue;
}
 
Example 33
Project: openjdk-jdk10   File: JToolBar.java   View source code 5 votes vote down vote up
/**
 * Sets the size of the separator.
 *
 * @param size the new <code>Dimension</code> of the separator
 */
public void setSeparatorSize( Dimension size )
{
    if (size != null) {
        separatorSize = size;
    } else {
        super.updateUI();
    }
    this.invalidate();
}
 
Example 34
Project: Manns-Game-of-Life-Updated-Version   File: MGoL_Backend.java   View source code 5 votes vote down vote up
@Override
public void componentResized(ComponentEvent e) 
{
	/*
	 * This method is responsible for the Array Board always being the dimensions of the User Interface.
	 * This is necessary when the user changes the size of the Cells within the Array. 
	 * This inadvertently makes the array smaller and thus, the board ensure the array will stay the same size while adding more cells to accomodate.
	 * This calls the Update Universe Method.
	 */
	// Setup the game board size with proper boundaries
	GameOfLifeDimensions = new Dimension(getWidth()/cellSize-2, getHeight()/cellSize-2);
	updateUniverseSize();
}
 
Example 35
Project: Yass   File: Java2DRenderer.java   View source code 5 votes vote down vote up
public Format setInputFormat(Format format) {
       System.out.println("Fobs Java2DRenderer: setInputFormat");
       FobsConfiguration.videoFrameFormat=FobsConfiguration.RGBA;

       vf = (RGBFormat) format;
int formatWidth = (int) vf.getSize().getWidth();
int formatHeight = (int) vf.getSize().getHeight();
this.setPreferredSize(new Dimension(formatWidth,formatHeight));
return format;
   }
 
Example 36
Project: alevin-svn2   File: MultiAlgoScenarioWizard.java   View source code 5 votes vote down vote up
/**
 * @return a {@link JPanel} with {@link JButton}s to manipulate the network
 *         table: Move up, move down, add, remove.
 */
private JPanel createButtons() {
	JPanel bpanel = new JPanel();
	bpanel.setLayout(new BoxLayout(bpanel, BoxLayout.PAGE_AXIS));

	ActionListener listener = new ButtonHandler();
	JButton[] jbuttons = new JButton[4];
	String[] buttons = {
			UP_LBL,		UP_TIP, 	UP_ACTN,
			DOWN_LBL,	DOWN_TIP,	DOWN_ACTN,
			ADD_LBL,	ADD_TIP,	ADD_ACTN,
			REMOVE_LBL,	REMOVE_TIP,	REMOVE_ACTN
	};

	for (int i = 0; i < jbuttons.length; i++) {
		JButton button = new JButton();

		button.setText(buttons[i*3]);
		button.setToolTipText(buttons[i*3+1]);
		button.setActionCommand(buttons[i*3+2]);

		button.addActionListener(listener);
		button.setMaximumSize(new Dimension(
				Short.MAX_VALUE, button.getPreferredSize().height));

		bpanel.add(button);
		jbuttons[i] = button;

		if (i != jbuttons.length - 1) {
			bpanel.add(Box.createVerticalStrut(PADDING));
		}
	}

	this.moveUp = jbuttons[0];
	this.moveDown = jbuttons[1];
	this.add = jbuttons[2];
	this.remove = jbuttons[3];

	return bpanel;
}
 
Example 37
Project: chipKIT-importer   File: ProgressTrackingPanel.java   View source code 5 votes vote down vote up
private JComponent createImportFailedPane( Exception cause ) {
    JLabel infoLabel = new JLabel( NbBundle.getMessage( ProgressTrackingPanel.class, "ProgressTrackingPanel.importFailedMessage" ));
    infoLabel.setHorizontalAlignment(JLabel.CENTER );
    infoLabel.setBackground(Color.red);
    infoLabel.setOpaque(true);
    infoLabel.setBorder( BorderFactory.createLineBorder(Color.red, 3) );
    
    ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream();
    PrintWriter printWriter = new PrintWriter( arrayOutputStream );
    cause.printStackTrace( printWriter );
    printWriter.flush();
    String stackTraceText = arrayOutputStream.toString();
    
    JTextArea stackTraceTextArea = new JTextArea( stackTraceText );
    stackTraceTextArea.setEditable(false);
    
    JScrollPane scrollPane = new JScrollPane( stackTraceTextArea );        
    
    JButton copyToClipboardButton = new JButton( NbBundle.getMessage( ProgressTrackingPanel.class, "ProgressTrackingPanel.copyToClipboard" ));
    copyToClipboardButton.addActionListener( (a) -> {
        Toolkit defaultToolkit = Toolkit.getDefaultToolkit();
        defaultToolkit.getSystemClipboard().setContents( new StringSelection(stackTraceText), null );
    });
    
    JPanel p1 = new JPanel( new FlowLayout(FlowLayout.TRAILING) );
    p1.add( copyToClipboardButton );
    
    JPanel p2 = new JPanel( new BorderLayout(0, 10) );
    p2.add( infoLabel, BorderLayout.NORTH );
    p2.add( scrollPane, BorderLayout.CENTER );        
    p2.add( p1, BorderLayout.SOUTH );
    p2.setSize( new Dimension(600,400) );
    p2.setMinimumSize( p2.getSize() );
    p2.setPreferredSize( p2.getSize() );
    
    return p2;
}
 
Example 38
Project: jaer   File: PanTiltGUI.java   View source code 5 votes vote down vote up
/** Make the GUI.
     * 
     * @param pt the pan tilt unit
     * @param calibrator that we give calibration points to and that provides calibration points to paint here
     */
    public PanTiltGUI(PanTilt pt, PanTiltCalibrator calibrator) {
        this.calibrator=calibrator;
        panTilt = pt;
        initComponents();
        calibrationPanel.setPreferredSize(new Dimension(w, h));
//        HardwareInterfaceException.addExceptionListener(this);
        calibrationPanel.requestFocusInWindow();
        pack();
    }
 
Example 39
Project: incubator-netbeans   File: ImportImageWizard.java   View source code 5 votes vote down vote up
@Override
public Component getComponent() {
    if (cpfChooser == null) {
        cpfChooser = new ClassPathFileChooser(
                wizard.fileInProject,
                new ClassPathFileChooser.Filter() {
            @Override
                    public boolean accept(FileObject fo) {
                        return fo.isFolder();
                    }
                },
                true, false);

        cpfChooser.addPropertyChangeListener(new PropertyChangeListener() {
            @Override
            public void propertyChange(PropertyChangeEvent ev) {
                if (!setTargetFolder && ClassPathFileChooser.PROP_SELECTED_FILE
                            .equals(ev.getPropertyName()))
                    fireStateChanged();
            }
        });
        cpfChooser.setPreferredSize(new Dimension(200, 200)); // TreeView wants to be too big

        cpfChooser.setName(NbBundle.getMessage(ImportImageWizard.class, "ImportImageWizard.Step2")); // NOI18N
        cpfChooser.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, 1); // NOI18N
    }
    if (setTargetFolder) {
        try {
            cpfChooser.setSelectedFile(wizard.targetFolder);
        } catch (IllegalArgumentException ex) {
            // Bug 216368 - sometimes targetFolder (package selected in icon editor) is not
            // found among source roots determined from execution classpath in ClassPathFileChooser
            // Cause unknown (SourceForBinaryQuery giving bad results?) but not a reason to throw exception on user.
            Logger.getLogger(ImportImageWizard.class.getName()).log(Level.INFO,
                    "Folder "+wizard.targetFolder+" not found on classpath of "+wizard.fileInProject, ex); // NOI18N
        }
        setTargetFolder = false;
    }
    return cpfChooser;
}
 
Example 40
Project: incubator-netbeans   File: CodeFoldingSideBar.java   View source code 5 votes vote down vote up
private void updatePreferredSize() {
    if (enabled && !alreadyPresent) {
        setPreferredSize(new Dimension(getColoring().getFont().getSize(), component.getHeight()));
        setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
    }else{
        setPreferredSize(new Dimension(0,0));
        setMaximumSize(new Dimension(0,0));
    }
    revalidate();
}