/** * */ 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); }
@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(); }
/** * 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; }
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; }
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 ); }
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; }
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); }
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(); }
/** * 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(); } }
@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; }
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); }
@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); }
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(); }
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); } }
/** * 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); }
@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; }
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(); } }
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); }
/** * 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); }
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; }
/** * 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; }
@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; }
@Override public Dimension getPreferredSize() { if (getContentSize() == 0) { return new Dimension(); } else { return super.getPreferredSize(); } }
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); }
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)); }
/** * 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(); }
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); }
/** * Ermittelt die Größe des Bildschirms. * * @return die Größe */ private Dimension getScreenSize() { if (screenSize == null) screenSize = Toolkit.getDefaultToolkit().getScreenSize(); return screenSize; }
/** 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(); }
/** * 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; }
/** * 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 }
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; } }
/** * 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(); }
@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(); }
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; }
/** * @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; }
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; }
/** 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(); }
@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; }