Java Code Examples for javax.swing.ImageIcon

The following are top voted examples for showing how to use javax.swing.ImageIcon. 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: Neukoelln_SER316   File: TaskTreeTableCellRenderer.java   View source code 6 votes vote down vote up
public static ImageIcon getPriorityIcon(Task t) {
    switch (t.getPriority()) {
    case Task.PRIORITY_NORMAL:
        return PR_NORMAL_ICON;
    case Task.PRIORITY_HIGHEST:
        return PR_HIGHEST_ICON;
    case Task.PRIORITY_HIGH:
        return PR_HIGH_ICON;
    case Task.PRIORITY_LOW:
        return PR_LOW_ICON;
    case Task.PRIORITY_LOWEST:
        return PR_LOWEST_ICON;
    }
    System.err.println("Problem finding priority icon");
    return null;
}
 
Example 2
Project: code-sentinel   File: RunCentralisedMAS.java   View source code 6 votes vote down vote up
protected void createPauseButton() {
    final JButton btPause = new JButton("Pause", new ImageIcon(RunCentralisedMAS.class.getResource("/images/resume_co.gif")));
    btPause.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            if (MASConsoleGUI.get().isPause()) {
                btPause.setText("Pause");
                MASConsoleGUI.get().setPause(false);
            } else {
                btPause.setText("Continue");
                MASConsoleGUI.get().setPause(true);
            }

        }
    });
    MASConsoleGUI.get().addButton(btPause);
}
 
Example 3
Project: PPRCarTrade   File: TelaVenda.java   View source code 6 votes vote down vote up
private void btn_CarregarImagemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_CarregarImagemActionPerformed
    // TODO add your handling code here:
    JFileChooser fc = new JFileChooser();
    FileFilter imageFilter = new FileNameExtensionFilter("Image files", ImageIO.getReaderFileSuffixes());
    fc.setFileFilter(imageFilter);
    int result = fc.showOpenDialog(null);
    if(result == JFileChooser.APPROVE_OPTION){
        try {
            String path = fc.getSelectedFile().getAbsolutePath();
            imagens.add(new ImageIcon(path));
            JOptionPane.showMessageDialog(this, "Imagem carregada com sucesso!");
        } catch(Exception e){
            JOptionPane.showMessageDialog(null, "Ocorreu um erro ao carregar a imagem!", "Erro", JOptionPane.ERROR_MESSAGE);
        }            
    }
}
 
Example 4
Project: SER316-Munich   File: App.java   View source code 6 votes vote down vote up
/**
 * Method showSplash.
 */
private void showSplash() {
	splash = new JFrame();
	ImageIcon spl =
		new ImageIcon(App.class.getResource("resources/splash.png"));
	JLabel l = new JLabel();
	l.setSize(400, 300);
	l.setIcon(spl);
	splash.getContentPane().add(l);
	splash.setSize(400, 300);
	Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
	splash.setLocation(
		(screenSize.width - 400) / 2,
		(screenSize.height - 300) / 2);
	splash.setUndecorated(true);
	splash.setVisible(true);
}
 
Example 5
Project: FreeCol   File: QuickActionMenu.java   View source code 6 votes vote down vote up
/**
 * Creates menu items for some goods in a market.
 *
 * @param marketLabel The {@code MarketLabel} to create entries for.
 */
private void createMarketMenu(MarketLabel marketLabel) {
    final AbstractGoods ag = marketLabel.getAbstractGoods();
    final Player player = freeColClient.getMyPlayer();

    this.setLabel(Messages.message("cargo"));
    JMenuItem name = new JMenuItem(
        Messages.getName(ag) + " (" + Messages.message("colopedia") + ")",
        new ImageIcon(
            gui.getImageLibrary().getSmallIconImage(ag.getType())));
    name.addActionListener((ActionEvent ae) -> {
            gui.showColopediaPanel(ag.getType().getId());
        });
    this.add(name);

    final Europe europe = this.freeColClient.getMyPlayer().getEurope();
    addMarketItems(ag, europe);

    if (!player.canTrade(ag.getType())) {
        addPayArrears(ag.getType());
    }
}
 
