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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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();
}
 
Example 41
Project: OpenJSharp   File: MultiDesktopPaneUI.java   Source Code and License 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 42
Project: OpenJSharp   File: MultiTreeUI.java   Source Code and License 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 43
Project: SpriteAnimator   File: AnimatedGIFWriter.java   Source Code and License 5 votes vote down vote up
private static Dimension getLogicalScreenSize(BufferedImage[] images) {
	// Determine the logical screen dimension assuming all the frames have the same
	// left and top coordinates (0, 0)
	int logicalScreenWidth = 0;
	int logicalScreenHeight = 0;

	for(BufferedImage image : images) {
		if(image.getWidth() > logicalScreenWidth)
			logicalScreenWidth = image.getWidth();
		if(image.getHeight() > logicalScreenHeight)
			logicalScreenHeight = image.getHeight();
	}

	return new Dimension(logicalScreenWidth, logicalScreenHeight);
}
 
Example 44
Project: ramus   File: BusyDialog.java   Source Code and License 5 votes vote down vote up
private void init() {
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    busyLabel = new JXBusyLabel();

    busyLabel.setText(getTitle());
    busyLabel.setBusy(true);

    add(busyLabel);
    pack();
    setSize(new Dimension(300, getBounds().height));
    setLocationRelativeTo(this);
    setResizable(false);
}
 
Example 45
Project: QN-ACTR-Release   File: Mediator.java   Source Code and License 5 votes vote down vote up
/**
 * Selects the specified cell and initiates editing.
 * The edit-attempt fails if the <code>CellEditor</code>
 * does not allow
 * editing for the specified item.
 */
public void startEditingAtCell(Object cell) {
	graph.startEditingAtCell(cell);
	if ((cell != null) && (cell instanceof JmtCell)) {
		JmtCell jcell = (JmtCell) cell;
		StationParameterPanel stationPanel = new jmt.gui.common.panels.StationParameterPanel(model, model,
				((CellComponent) jcell.getUserObject()).getKey());
		// Adds on the top a panel to change station name
		stationPanel.add(new StationNamePanel(model, ((CellComponent) jcell.getUserObject()).getKey()), BorderLayout.NORTH);
		dialogFactory.getDialog(stationPanel, "Editing " + jcell.getUserObject().toString() + " Properties...");

		// Updates cell dimensions if name was changed too much...
		Hashtable<Object, Map> nest = new Hashtable<Object, Map>();
		Dimension cellDimension = jcell.getSize(graph);
		Map attr = jcell.getAttributes();
		Rectangle2D oldBounds = GraphConstants.getBounds(attr);
		if (oldBounds.getWidth() != cellDimension.getWidth()) {
			GraphConstants.setBounds(attr, new Rectangle2D.Double(oldBounds.getX(), oldBounds.getY(), cellDimension.getWidth(), cellDimension
					.getHeight()));
			nest.put(cell, attr);
			jcell.updatePortPositions(nest, GraphConstants.getIcon(attr), cellDimension);
			graph.getGraphLayoutCache().edit(nest);
		}
	}
	// Blocking region editing
	else if ((cell != null) && (cell instanceof BlockingRegion)) {
		Object regionKey = ((BlockingRegion) cell).getKey();
		dialogFactory.getDialog(new BlockingRegionParameterPanel(model, model, regionKey), "Editing " + model.getRegionName(regionKey)
				+ " Properties...");
	}
}
 
Example 46
Project: Progetto-A   File: MenuLogin.java   Source Code and License 5 votes vote down vote up
/**
 * 
 * @param client oggetto client
 */
public MenuLogin(Client client) {
    this.client=client;
    this.socketClient=client.getSocketClient();
    setTitle("Login");
    setPreferredSize(new Dimension(1000, 800));
    setMinimumSize(new Dimension(1000, 800));
    pack();
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setResizable(false);
    setLocationRelativeTo(null);

    inizializzaGUI();
}
 
Example 47
Project: VISNode   File: ExceptionPanel.java   Source Code and License 5 votes vote down vote up
/**
 * Builds the stack
 * 
 * @param exception
 * @return JComponent
 */
private JComponent buildStack(Exception exception) {
    JTextArea textArea = new JTextArea(2, 100);
    textArea.setText(ExceptionUtils.getStackTrace(exception));
    textArea.setEditable(false);
    JScrollPane scrollPane = new JScrollPane(textArea);
    scrollPane.setPreferredSize(new Dimension(0, 600));
    return scrollPane;
}
 
