Example usage for java.awt Toolkit getImage

List of usage examples for java.awt Toolkit getImage

Introduction

In this page you can find the example usage for java.awt Toolkit getImage.

Prototype

public abstract Image getImage(URL url);

Source Link

Document

Returns an image which gets pixel data from the specified URL.

Usage

From source file:Visao.Relatorio.Relatorio_QuantidadeReclamacoesSexo.java

/**
 * Creates new form sexo//from  ww w  . j  av a2s.c o  m
 */
public Relatorio_QuantidadeReclamacoesSexo(java.awt.Frame parent, boolean modal, GeneralDAO dao) {
    super(parent, modal);
    initComponents();
    this.dao = dao;
    controleRelatorio = new ControleRelatorio(dao);
    jButton2.setEnabled(false);
    this.parent = parent;
    this.setSize(new Dimension(404, 130));
    Toolkit kit = this.getToolkit();
    java.awt.Image icone = kit.getImage("src/Icones/relatorio.png");
    this.setIconImage(icone);
}

From source file:SplashScreen.java

/**
 * Create a new splash screen object of the specified image.
 * The image file is located and referred to through the deployment, not
 * the local file system; A typical value might be "/com/company/splash.jpg".
 * /* www  .  j a v a2 s .  co m*/
 * @param imageFileName  Name of image file resource to act as splash screen.
 */
public SplashScreen(String imageFileName) {
    super(new Frame());

    try {
        Toolkit toolkit = Toolkit.getDefaultToolkit();

        URL imageUrl = getClass().getResource(imageFileName);
        image_ = toolkit.getImage(imageUrl);

        MediaTracker mediaTracker = new MediaTracker(this);
        mediaTracker.addImage(image_, 0);
        mediaTracker.waitForID(0);

        width_ = image_.getWidth(this);
        height_ = image_.getHeight(this);

        Dimension screenSize = toolkit.getScreenSize();

        x_ = (screenSize.width - width_) / 2;
        y_ = (screenSize.height - height_) / 2;
    } catch (Exception exception) {
        exception.printStackTrace();
        image_ = null;
    }
}

From source file:Visao.Relatorio.Relatorio_QuantidadeReclamacoesUF.java

/**
 * Creates new form UF/* w ww.jav  a2s. c  om*/
 */
public Relatorio_QuantidadeReclamacoesUF(java.awt.Frame parent, boolean modal, GeneralDAO dao) {
    super(parent, modal);
    initComponents();
    this.dao = dao;
    controleRelatorio = new ControleRelatorio(dao);
    this.parent = parent;
    jButton2.setEnabled(false);
    Toolkit kit = this.getToolkit();
    java.awt.Image icone = kit.getImage("src/Icones/relatorio.png");
    this.setIconImage(icone);
}

From source file:edu.harvard.i2b2.analysis.ui.WaitPanel.java

public GIFPanel(java.awt.Image img) {
    super();//  w ww.  ja  v a2s.  c  om
    Toolkit kit = Toolkit.getDefaultToolkit();

    this.img = kit.getImage("waiting.gif");
    runner = new Thread(this);
    // timer = new TimeCounter();
    runner.start();
}

From source file:SizedFrameTest.java

public SizedFrame() {
    // get screen dimensions

    Toolkit kit = Toolkit.getDefaultToolkit();
    Dimension screenSize = kit.getScreenSize();
    int screenHeight = screenSize.height;
    int screenWidth = screenSize.width;

    // set frame width, height and let platform pick screen location

    setSize(screenWidth / 2, screenHeight / 2);
    setLocationByPlatform(true);/*from   ww  w  . ja va2 s  . c  o  m*/

    // set frame icon and title

    Image img = kit.getImage("icon.gif");
    setIconImage(img);
    setTitle("SizedFrame");
}

From source file:net.chaosserver.timelord.swingui.Timelord.java

/**
 * Starts up the timelord application and displays the frame.
 *//*from  w ww .  ja v a  2  s .  co  m*/