Example 6
Project: openvisualtraceroute   File: WWJPanel.java   View source code 6 votes vote down vote up
/**
 * Highlight the given annotation
 *
 * @param annotation
 * @param point
 */
private void highlightAnnotation(final LabeledPath label, final GeoPoint point) {
	final ScreenAnnotation annotation = label.getAnnotation();
	if (_lastSelection != null) {
		final LabeledPath lastSelectedLabel = _lastSelection.getLeft();
		final ScreenAnnotation lastSelectedAnnotation = lastSelectedLabel.getAnnotation();
		final GeoPoint lastSelectedPoint = _lastSelection.getRight();
		if (_mapShowLabel) {
			lastSelectedAnnotation.setAttributes(createAnnotationAttr(false, lastSelectedPoint.getCountryFlag(IMAGE_RESOLUTION), getText(lastSelectedPoint)));
			lastSelectedAnnotation.setAlwaysOnTop(false);
		} else {
			_renderableLayer.removeRenderable(lastSelectedLabel);
		}
	}
	final ImageIcon image = point.getCountryFlag(IMAGE_RESOLUTION);
	final String text = getText(point);
	annotation.setAttributes(createAnnotationAttr(true, image, text));
	annotation.setAlwaysOnTop(true);
	if (!_mapShowLabel) {
		_renderableLayer.addRenderable(label);
		_controller.redraw();
	}
	_lastSelection = Pair.of(label, point);
}
 
Example 7
Project: rapidminer   File: Item.java   View source code 6 votes vote down vote up
private ImageIcon getThumbnailIcon() {
	if (this.thumbIcon == null) {
		if (this.isDirectory) {
			this.thumbIcon = getBigSystemIcon();
		} else {
			try {
				this.thumbIcon = new ImageIcon(Tools.getScaledInstance(this.file));
				if (this.thumbIcon == null) {
					this.thumbIcon = getBigSystemIcon();
				}
			} catch (Exception ex) {
				this.thumbIcon = getBigSystemIcon();
			}
		}
	}
	return this.thumbIcon;
}
 
Example 8
Project: 2D-Elliptic-Mesh-Generator   File: PlotPanel.java   View source code 6 votes vote down vote up
public void toGraphicFile(File file) throws IOException {
    // otherwise toolbar appears
    plotToolBar.setVisible(false);

    Image image = createImage(getWidth(), getHeight());
    paint(image.getGraphics());
    image = new ImageIcon(image).getImage();

    BufferedImage bufferedImage = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_RGB);
    Graphics g = bufferedImage.createGraphics();
    g.drawImage(image, 0, 0, Color.WHITE, null);
    g.dispose();

    // make it reappear
    plotToolBar.setVisible(true);

    try {
        ImageIO.write((RenderedImage) bufferedImage, "PNG", file);
    } catch (IllegalArgumentException ex) {
    }
}
 
Example 9
Project: SER316-Aachen   File: App.java   View source code 6 votes vote down vote up
/**
 * Method showSplash.
 */
private void showSplash() {
	splash = new JFrame();
	ImageIcon spl =
		new ImageIcon(App.class.getResource("resources/splash.png"));
	JLabel l = new JLabel();
	l.setSize(400, 300);
	l.setIcon(spl);
	splash.getContentPane().add(l);
	splash.setSize(400, 300);
	Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
	splash.setLocation(
		(screenSize.width - 400) / 2,
		(screenSize.height - 300) / 2);
	splash.setUndecorated(true);
	splash.setVisible(true);
}
 
Example 10
Project: zooracle   File: OpenCVUtils.java   View source code 6 votes vote down vote up
/**
 * Display image in a frame
 *
 * @param title
 * @param img
 */