Example 48
Project: marathonv5   File: TableDemo.java   Source Code and License 5 votes vote down vote up
public TableDemo() {
    super(new GridLayout(1, 0));

    JTable table = new JTable(new MyTableModel());
    table.setPreferredScrollableViewportSize(new Dimension(500, 70));
    table.setFillsViewportHeight(true);

    // Create the scroll pane and add the table to it.
    JScrollPane scrollPane = new JScrollPane(table);

    // Add the scroll pane to this panel.
    add(scrollPane);
}
 
Example 49
Project: Logisim   File: PreferencesFrame.java   Source Code and License 5 votes vote down vote up
private PreferencesFrame() {
	setDefaultCloseOperation(HIDE_ON_CLOSE);
	setJMenuBar(new LogisimMenuBar(this, null));

	panels = new OptionsPanel[] { new TemplateOptions(this), new IntlOptions(this), new WindowOptions(this),
			new LayoutOptions(this), new ExperimentalOptions(this), new ForkOptions(this), };
	tabbedPane = new JTabbedPane();
	int intlIndex = -1;
	for (int index = 0; index < panels.length; index++) {
		OptionsPanel panel = panels[index];
		tabbedPane.addTab(panel.getTitle(), null, panel, panel.getToolTipText());
		if (panel instanceof IntlOptions)
			intlIndex = index;
	}

	JPanel buttonPanel = new JPanel();
	buttonPanel.add(close);
	close.addActionListener(myListener);

	Container contents = getContentPane();
	tabbedPane.setPreferredSize(new Dimension(450, 300));
	contents.add(tabbedPane, BorderLayout.CENTER);
	contents.add(buttonPanel, BorderLayout.SOUTH);

	if (intlIndex >= 0)
		tabbedPane.setSelectedIndex(intlIndex);

	LocaleManager.addLocaleListener(myListener);
	myListener.localeChanged();
	pack();
	setLocationRelativeTo(null);
}
 
Example 50
Project: incubator-netbeans   File: StatusLineComponent.java   Source Code and License 5 votes vote down vote up
private void initMinDimension(String... maxStrings) {
    FontMetrics fm = getFontMetrics(getFont());
    int minWidth = 0;
    for (String s : maxStrings) {
        minWidth = Math.max(minWidth, fm.stringWidth(s));
    }
    Border b = getBorder();
    Insets ins = (b != null) ? b.getBorderInsets(this) : NULL_INSETS;
    minWidth += ins.left + ins.right;
    int minHeight = fm.getHeight() + ins.top + ins.bottom;
    minDimension = new Dimension(minWidth, minHeight);
}
 
Example 51
Project: brModelo   File: Elementar.java   Source Code and License 4 votes vote down vote up
/**
 * @return the size
 */
public Dimension getSize() {
    return size;
}
 
Example 52
Project: Neukoelln_SER316   File: TagSearchController.java   Source Code and License 4 votes vote down vote up
public static void searchByTag_actionPerformed(ActionEvent e) {
	TagSearchController sc = new TagSearchController(App.getFrame(), Local.getString("Search By Tag"));
   	
   	Dimension frmSize = App.getFrame().getSize();
       Point loc = App.getFrame().getLocation();
       sc.setLocation((frmSize.width) / 3 + loc.x, (frmSize.height) / 3 + loc.y);
       sc.setVisible(true);
       if (sc.CANCELLED)
           return;
}
 