public void start() {
    applicationFrame = new JFrame("Timelord");

    // Get the pretty application icon
    URL iconUrl = this.getClass().getResource("/net/chaosserver/timelord/TimelordIcon.gif");

    if (log.isTraceEnabled()) {
        log.trace("iconUrl is [" + iconUrl + "]");
    }

    if (iconUrl != null) {
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Image applicationImage = toolkit.getImage(iconUrl);
        applicationIcon = new ImageIcon(applicationImage);
        applicationFrame.setIconImage(applicationImage);
    } else {
        if (log.isWarnEnabled()) {
            log.warn("Cound not find icon url");
        }
    }

    if (!isAlreadyRunning() && !isUpgradeRequested()) {
        TimelordMenu menu = new TimelordMenu(this);
        applicationFrame.setJMenuBar(menu);
        applicationFrame.addWindowListener(new WindowCloser());

        if (OsUtil.isMac()) {
            try {
                Class<?> macSwingerClass = Class
                        .forName("net.chaosserver.timelord." + "swingui.macos.MacSwinger");

                Constructor<?> macSwingerConstructor = macSwingerClass
                        .getConstructor(new Class[] { Timelord.class });

                macSwingerConstructor.newInstance(new Object[] { this });
            } catch (Exception e) {
                // Shouldn't happen, but not a big deal
                if (log.isWarnEnabled()) {
                    log.warn("Failed to create the MacSwinger", e);
                }
            }

        }

        TimelordDataReaderWriter timelordDataRW = new XmlDataReaderWriter();

        try {
            TimelordData inputTimelordData = timelordDataRW.readTimelordData();
            inputTimelordData.cleanse();
            inputTimelordData.resetTaskListeners();
            setTimelordData(inputTimelordData);
            menu.setTimelordData(getTimelordData());

            applicationFrame.setSize(loadLastFrameSize());
            timelordTabbedPane = new TimelordTabbedPane(getTimelordData());
            applicationFrame.getContentPane().add(timelordTabbedPane);

            applicationFrame.setLocation(loadLastFrameLocation());
            applicationFrame.setVisible(true);

            // If there is no data for Today, let the user set the
            // start time.
            TimelordDayView timelordDayView = new TimelordDayView(inputTimelordData,
                    DateUtil.trunc(new Date()));

            if (timelordDayView.getTotalTimeToday(true) == 0) {
                menu.timelord.changeStartTime(true);
            }

            bringToFrontThread = new BringToFrontThread(applicationFrame, this);
            bringToFrontThread.start();

            autoSaveThread = new AutoSaveThread(getTimelordData());
            autoSaveThread.start();
        } catch (TimelordDataException e) {
            String shutdown = "Shutdown";
            Object[] options = { shutdown };

            JOptionPane.showOptionDialog(null, "There was an unrecoverable error trying to load "
                    + "the file.\nTimelord was probably shutdown " + "in the middle of the last write.\nThere "
                    + "should be a lot of backup files inside the "
                    + "defaut location.\nCopy one of the backups "
                    + "over the most recent, restart, and keep your " + "fingers crossed.\n" + e,
                    "Timelord Data File Corrupted", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE, null,
                    options, shutdown);

            stop();
        }
    } else {
        stop();
    }
}

From source file:Forms.frm_Penghuni.java

private void btnCariKTPActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCariKTPActionPerformed
    // TODO add your handling code here:
    FileNameExtensionFilter filter = new FileNameExtensionFilter("Image Files", "jpg", "png", "jpeg");
    jfc = new JFileChooser();
    jfc.setFileFilter(filter);//from  www. j a  v  a 2s.  co m
    if (jfc.showOpenDialog(pnlKTP) == JFileChooser.APPROVE_OPTION) {
        Rectangle rect1 = pnlKTP.getBounds();
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Image image = toolkit.getImage(jfc.getSelectedFile().getAbsolutePath());
        Image imagedResized = image.getScaledInstance(rect1.width, rect1.height, Image.SCALE_DEFAULT);
        ImageIcon imageIcon = new ImageIcon(imagedResized);

        pnlKTP.setBackgroundImage(imageIcon);
        tfPasKTP.setText(jfc.getSelectedFile().getName());

        file = new File(jfc.getSelectedFile().getPath());
    }
}

From source file:Forms.frm_Penghuni.java

private void btnCariFotoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCariFotoActionPerformed
    // TODO add your handling code here:
    FileNameExtensionFilter filter = new FileNameExtensionFilter("Image Files", "jpg", "png", "jpeg");
    jfc1 = new JFileChooser();
    jfc1.setFileFilter(filter);/*from  ww  w.  ja  va  2s  . co  m*/

    if (jfc1.showOpenDialog(pnlFoto) == JFileChooser.APPROVE_OPTION) {

        Rectangle rect = pnlFoto.getBounds();

        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Image image1 = toolkit.getImage(jfc1.getSelectedFile().getAbsolutePath());
        Image imagedResized = image1.getScaledInstance(rect.width, rect.height, Image.SCALE_DEFAULT);
        ImageIcon imageIcon1 = new ImageIcon(imagedResized);

        pnlFoto.setBackgroundImage(imageIcon1);
        tfPasFoto.setText(jfc1.getSelectedFile().getName());

        file1 = new File(jfc1.getSelectedFile().getPath());
    }
}