public static void imshow(String title, Mat img) {
	 
    
    // Convert image Mat to a jpeg
    MatOfByte imageBytes = new MatOfByte();
    Highgui.imencode(".jpg", img, imageBytes);
    
    try {
        // Put the jpeg bytes into a JFrame window and show.
        JFrame frame = new JFrame(title);
        frame.getContentPane().add(new JLabel(new ImageIcon(ImageIO.read(new ByteArrayInputStream(imageBytes.toArray())))));
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setVisible(true);
        frame.setLocation(30 + (windowNo*20), 30 + (windowNo*20));
        windowNo++;
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 11
Project: rapidminer   File: Tools.java   View source code 6 votes vote down vote up
public static ImageIcon getSmallSystemIcon(Image img) throws Exception {
	if (img.getWidth(null) > 20 || img.getHeight(null) > 20) {
		if (img.getWidth(null) > img.getHeight(null)) {
			width = 18;
			height = img.getHeight(null) * 18 / img.getWidth(null);
		} else {
			height = 18;
			width = img.getWidth(null) * 18 / img.getHeight(null);
		}
	} else {
		return new ImageIcon(img);
	}

	dest = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR);
	dest2 = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR);

	g = dest.getGraphics();
	g.drawImage(img, 1, 1, width, height, null);

	g.dispose();

	blurOperator.filter(dest, dest2);

	return new ImageIcon(dest2);
}
 
Example 12
Project: LightSIP   File: TabbedPaneDemo.java   View source code 6 votes vote down vote up
public TabbedPaneDemo() {
    ImageIcon icon = new ImageIcon("images/middle.gif");
    JTabbedPane tabbedPane = new JTabbedPane();

    Component panel1 = makeTextPanel("Blah");
    tabbedPane.addTab("One", icon, panel1, "Does nothing");
    tabbedPane.setSelectedIndex(0);

    Component panel2 = makeTextPanel("Blah blah");
    tabbedPane.addTab("Two", icon, panel2, "Does twice as much nothing");

    Component panel3 = makeTextPanel("Blah blah blah");
    tabbedPane.addTab("Three", icon, panel3, "Still does nothing");

    Component panel4 = makeTextPanel("Blah blah blah blah");
    tabbedPane.addTab("Four", icon, panel4, "Does nothing at all");

    //Add the tabbed pane to this panel.
    setLayout(new GridLayout(1, 1));
    add(tabbedPane);
}
 
Example 13
Project: Wilmersdorf_SER316   File: TaskTreeTableCellRenderer.java   View source code 6 votes vote down vote up
public static ImageIcon getPriorityIcon(Task t) {
    switch (t.getPriority()) {
    case Task.PRIORITY_NORMAL:
        return PR_NORMAL_ICON;
    case Task.PRIORITY_HIGHEST:
        return PR_HIGHEST_ICON;
    case Task.PRIORITY_HIGH:
        return PR_HIGH_ICON;
    case Task.PRIORITY_LOW:
        return PR_LOW_ICON;
    case Task.PRIORITY_LOWEST:
        return PR_LOWEST_ICON;
    }
    System.err.println("Problem finding priority icon");
    return null;
}
 
Example 14
Project: JuggleMasterPro   File: PreferencesDialogJButton.java   View source code 6 votes vote down vote up
final public void doLoadImages() {

		int intLiconFile =
							this.bolGresetPreferences ? Constants.intS_FILE_ICON_RESET_BW
														: this.bolGsavePreferences ? this.bolGcloseDialog ? Constants.intS_FILE_ICON_OK_BW
																											: Constants.intS_FILE_ICON_APPLY_BW
																					: this.bolGcloseDialog ? Constants.intS_FILE_ICON_CANCEL_BW
																											: Constants.intS_FILE_ICON_RESTORE_BW;
		final ImageIcon icoL = this.objGcontrolJFrame.getJuggleMasterPro().getImageIcon(intLiconFile, 2);

		intLiconFile =
						this.bolGresetPreferences ? Constants.intS_FILE_ICON_RESET
													: this.bolGsavePreferences ? this.bolGcloseDialog ? Constants.intS_FILE_ICON_OK
																										: Constants.intS_FILE_ICON_APPLY
																				: this.bolGcloseDialog ? Constants.intS_FILE_ICON_CANCEL
																										: Constants.intS_FILE_ICON_RESTORE;
		final ImageIcon icoLrollOver = this.objGcontrolJFrame.getJuggleMasterPro().getImageIcon(intLiconFile, 2);

		Tools.setIcons(this, icoL, icoLrollOver);
	}
 