Example 53
Project: incubator-netbeans   File: CodeCustomEditor.java   Source Code and License 4 votes vote down vote up
public CodeCustomEditor(RADConnectionPropertyEditor propertyEditor,
                        FormModel formModel, FormProperty property)
{
    this.propertyEditor = propertyEditor;
    
    codePane = new JEditorPane() { // editor pane does not count the pref. height correctly
        @Override
        public Dimension getPreferredScrollableViewportSize() {
            return new Dimension(super.getPreferredScrollableViewportSize().width, getPrefHeight(this));
        }
        @Override
        public Dimension getPreferredSize() {
            return new Dimension(super.getPreferredSize().width, getPrefHeight(this));
        }
        @Override
        public Dimension getMinimumSize() {
            return new Dimension(super.getMinimumSize().width, getPrefHeight(this));
        }
    };
    codePane.getAccessibleContext().setAccessibleName(
        NbBundle.getBundle(CodeCustomEditor.class).getString("ACSN_CustomCode_EditorPane")); //NOI18N
    headerLabel.setLabelFor(codePane);
    jScrollPane.setViewportView(codePane);
    jScrollPane.getViewport().setBackground(new Color(codePane.getBackground().getRGB()));

    int codePos = -1;
    FormDataObject dobj = FormEditor.getFormDataObject(formModel);
    EditorSupport es = dobj.getFormEditorSupport();
    GuardedSectionManager gsm = es.getGuardedSectionManager();
    SimpleSection sec = gsm.findSimpleSection(EditorSupport.SECTION_INIT_COMPONENTS);
    if ((property instanceof RADProperty) && (property.getWriteMethod() != null)) {
        RADComponent metacomp = ((RADProperty)property).getRADComponent();
        headerLabel.setText("<html>" + metacomp.getName() + ".<b>" // NOI18N
                + property.getWriteMethod().getName() + "</b>("); // NOI18N
        footerLabel.setText(");"); // NOI18N

        String codeSnippet;
        if (metacomp != formModel.getTopRADComponent()) {
            codeSnippet = " " + metacomp.getName() + "." + property.getWriteMethod().getName() + "("; // NOI18N
        } else {
            codeSnippet = " " + property.getWriteMethod().getName() + "("; // NOI18N
        }
        codePos = sec.getText().indexOf(codeSnippet);
        if (codePos >= 0) {
            codePos += codeSnippet.length();
        }
    }
    else {
        headerLabel.setText(FormUtils.getBundleString("CodeCustomEditor.codeLabel")); // NOI18N
    }
    if (codePos < 0) {
        codePos = sec.getText().indexOf('{') + 2;
    }
    FormUtils.setupEditorPane(codePane, dobj.getPrimaryFile(), codePos + sec.getStartPosition().getOffset());

    headerLabel.setFont(codePane.getFont());
    footerLabel.setFont(codePane.getFont());
    typeField.setBorder(BorderFactory.createEmptyBorder());
    typeField.setEditable(false);
    typeField.setFont(codePane.getFont());
    typeField.setText(Utilities.getClassName(property.getValueType()));
    if (UIManager.getLookAndFeel().getID().equals("Nimbus")) { // NOI18N
        // We have to "clone" the Color because Nimbus ignores ColorUIResources
        typeField.setBackground(new Color(getBackground().getRGB()));
    }

    resetLayout();

    codePane.getDocument().addDocumentListener(this);

    // issue 103809
    addComponentListener(new ComponentAdapter() {
        @Override
        public void componentShown(ComponentEvent ev) {
            revalidate();
            repaint();
        }
    });
}
 
Example 54
Project: scorekeeperfrontend   File: BracketPane.java   Source Code and License 4 votes vote down vote up
/**
 * Sets the depth of rounds that take place, 1 is just 2 people in a finale,
 * recreate the brackets and components.
 * @param c the challenge to make active
 */
public void setChallenge(Challenge c)
{
	challenge = c;
	int newDepth = challenge.getDepth();

	/* base rounds is the number of entrants int the first full round */
	removeAll();		
	baseRounds = (int)Math.pow(2, newDepth-1);
	
	int width = roundWidth * (newDepth+1);
	int height = (baseRounds * initialSpacing * 2); // - initialSpacing;

	Insets insets = getInsets();
	Dimension newSize = new Dimension(width + insets.left + insets.right, 
									height + insets.top + insets.bottom);

	setMinimumSize(newSize);
	setPreferredSize(newSize);
	//setPreferredSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
	setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
	
	/* +1 extra round for the 3rd place bracket 
	 * example:
	 *   7
	 *   6 3
	 *   5 2 1
	 *   4   [0 index is 1st and 3rd place winners]
	 */
	
	rounds.clear();  // just restart from scratch for ease
	
	int cnt = (int)Math.pow(2, newDepth);
	for (int ii = rounds.size(); ii < cnt; ii++)
		rounds.add(new RoundGroup(ii));			

	winner1 = new EntrantLabel(new Id.Entry(challenge.getChallengeId(), 0, Id.Entry.Level.UPPER));
	winner3 = new EntrantLabel(new Id.Entry(challenge.getChallengeId(), 0, Id.Entry.Level.LOWER));
	thirdPRound = new RoundGroup(99);
	rounds.add(thirdPRound);
	
	if (cnt > 1)
	{
		RoundGroup rg;
		
		for (int ii = cnt - 1; ii >= 0; ii--)
		{
			rg = rounds.get(ii);
			rg.upper.updateEntrant();
			rg.lower.updateEntrant();
			add(rg.upper, Integer.valueOf(5));
			add(rg.lower, Integer.valueOf(5));
			add(rg.open, Integer.valueOf(5));
		}
		
		thirdPRound.upper.updateEntrant();
		thirdPRound.lower.updateEntrant();
		add(thirdPRound.upper, Integer.valueOf(5));
		add(thirdPRound.lower, Integer.valueOf(5));
		add(thirdPRound.open, Integer.valueOf(5));
		
		add(winner1, Integer.valueOf(5));
		add(winner3, Integer.valueOf(5));
		winner1.updateEntrant();
		winner3.updateEntrant();
	}
	
	revalidate();
	repaint();
}
 