From source file:Forms.frm_Penghuni.java

private void btnEditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditActionPerformed
    // TODO add your handling code here:
    if ((tblPenghuni.getSelectedRow() == -1)) {
        JOptionPane.showMessageDialog(null, "Silahkan pilih baris yang ingin diedit pada Tabel..");
    } else {/*from   ww  w . j  a  v a 2  s .  co m*/
        int baris = tblPenghuni.getSelectedRow();
        id_penyewa = tblPenghuni.getValueAt(baris, 0).toString();

        try {
            String sql = "Select *from penyewa where id_penyewa = " + id_penyewa + ";";
            stt = con.createStatement();
            rss = stt.executeQuery(sql);
            while (rss.next()) {
                Object[] o = new Object[14];
                o[0] = rss.getString("id_penyewa");
                o[1] = rss.getString("nama");
                o[2] = rss.getString("alamat");
                o[3] = rss.getString("tempat_lahir");
                o[4] = rss.getDate("tgl_lahir");
                o[5] = rss.getString("jk");
                o[6] = rss.getString("noktp");
                o[7] = rss.getString("nohp");
                o[8] = rss.getString("email");
                o[9] = rss.getString("pekerjaan");
                o[10] = rss.getString("alamat_kerja");
                o[11] = rss.getString("notelp_kerja");
                o[12] = rss.getString("foto_wajah");
                o[13] = rss.getString("foto_ktp");

                id_penyewa = rss.getString("id_penyewa");
                tfNamaPenghuni.setText(o[1].toString());
                tfAlamatPenghuni.setText(o[2].toString());
                tfTempatLahirPenghuni.setText(o[3].toString());

                DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
                dcTanggalLahirPenghuni.setDate(dateFormat.parse(o[4].toString()));
                cbGender.setSelectedItem(o[5]);
                tfEmail.setText(o[8].toString());
                tfNomorKTP.setText(o[6].toString());
                tfNomorTelp.setText(o[7].toString());
                tfPekerjaan.setText(o[9].toString());
                tfAlamatPekerjaan.setText(o[10].toString());
                tfNomorTelpPekerjaan.setText(o[11].toString());
                tfPasFoto.setText(o[12].toString());
                tfPasKTP.setText(o[13].toString());

                String fotowajah = o[12].toString();
                String fotoktp = o[13].toString();

                //================== tambah foto ================== 
                try {
                    Toolkit toolkit = Toolkit.getDefaultToolkit();

                    String path = new File(".").getCanonicalPath();

                    Rectangle rect2 = pnlFoto.getBounds();
                    Image image = toolkit.getImage(path + "/image/" + fotowajah);
                    Image imagedResized = image.getScaledInstance(rect2.width, rect2.height,
                            Image.SCALE_DEFAULT);
                    ImageIcon icon = new ImageIcon(imagedResized);
                    pnlFoto.setBackgroundImage(icon);

                    Rectangle rect3 = pnlKTP.getBounds();
                    Image image1 = toolkit.getImage(path + "/image/" + fotoktp);
                    Image imagedResized1 = image1.getScaledInstance(rect3.width, rect3.height,
                            Image.SCALE_DEFAULT);
                    ImageIcon icon1 = new ImageIcon(imagedResized1);
                    pnlKTP.setBackgroundImage(icon1);

                } catch (IOException ex) {
                    Logger.getLogger(frm_detail_penghuni.class.getName()).log(Level.SEVERE, null, ex);
                }
                //================================================= 

                KunciField(true);
            }
        } catch (SQLException e) {
            System.out.println(e.getMessage());
        } catch (ParseException ex) {
            Logger.getLogger(frm_Penghuni.class.getName()).log(Level.SEVERE, null, ex);
        }

    }
}

From source file:Forms.frm_Penghuni.java