Example 15
Project: Hotel-Properties-Management-System   File: LanguageCmbBox.java   View source code 6 votes vote down vote up
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected,
		boolean cellHasFocus) {
	

	int selectedIndex = ((Integer) value).intValue();

	if (isSelected) {
		setBackground(list.getSelectionBackground());
		setForeground(list.getSelectionForeground());
	} else {
		setBackground(list.getBackground());
		setForeground(list.getForeground());
	}

	ImageIcon icon = iconArray[selectedIndex];
	setIcon(icon);
	
	return this;
}
 
Example 16
Project: Dahlem_SER316   File: TaskTreeTableCellRenderer.java   View source code 6 votes vote down vote up
public static ImageIcon getStatusIcon(Task t) {
    switch (t.getStatus(CurrentDate.get())) {
    case Task.ACTIVE:
        return TASK_ACTIVE_ICON;
    case Task.SCHEDULED:
        return TASK_SCHEDULED_ICON;
    case Task.DEADLINE:
        return TASK_DEADLINE_ICON;
    case Task.OVERDUE:
        return TASK_FAILED_ICON;
    case Task.COMPLETED:
        return TASK_COMPLETED_ICON;
    }
    System.err.println("Problem finding status icon");
    return null;
}
 
Example 17
Project: trashjam2017   File: Hiero.java   View source code 5 votes vote down vote up
static Icon getColorIcon (java.awt.Color color) {
	BufferedImage image = new BufferedImage(32, 16, BufferedImage.TYPE_INT_RGB);
	java.awt.Graphics g = image.getGraphics();
	g.setColor(color);
	g.fillRect(1, 1, 30, 14);
	g.setColor(java.awt.Color.black);
	g.drawRect(0, 0, 31, 15);
	return new ImageIcon(image);
}
 
Example 18
Project: Neukoelln_SER316   File: ImagePreview.java   View source code 5 votes vote down vote up
public void loadImage() {
    if (file == null) {
        return;
    }

    ImageIcon tmpIcon = new ImageIcon(file.getPath());
    if (tmpIcon.getIconWidth() > 90) {
        thumbnail = new ImageIcon(tmpIcon.getImage().
                             getScaledInstance(90, -1,
                                               Image.SCALE_DEFAULT));
    } else {
        thumbnail = tmpIcon;
    }
}
 
Example 19
Project: powertext   File: AutoCompleteDescWindow.java   View source code 5 votes vote down vote up
public ToolBarBackAction(boolean ltr) {
	String img = "org/fife/ui/autocomplete/arrow_" +
				(ltr ? "left.png" : "right.png");
	ClassLoader cl = getClass().getClassLoader();
	Icon icon = new ImageIcon(cl.getResource(img));
	putValue(Action.SMALL_ICON, icon);
}
 
Example 20
Project: ramus   File: ExcelPlugin.java   View source code 5 votes vote down vote up
public ExportToExcelAction(TableView tableView) {
    this.tableView = tableView;
    putValue(ACTION_COMMAND_KEY, "Action.ExportToExcel");
    putValue(ACTION_STRING_GETTER, ExcelPlugin.this);
    putValue(SMALL_ICON, new ImageIcon(getClass().getResource(
            "/com/ramussoft/excel/export-to-excel.png")));
}
 
Example 21
Project: ramus   File: ModelsPanel.java   View source code 5 votes vote down vote up
private void init() {
    treeModel.setRoot(createRoot());

    tree = new JTree(treeModel) {
        @Override
        public TreeCellRenderer getCellRenderer() {
            TreeCellRenderer renderer = super.getCellRenderer();
            if (renderer == null)
                return null;
            ((DefaultTreeCellRenderer) renderer).setLeafIcon(new ImageIcon(
                    getClass().getResource("/images/function.png")));
            return renderer;
        }
    };

    tree.setCellRenderer(new Renderer());

    tree.setEditable(true);

    tree.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if ((e.getButton() == MouseEvent.BUTTON1)
                    && (e.getClickCount() == 2)) {
                openDiagram();
            }
        }

    });

    tree.setRootVisible(true);

    JScrollPane pane = new JScrollPane();
    pane.setViewportView(tree);
    this.add(pane, BorderLayout.CENTER);
}
 