Example 55
Project: incubator-netbeans   File: AutoResizingPanel.java   Source Code and License 4 votes vote down vote up
@Override
public Dimension getPreferredSize() {
    return (requestedSize != null) ? requestedSize
                                   : super.getPreferredSize();
}
 
Example 56
Project: zooracle   File: DatabaseManagerView.java   Source Code and License 4 votes vote down vote up
public void resizeComponents()
{
	browserFrame.setPreferredSize(new Dimension(mainWindow.getWidth()/ 4-30, mainWindow.getHeight() - 120));
	compareView.setPreferredSize(new Dimension(3*mainWindow.getWidth()/ 4-30, mainWindow.getHeight()  - 120));
}
 
Example 57
Project: AgentWorkbench   File: TimeModelPresentConfiguration.java   Source Code and License 4 votes vote down vote up
/**
 * This method initializes this.
 */
@Override
protected void initialize() {

    GridBagConstraints gridBagConstraints21 = new GridBagConstraints();
    gridBagConstraints21.gridx = 1;
    gridBagConstraints21.anchor = GridBagConstraints.WEST;
    gridBagConstraints21.insets = new Insets(10, 5, 0, 0);
    gridBagConstraints21.gridy = 6;
    GridBagConstraints gridBagConstraints20 = new GridBagConstraints();
    gridBagConstraints20.gridx = 0;
    gridBagConstraints20.insets = new Insets(15, 10, 0, 0);
    gridBagConstraints20.anchor = GridBagConstraints.NORTHWEST;
    gridBagConstraints20.gridy = 6;
    GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
    gridBagConstraints4.gridx = 0;
    gridBagConstraints4.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints4.insets = new Insets(5, 7, 5, 20);
    gridBagConstraints4.gridwidth = 2;
    gridBagConstraints4.gridy = 7;
    GridBagConstraints gridBagConstraints9 = new GridBagConstraints();
    gridBagConstraints9.gridx = 0;
    gridBagConstraints9.anchor = GridBagConstraints.WEST;
    gridBagConstraints9.insets = new Insets(10, 10, 10, 10);
    gridBagConstraints9.gridwidth = 2;
    gridBagConstraints9.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints9.gridy = 9;
    GridBagConstraints gridBagConstraints7 = new GridBagConstraints();
    gridBagConstraints7.gridx = 0;
    gridBagConstraints7.fill = GridBagConstraints.BOTH;
    gridBagConstraints7.weightx = 1.0;
    gridBagConstraints7.weighty = 1.0;
    gridBagConstraints7.gridwidth = 2;
    gridBagConstraints7.gridy = 11;
    GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
    gridBagConstraints6.gridx = 0;
    gridBagConstraints6.insets = new Insets(0, 10, 0, 0);
    gridBagConstraints6.anchor = GridBagConstraints.WEST;
    gridBagConstraints6.gridwidth = 2;
    gridBagConstraints6.weightx = 0.0;
    gridBagConstraints6.fill = GridBagConstraints.NONE;
    gridBagConstraints6.gridy = 1;
    GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
    gridBagConstraints5.gridx = 0;
    gridBagConstraints5.anchor = GridBagConstraints.WEST;
    gridBagConstraints5.insets = new Insets(10, 10, 5, 0);
    gridBagConstraints5.gridwidth = 2;
    gridBagConstraints5.gridy = 0;
    GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
    gridBagConstraints1.gridx = 1;
    gridBagConstraints1.gridy = 0;

    JLabel jLabelHeader1 = new JLabel();
    jLabelHeader1.setText("TimeModelPresent");
    jLabelHeader1.setFont(new Font("Dialog", Font.BOLD, 14));
    JLabel jLabelHeader2 = new JLabel();
    jLabelHeader2.setText("Gegenwarts-Zeit.");
    jLabelHeader2.setText(Language.translate(jLabelHeader2.getText()));

    JLabel jLabelDateFormat = new JLabel();
    jLabelDateFormat.setFont(new Font("Dialog", Font.BOLD, 12));
    jLabelDateFormat.setText("Ansicht");
    jLabelDateFormat.setText(Language.translate(jLabelDateFormat.getText()) + ":");

    this.setSize(new Dimension(615, 367));
    this.setLayout(new GridBagLayout());
    this.add(jLabelHeader1, gridBagConstraints5);
    this.add(jLabelHeader2, gridBagConstraints6);
    this.add(getJPanelWidthSettings(), gridBagConstraints9);
    this.add(getJPanelDummy(), gridBagConstraints7);
    this.add(getJPanelDivider(), gridBagConstraints4);
    this.add(jLabelDateFormat, gridBagConstraints20);
    this.add(getJPanelTimeFormater(), gridBagConstraints21);
}
 