private void btnDetailActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDetailActionPerformed
    // TODO add your handling code here:
    if (tblPenghuni.getSelectedRowCount() == 1) {
        int baris = tblPenghuni.getSelectedRow();
        String id_penyewa = tblPenghuni.getValueAt(baris, 0).toString();
        try {/*w w w . j a  v a  2 s  . co  m*/
            String sql = "Select *from penyewa where id_penyewa = " + id_penyewa + ";";
            stt = con.createStatement();
            rss = stt.executeQuery(sql);
            while (rss.next()) {
                Object[] o = new Object[15];
                o[0] = rss.getString("id_penyewa");
                o[1] = rss.getString("nama");
                o[2] = rss.getString("alamat");
                o[3] = rss.getString("tempat_lahir");
                o[4] = rss.getDate("tgl_lahir");
                o[5] = rss.getString("jk");
                o[6] = rss.getString("email");
                o[7] = rss.getString("noktp");
                o[8] = rss.getString("nohp");
                o[9] = rss.getString("pekerjaan");
                o[10] = rss.getString("alamat_kerja");
                o[11] = rss.getString("notelp_kerja");
                o[12] = rss.getString("foto_wajah");
                o[13] = rss.getString("foto_ktp");
                o[14] = rss.getString("tgl_terdaftar");

                frm_detail_penghuni detail = new frm_detail_penghuni();
                String nama = o[1].toString();
                String alamat = o[2].toString();
                String tmptLahir = o[3].toString();
                String tglLahir = o[4].toString();
                String Gender = o[5].toString();
                String email = o[6].toString();
                String noKTP = o[7].toString();
                String noTelp = o[8].toString();
                String pekerjaan = o[9].toString();
                String almtPekerjaan = o[10].toString();
                String telpPek = o[11].toString();
                //                String tglMasuk = o[12].toString();
                String fotowajah = o[12].toString();
                String fotoktp = o[13].toString();
                String tgl_daftar = o[14].toString();
                //                frm_detail_penghuni.pnlDetPasFoto.setText(this.o[1].toString());
                //                frm_detail_penghuni.pnlDetPasKTP.setText(this.o[1].toString());

                frm_detail_penghuni.tfDetNama.setText(nama);
                frm_detail_penghuni.tfDetAlamat.setText(alamat);
                frm_detail_penghuni.tfDetTmptLahir.setText(tmptLahir);
                frm_detail_penghuni.tfDetTglLahir.setText(tglLahir);
                frm_detail_penghuni.tfDetGender.setText(Gender);
                frm_detail_penghuni.tfDetEmail.setText(email);
                frm_detail_penghuni.tfDetNomorKTP.setText(noKTP);
                frm_detail_penghuni.tfDetNomorTelp.setText(noTelp);
                frm_detail_penghuni.tfDetPekerjaan.setText(pekerjaan);
                frm_detail_penghuni.tfDetAlamatPekerjaan.setText(almtPekerjaan);
                frm_detail_penghuni.tfDetTelpPekerjaan.setText(telpPek);
                frm_detail_penghuni.tfDetTglMasuk.setText(tgl_daftar);

                try {
                    Toolkit toolkit = Toolkit.getDefaultToolkit();

                    String path = new File(".").getCanonicalPath();

                    Rectangle rect2 = frm_detail_penghuni.pnlDetPasFoto.getBounds();
                    Image image = toolkit.getImage(path + "/image/" + fotowajah);
                    Image imagedResized = image.getScaledInstance(rect2.width, rect2.height,
                            Image.SCALE_DEFAULT);
                    ImageIcon icon = new ImageIcon(imagedResized);
                    frm_detail_penghuni.pnlDetPasFoto.setBackgroundImage(icon);

                    Rectangle rect3 = frm_detail_penghuni.pnlDetPasKTP.getBounds();
                    Image image1 = toolkit.getImage(path + "/image/" + fotoktp);
                    Image imagedResized1 = image1.getScaledInstance(rect3.width, rect3.height,
                            Image.SCALE_DEFAULT);
                    ImageIcon icon1 = new ImageIcon(imagedResized1);
                    frm_detail_penghuni.pnlDetPasKTP.setBackgroundImage(icon1);

                } catch (IOException ex) {
                    Logger.getLogger(frm_detail_penghuni.class.getName()).log(Level.SEVERE, null, ex);
                }
                detail.setVisible(true);
            }
        } catch (SQLException e) {
            System.out.println(e.getMessage());
        }

    } else {
        JOptionPane.showMessageDialog(null, "Silahkan Pilih Pengguna Terlebih Dahulu!..");
    }
}