Example 22
Project: Weather-Forecast   File: WeatherImp.java   View source code 5 votes vote down vote up
public ImageIcon WeatherIcon(final String dscription, boolean flag) {
    if (dscription.contains(WeatherDescription.Clouds)) {
        return new ImageIcon(getClass().getResource(WeatherDescription.CloudIcon100PX));
    } else if (dscription.contains(WeatherDescription.Rain)) {
        return new ImageIcon(getClass().getResource(WeatherDescription.RainIcon100PX));
    } else if (dscription.contains(WeatherDescription.Snow)) {
        return new ImageIcon(getClass().getResource(WeatherDescription.SnowIcon100PX));
    } else if (dscription.contains(WeatherDescription.Clear)) {
        return new ImageIcon(getClass().getResource(WeatherDescription.SunIcon100PX));
    } else {
        return null;
    }
}
 
Example 23
Project: freecol   File: GoodsLabel.java   View source code 5 votes vote down vote up
/**
 * Set whether only a partial amount is to be selected.
 *
 * @param partialChosen The new partial choice.
 */
@Override
public void setPartialChosen(boolean partialChosen) {
    super.setPartialChosen(partialChosen);
    ImageLibrary lib = gui.getImageLibrary();
    Image image = partialChosen
                  ? lib.getSmallIconImage(getType())
                  : lib.getIconImage(getType());
    setIcon(new ImageIcon(image));
}
 
Example 24
Project: ramus   File: OtherElementTableCellEditor.java   View source code 5 votes vote down vote up
private JButton createEditButton() {
    JButton edit = new JButton();
    edit.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            edit();
        }
    });
    edit.setIcon(new ImageIcon(getClass().getResource(
            "/com/ramussoft/gui/edit.png")));
    edit.setToolTipText(GlobalResourcesManager.getString("edit"));
    edit.setFocusable(false);
    edit.setPreferredSize(new Dimension(16, 16));
    return edit;
}
 
Example 25
Project: defense-solutions-proofs-of-concept   File: BasemapWidget.java   View source code 5 votes vote down vote up
public BasemapWidget(BasemapLayer layer, ButtonGroup buttonGroup) {
    initComponents();
    this.layer = layer;
    if (layer.getLayer().isVisible()) {
        jToggleButton_showBasemap.setSelected(true);
        jToggleButton_showBasemap.setBorder(BORDER_SELECTED);
    } else {
        jToggleButton_showBasemap.setBorder(BORDER_UNSELECTED);
    }
    jLabel_label.setText("<html>" + layer.getLayer().getName() + "</html>");
    
    Icon icon = layer.getThumbnail();
    if (null == icon) {
        icon = guessIconForLayerName(layer.getLayer().getName());
    }
    if (null != icon) {
        if (null != icon && icon instanceof ImageIcon) {
            ImageIcon imageIcon = (ImageIcon) icon;
            icon = Utilities.rescale(imageIcon, jToggleButton_showBasemap.getPreferredSize(), this);
        }
        jToggleButton_showBasemap.setIcon(icon);
    }
    
    setSize(getLayout().preferredLayoutSize(this));
    
    buttonGroup.add(jToggleButton_showBasemap);
}
 
Example 26
Project: Pixie   File: BoundingBoxWindow.java   View source code 5 votes vote down vote up
/**
 * Display the image with the segmented box.
 */
private void showImage() {
    // resize image with the ratio relative to the original image, in order to prevent data loose
    workImg = resize.resizeImage(origImg);

    // if the image was highlighted, do it again
    if (HISTO_ORIGINAL.equals(jBHistogramEq.getText())) {
        workImg = Utils.histogramEqColor(workImg);
    }

    // get the graphics of the image
    Graphics2D g2d = workImg.createGraphics();

    if ((currentObject instanceof ObjectBBox) || (currentObject instanceof ObjectScribble)) {
        // draw the outer box of the object
        Rectangle bBox = drawOuterBox(g2d);

        // display the object map if the object is scribble
        displayObjMap(bBox);

    } else if (currentObject instanceof ObjectPolygon) {
        // draw the polygon object
        drawPolygon(g2d);
    }

    g2d.dispose();

    // display the image
    ImageIcon iconLogo = new ImageIcon(workImg);
    jLImagePreview.setIcon(iconLogo);
}
 