Example 58
Project: incubator-netbeans   File: ALT_ResizingSizeTest.java   Source Code and License 4 votes vote down vote up
public void doChanges1() {
    // > SET DEFAULT SIZE
    ld.setDefaultSize("Form");
    // < SET DEFAULT SIZE
    ld.externalSizeChangeHappened();
    // > UPDATE CURRENT STATE
    contInterior.put("Form", new Rectangle(0, 0, 199, 143));
    compBounds.put("jTextField1", new Rectangle(10, 37, 164, 20));
    baselinePosition.put("jTextField1-164-20", new Integer(14));
    compBounds.put("jCheckBox1", new Rectangle(10, 7, 81, 23));
    baselinePosition.put("jCheckBox1-81-23", new Integer(15));
    compBounds.put("jCheckBox2", new Rectangle(93, 7, 81, 23));
    baselinePosition.put("jCheckBox2-81-23", new Integer(15));
    compBounds.put("jLabel1", new Rectangle(10, 89, 34, 14));
    baselinePosition.put("jLabel1-34-14", new Integer(11));
    compBounds.put("jComboBox1", new Rectangle(54, 86, 56, 20));
    baselinePosition.put("jComboBox1-56-20", new Integer(14));
    compBounds.put("jLabel2", new Rectangle(10, 115, 34, 14));
    baselinePosition.put("jLabel2-34-14", new Integer(11));
    compBounds.put("jTextField2", new Rectangle(48, 112, 126, 20));
    baselinePosition.put("jTextField2-126-20", new Integer(14));
    prefPaddingInParent.put("Form-jLabel2-1-1", new Integer(11)); // parentId-compId-dimension-compAlignment
    prefPaddingInParent.put("Form-jTextField2-1-1", new Integer(11)); // parentId-compId-dimension-compAlignment
    compPrefSize.put("jTextField1", new Dimension(59, 20));
    compPrefSize.put("jCheckBox1", new Dimension(81, 23));
    compPrefSize.put("jCheckBox2", new Dimension(81, 23));
    compPrefSize.put("jLabel1", new Dimension(34, 14));
    compPrefSize.put("jComboBox1", new Dimension(56, 20));
    compPrefSize.put("jLabel2", new Dimension(34, 14));
    compPrefSize.put("jTextField2", new Dimension(59, 20));
    contInterior.put("Form", new Rectangle(0, 0, 199, 143));
    compBounds.put("jTextField1", new Rectangle(10, 37, 164, 20));
    baselinePosition.put("jTextField1-164-20", new Integer(14));
    compBounds.put("jCheckBox1", new Rectangle(10, 7, 81, 23));
    baselinePosition.put("jCheckBox1-81-23", new Integer(15));
    compBounds.put("jCheckBox2", new Rectangle(93, 7, 81, 23));
    baselinePosition.put("jCheckBox2-81-23", new Integer(15));
    compBounds.put("jLabel1", new Rectangle(10, 89, 34, 14));
    baselinePosition.put("jLabel1-34-14", new Integer(11));
    compBounds.put("jComboBox1", new Rectangle(54, 86, 56, 20));
    baselinePosition.put("jComboBox1-56-20", new Integer(14));
    compBounds.put("jLabel2", new Rectangle(10, 115, 34, 14));
    baselinePosition.put("jLabel2-34-14", new Integer(11));
    compBounds.put("jTextField2", new Rectangle(48, 112, 126, 20));
    baselinePosition.put("jTextField2-126-20", new Integer(14));
    ld.updateCurrentState();
    // < UPDATE CURRENT STATE
}
 