Example 27
Project: ramus   File: PrintPreviewComponent.java   View source code 5 votes vote down vote up
public PageSetupAction() {
    super(GlobalResourcesManager.getString("Action.PageSetup"));
    putValue(
            SMALL_ICON,
            new ImageIcon(getClass().getResource(
                    "/com/ramussoft/gui/page-setup.png")));
    putValue(ACTION_COMMAND_KEY, "Action.PageSetup");
    putValue(SHORT_DESCRIPTION,
            GlobalResourcesManager.getString("Action.PageSetup"));
}
 
Example 28
Project: pm-home-station   File: LabelObserver.java   View source code 5 votes vote down vote up
@Override
public void disconnected() {
    btnConnect.setText("Connect");
    deviceStatus.setText("Status: Device sensor disconnected");
    if (icon != null) {
        icon.setIcon(new ImageIcon(disconnectedIcon.getScaledInstance(icon.getIcon().getIconWidth(), -1, Image.SCALE_SMOOTH)));
    }
}
 
Example 29
Project: Tarski   File: mxGraphComponent.java   View source code 5 votes vote down vote up
/**
 * 
 */
public void setBackgroundImage(ImageIcon value) {
  ImageIcon oldValue = backgroundImage;
  backgroundImage = value;

  firePropertyChange("backgroundImage", oldValue, backgroundImage);
}
 
Example 30
Project: ramus   File: TableEditor.java   View source code 5 votes vote down vote up
public MoveToOtherElementAction() {
    putValue(ACTION_COMMAND_KEY,
            "Action.MoveTableElementToOtherElement");
    putValue(
            SMALL_ICON,
            new ImageIcon(
                    getClass()
                            .getResource(
                                    "/com/ramussoft/gui/table/move-table-element-to-other-element.png")));
    setEnabled(false);
}
 
Example 31
Project: FreeCol   File: SwingGUI.java   View source code 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public boolean confirm(Tile tile, StringTemplate template, Unit unit,
                       String okKey, String cancelKey) {
    return canvas.showConfirmDialog(tile,
        Utility.localizedTextArea(template),
        new ImageIcon(imageLibrary.getUnitImage(unit)),
        okKey, cancelKey);
}
 
Example 32
Project: ProyectoPacientes   File: JDagEspecialidad.java   View source code 5 votes vote down vote up
private void btnAgregarKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_btnAgregarKeyPressed
    // TODO add your handling code here:
    String cc = this.cc.getText();
    String ee = this.ee.getText();
    if(cc.length()==0||ee.length()==0)
    {
        JOptionPane.showMessageDialog(null, "Los registros no pueden estar vacios\nPor favor llene los registros", "Advertencia", JOptionPane.WARNING_MESSAGE);
        this.cc.requestFocus();
    }
    else
    {
        if(cc.length()>50||ee.length()>50)
        {
            JOptionPane.showMessageDialog(null, "El numero de caracteres permitido es de 50", "Advertencia", JOptionPane.WARNING_MESSAGE);
            this.cc.requestFocus();
        }
        else
        {
            AsignarEsp asignar = new AsignarEsp();
            Icon i = new ImageIcon(getClass().getResource("/Imagenes/Aceptar.jpg"));
            JOptionPane.showMessageDialog(null,asignar.AgregarEspecialidad(this.cc.getText(), this.ee.getText()),"Mensaje",JOptionPane.INFORMATION_MESSAGE, i);
            LLenarCombo llenar = new LLenarCombo();
            llenar.LimpiarCombo(AsignarEspecialidad.Combo);
            llenar.Presentar(AsignarEspecialidad.Combo);
            this.hide();
        }
    }
}
 
Example 33
Project: incubator-netbeans   File: EditableDisplayerTest.java   View source code 5 votes vote down vote up
/** Asserts that a pixel at a given position in an image matches a
 * pixel in a given position in a component */
private synchronized void assertPixelFromImage(String msg, final Image i, final Component c, final int imageX, final int imageY, final int compX, final int compY) throws Exception {
    final BufferedImage bi = i instanceof BufferedImage ? (BufferedImage) i : toBufferedImage(i);
    throwMe = null;
    sleep();
    
    int rgb = bi.getRGB(imageX, imageY);
    Color color = new Color(rgb);
    
    
    //uncomment the code below for diagnosing painting problems
    //and seeing which pixel you'return really checking
    JFrame jf = new JFrame("assertPixelFromImage " + count + " (look for the yellow line)") {
        public void paint(Graphics g) {
            new ImageIcon(bi).paintIcon(this, g, 25, 25);
            g.setColor(Color.YELLOW);
            g.drawLine(imageX+20, imageY+25, imageX+25, imageY+25);
        }
    };
    jf.setLocation(500,500);
    jf.setSize(100,100);
    jf.show();
    
    try {
        assertPixel(msg, c, color, compX, compY);
    } catch (Exception e) {
        throwMe = e;
    }
    if (throwMe != null) {
        throw throwMe;
    }
}
 
Example 34
Project: SUAPPasswordResetter   File: Login.java   View source code 5 votes vote down vote up
private void logar() {
    if (campoUsuario.equals("") || campoSenha.equals("")) {
        JOptionPane.showMessageDialog(null, "Campos matrícula ou senha não devem estar vazios.", "Atenção", JOptionPane.INFORMATION_MESSAGE, new ImageIcon(Toolkit.getDefaultToolkit().getImage("icon/64.png")));
    } else {
        Aguarde a = new Aguarde(null, false);
        a.setAlwaysOnTop(true);
        a.setVisible(true);

        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                Servidor servidor = new Servidor(campoUsuario.getText(), String.valueOf(campoSenha.getPassword()));
                Suap s = new Suap(servidor);

                try {
                    if (s.verificarCredenciais()) {
                        setVisible(false);
                        a.setVisible(false);
                    } else {
                        a.setVisible(false);
                        JOptionPane.showMessageDialog(Login.this, "Credenciais inválidas.");
                    }
                } catch (Exception ex) {
                    JOptionPane.showMessageDialog(Login.this, ex.getMessage());
                }
            }
        });

    }
}
 
Example 35
Project: org.alloytools.alloy   File: OurUtil.java   View source code 5 votes vote down vote up
/**
 * Load the given image file from an accompanying JAR file, and return it as
 * an Icon object.
 */
public static Icon loadIcon(String pathname) {
	URL url = OurUtil.class.getClassLoader().getResource(pathname);
	if (url != null)
		return new ImageIcon(Toolkit.getDefaultToolkit().createImage(url));
	return new ImageIcon(new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB));
}
 
Example 36
Project: FreeCol   File: ReportCompactColonyPanel.java   View source code 5 votes vote down vote up
private List<JButton> unitButtons(final Map<UnitType, Suggestion> suggestions,
                                  List<UnitType> have, Colony colony) {
    final String cac = colony.getId();
    List<JButton> result = new ArrayList<>();
    final Comparator<UnitType> buttonComparator
        = Comparator.comparing(ut -> suggestions.get(ut),
                               Suggestion.descendingAmountComparator);
    for (UnitType type : sort(suggestions.keySet(), buttonComparator)) {
        boolean present = have.contains(type);
        Suggestion suggestion = suggestions.get(type);
        String label = Integer.toString(suggestion.amount);
        ImageIcon icon
            = new ImageIcon(this.lib.getTinyUnitImage(type, false));
        StringTemplate tip = (suggestion.oldType == null)
            ? stpld("report.colony.wanting")
                .addName("%colony%", colony.getName())
                .addNamed("%unit%", type)
                .addStringTemplate("%location%",
                    suggestion.workLocation.getLabel())
                .addNamed("%goods%", suggestion.goodsType)
                .addAmount("%amount%", suggestion.amount)
            : stpld("report.colony.improving")
                .addName("%colony%", colony.getName())
                .addNamed("%oldUnit%", suggestion.oldType)
                .addNamed("%unit%", type)
                .addStringTemplate("%location%",
                    suggestion.workLocation.getLabel())
                .addNamed("%goods%", suggestion.goodsType)
                .addAmount("%amount%", suggestion.amount);
        JButton b = newButton(cac, label, icon,
                              (present) ? cGood : cPlain, tip);
        if (present) b.setFont(b.getFont().deriveFont(Font.BOLD));
        result.add(b);
    }
    return result;
}
 