Example 59
Project: SER316-Aachen   File: ResourceTypePanel.java   Source Code and License 4 votes vote down vote up
void editB_actionPerformed(ActionEvent e) {
    EditTypeDialog dlg = new EditTypeDialog(App.getFrame(), Local.getString("Edit resource type"));
    Dimension dlgSize = new Dimension(420, 450);
    dlg.setSize(dlgSize);
    Dimension frmSize = App.getFrame().getSize();
    Point loc = App.getFrame().getLocation();
    dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
    MimeType mt = (MimeType) typesList.getSelectedValue();
    String[] exts = mt.getExtensions();
    String extss = "";
    for (int i = 0; i < exts.length; i++)
        extss += exts[i] + " ";
    dlg.extField.setText(extss);
    dlg.descField.setText(mt.getLabel());
    dlg.iconLabel.setIcon(mt.getIcon());
    AppList appList = MimeTypesList.getAppList();
    dlg.appPanel.applicationField.setText(
        appList.getFindPath(mt.getAppId()) + "/" + appList.getExec(mt.getAppId()));
    dlg.appPanel.argumentsField.setText(appList.getCommandLinePattern(mt.getAppId()));
    dlg.setVisible(true);
    if (dlg.CANCELLED)
        return;
    String typeId = mt.getMimeTypeId();
    MimeTypesList.removeMimeType(typeId);
    mt = MimeTypesList.addMimeType(typeId);
    exts = dlg.extField.getText().trim().split(" ");
    for (int i = 0; i < exts.length; i++)
        mt.addExtension(exts[i]);
    mt.setLabel(dlg.descField.getText());
    if (dlg.appPanel.applicationField.getText().length() > 0) {
        File f = new File(dlg.appPanel.applicationField.getText());
        String appId = Util.generateId();
        appList.addApp(
            appId,
            f.getParent().replace('\\', '/'),
            f.getName().replace('\\', '/'),
            dlg.appPanel.argumentsField.getText());
        mt.setApp(appId);
    }
    if (dlg.iconPath.length() > 0)
        mt.setIconPath(dlg.iconPath);
    CurrentStorage.get().storeMimeTypesList();
    this.initTypesList();
    typesList.setSelectedValue(mt, true);

}
 
Example 60
Project: OpenJSharp   File: BasicScrollPaneUI.java   Source Code and License 4 votes vote down vote up
private void scroll(JScrollPane scrollpane, int orientation,
                    int direction, boolean block) {
    JViewport vp = scrollpane.getViewport();
    Component view;
    if (vp != null && (view = vp.getView()) != null) {
        Rectangle visRect = vp.getViewRect();
        Dimension vSize = view.getSize();
        int amount;

        if (view instanceof Scrollable) {
            if (block) {
                amount = ((Scrollable)view).getScrollableBlockIncrement
                         (visRect, orientation, direction);
            }
            else {
                amount = ((Scrollable)view).getScrollableUnitIncrement
                         (visRect, orientation, direction);
            }
        }
        else {
            if (block) {
                if (orientation == SwingConstants.VERTICAL) {
                    amount = visRect.height;
                }
                else {
                    amount = visRect.width;
                }
            }
            else {
                amount = 10;
            }
        }
        if (orientation == SwingConstants.VERTICAL) {
            visRect.y += (amount * direction);
            if ((visRect.y + visRect.height) > vSize.height) {
                visRect.y = Math.max(0, vSize.height - visRect.height);
            }
            else if (visRect.y < 0) {
                visRect.y = 0;
            }
        }
        else {
            if (scrollpane.getComponentOrientation().isLeftToRight()) {
                visRect.x += (amount * direction);
                if ((visRect.x + visRect.width) > vSize.width) {
                    visRect.x = Math.max(0, vSize.width - visRect.width);
                } else if (visRect.x < 0) {
                    visRect.x = 0;
                }
            } else {
                visRect.x -= (amount * direction);
                if (visRect.width > vSize.width) {
                    visRect.x = vSize.width - visRect.width;
                } else {
                    visRect.x = Math.max(0, Math.min(vSize.width - visRect.width, visRect.x));
                }
            }
        }
        vp.setViewPosition(visRect.getLocation());
    }
}