Example 37
Project: java-course   File: TabComponent.java   View source code 5 votes vote down vote up
/**
 * Constructor for TabComponent class.
 * 
 * @param pane
 *            {@link JTabbedPane} parent component.
 * @param observer
 *            Main JNotepadPP frame.
 * @param lp
 *            Localization provider.
 */
public TabComponent(JTabbedPane pane, JNotepadPP observer,
        ILocalizationProvider lp) {

    super(new FlowLayout(FlowLayout.LEFT, 0, 0));
    this.lp = lp;
    this.observer = observer;
    setOpaque(false);

    JLabel label = new JLabel() {
        private static final long serialVersionUID = 1L;

        public String getText() {
            int i = pane.indexOfTabComponent(TabComponent.this);
            if (i != -1) {
                this.revalidate();
                return pane.getTitleAt(i);

            }
            return "";
        }
    };

    ImageIcon image = new ImageIcon(this.getClass().getResource(
            "res/green.png"));
    picLabel = new JLabel(image);
    add(picLabel);
    add(label);

    picLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
    label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
    closeButton = new CloseTabButton(this);
    add(closeButton);

    setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0));
}
 
Example 38
Project: Equella   File: GResourceSelector.java   View source code 5 votes vote down vote up
@Override
public JComponent generateControl()
{
	field = new JTextField();
	field.setMaximumSize(new Dimension(Short.MAX_VALUE, 20));

	if( items.size() >= 1 )
	{
		field.setText(((Item) items.get(0)).getValue());
	}

	JButton browse = new JButton("Browse");
	browse.setIcon(new ImageIcon(getClass().getResource("/images/browse.gif")));
	browse.setHorizontalTextPosition(SwingConstants.RIGHT);
	Dimension browseSize = browse.getPreferredSize();
	browseSize.height = 20;
	browse.setMaximumSize(browseSize);
	browse.addActionListener(this);

	JPanel group = new JPanel();
	group.setLayout(new BoxLayout(group, BoxLayout.X_AXIS));
	group.add(field);
	group.add(Box.createRigidArea(new Dimension(5, 0)));
	group.add(browse);
	group.setAlignmentX(Component.LEFT_ALIGNMENT);

	return group;
}
 
Example 39
Project: Cognizant-Intelligent-Test-Scripter   File: BaseEditor.java   View source code 5 votes vote down vote up
private BaseEditor() {

        this.setUndecorated(this.isUndecorated());
        initComponents();
        this.setIconImage(new ImageIcon(getClass().getResource("/explorer/explorer.png")).getImage());
        this.setBackground(new Color(255, 255, 255, 0));
        this.setAlwaysOnTop(true);
        add(slider);

    }
 
Example 40
Project: jaer   File: RNNfilter.java   View source code 5 votes vote down vote up
/**
 * Converts the arraylist holding the recorded features and prints it as an
 * image in a new JFrame
 *
 * @param input
 * @throws IOException
 */
public void printDigit(ArrayList<int[]> input) throws IOException {
    if (input.isEmpty()) {
        return;
    }
    int xLength = input.size();
    int yLength = input.get(0).length;
    int maxValue = 0;
    int[][] tmpImage = new int[xLength][yLength];
    for (int i = 0; i < xLength; i++) {
        tmpImage[i] = input.get(i);
    }
    maxValue = RNNfilter.maxValueIn2DArray(tmpImage);
    int[][] tmpImageScaled = RNNfilter.rescale2DArray(tmpImage, 255 / maxValue);
    BufferedImage newImage = new BufferedImage(xLength, yLength, BufferedImage.TYPE_INT_RGB);
    for (int x = 0; x < xLength; x++) {
        for (int y = 0; y < yLength; y++) {
            newImage.setRGB(x, y, tmpImageScaled[x][y]);
        }
    }
    ImageIcon icon = new ImageIcon(newImage);
    ScaledImagePanel scaledImage = new ScaledImagePanel(icon);
    JFrame frame = new JFrame();
    frame.setSize(xLength, yLength);
    frame.add(scaledImage);
    frame.setVisible(true);

}