Example usage for javax.swing JFrame setIconImage

List of usage examples for javax.swing JFrame setIconImage

Introduction

In this page you can find the example usage for javax.swing JFrame setIconImage.

Prototype

public void setIconImage(Image image) 

Source Link

Usage

From source file:com.jidesoft.spring.richclient.docking.JideApplicationWindow.java

/**
  * Overrides the applyStandardLayout by removing the 
  * setting of the layout manager and the insertion of
  * the center part of the frame. The JIDE docking framework
  * actually sets these, via the DefaultDockableHolder.
  *//*from   w w  w. j  ava 2s. co  m*/
@Override
protected void applyStandardLayout(JFrame windowControl, ApplicationWindowConfigurer configurer) {
    this.logger.info("Applying standard layout");
    windowControl.setTitle(configurer.getTitle());
    windowControl.setIconImage(configurer.getImage());
    windowControl.setJMenuBar(createMenuBarControl());
    windowControl.getContentPane().add(createToolBarControl(), BorderLayout.NORTH);
    //windowControl.getContentPane().add(createStatusBarControl(), BorderLayout.SOUTH);
}

From source file:freemrs.ChartPanelDraw.java

public ChartPanelDraw(java.util.List<Vitals> result, String type) {
    this.type = type;
    this.result = result;
    dataset = createTimeDataset();/*from   w  w  w  .  ja va  2s .com*/
    chartPanel = createChart(dataset, type);

    JFrame f = new JFrame("Vital Plot"); //Jframe to draw the graph
    f.setTitle("Vital Plot");
    f.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
    f.setLayout(new BorderLayout(0, 5));
    f.add(chartPanel, BorderLayout.CENTER);
    f.setIconImage(new ImageIcon(getClass().getResource("/images/icon_transparent.png")).getImage());

    chartPanel.setHorizontalAxisTrace(true); //set properties of the graph 
    chartPanel.setVerticalAxisTrace(true);
    chartPanel.setMouseWheelEnabled(true);

    JPanel panel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    panel.add(createTrace()); //Add components to panel
    panel.add(createDate());
    panel.add(createZoom());
    f.add(panel, BorderLayout.SOUTH);
    f.pack();
    f.setLocationRelativeTo(null);
    f.setVisible(true);
}

From source file:EHRAppointment.ChartPanelDraw.java

/**
 *
 * @param result//from www  . ja va2  s . co  m
 * @param type
 */
public ChartPanelDraw(java.util.List<Vitals> result, String type) {
    this.type = type;
    this.result = result;
    dataset = createTimeDataset();
    chartPanel = createChart(dataset, type);

    JFrame f = new JFrame("Vital Plot"); //Jframe to draw the graph
    f.setTitle("Vital Plot");
    f.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
    f.setLayout(new BorderLayout(0, 5));
    f.add(chartPanel, BorderLayout.CENTER);
    f.setIconImage(new ImageIcon(getClass().getResource("/images/icon_transparent.png")).getImage());

    chartPanel.setHorizontalAxisTrace(true); //set properties of the graph 
    chartPanel.setVerticalAxisTrace(true);
    chartPanel.setMouseWheelEnabled(true);

    JPanel panel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    panel.add(createTrace()); //Add components to panel
    panel.add(createDate());
    panel.add(createZoom());
    f.add(panel, BorderLayout.SOUTH);
    f.pack();
    f.setLocationRelativeTo(null);
    f.setVisible(true);
}

From source file:LineChart.java

public LineChart(JTable table) {
    final JFrame frame = new JFrame("jshow Chart");

    final JFreeChart chart = createDataset(table);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    chartPanel.setMouseZoomable(true, false);
    frame.setContentPane(chartPanel);//  w  ww  .jav  a 2  s . c om

    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    frame.setIconImage(Toolkit.getDefaultToolkit()
            .createImage(LineChart.class.getResource("de/skelton/images/chart.png")));

    frame.pack();
    frame.setVisible(true);
    frame.requestFocus();
    frame.toFront();
}

From source file:llc.rockford.webcast.EC2Driver.java

private void createAndShowGUI() {
    // Set the look and feel.
    initLookAndFeel();/*w  ww  .j  av a2  s .com*/

    // Make sure we have nice window decorations.
    JFrame.setDefaultLookAndFeelDecorated(true);

    // Create and set up the window.
    JFrame frame = new JFrame("Webcast Utility");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setPreferredSize(new Dimension(300, 400));
    java.net.URL url = ClassLoader.getSystemResource("llc/rockford/webcast/resources/internet.png");
    Toolkit kit = Toolkit.getDefaultToolkit();
    Image img = kit.createImage(url);
    frame.setIconImage(img);
    Component contents = createComponents();
    frame.getContentPane().add(contents, BorderLayout.CENTER);

    // Display the window.
    frame.pack();
    frame.setVisible(true);

}

From source file:is.iclt.jcorpald.CorpaldView.java

public void createAndShowGUI() {
    CorpaldSettings settings = CorpaldSettings.getInstance();

    //Create and set up the window.
    JFrame frame = new JFrame(settings.getProperty("corpus.acronym") + " "
            + settings.getProperty("corpus.version") + " - " + settings.getProperty("corpus.longname"));
    frame.setIconImage((new ImageIcon("icons/corpald.png")).getImage());

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    // frame.setBounds(50, 50, 700, 450);
    frame.setPreferredSize(new Dimension(750, 720));

    // Create the panel that has the query and the result        
    JPanel panMainArea = new JPanel(new BorderLayout());
    JPanel panQuery = new JPanel(new BorderLayout());

    txtQuery = new JHighlightPane();
    txtQuery.addKeyListener(this);

    txtQuery.setFont(new Font("Monospaced", Font.BOLD, 16));
    this.updateHighlighting();
    txtQuery.setPreferredSize(new Dimension(700, 150));

    panQuery.add(labQuery, BorderLayout.NORTH);
    panQuery.add(new JScrollPane(txtQuery, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS), BorderLayout.CENTER);
    panQuery.setBorder(new EmptyBorder(0, 10, 10, 10));

    String welcomeMessage = "";
    try {//  w  ww .j  a va  2  s .c  om
        welcomeMessage = FileUtils.readFileToString(new File(settings.getProperty("corpus.welcome")), "utf-8");
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    JPanel panResult = new JPanel(new BorderLayout());
    txtResult = new JTextArea(welcomeMessage);

    txtResult.setEditable(false);
    txtResult.setFont(new Font("Monospaced", Font.BOLD, 14));

    JScrollPane scrResult = new JScrollPane(txtResult, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    scrResult.setPreferredSize(new Dimension(700, 400));
    panResult.add(new JLabel("Result:"), BorderLayout.NORTH);
    panResult.add(scrResult, BorderLayout.CENTER);
    panResult.setBorder(new EmptyBorder(0, 10, 0, 10));

    panMainArea.add(panQuery, BorderLayout.NORTH);
    panMainArea.add(panResult, BorderLayout.CENTER);

    // Create panel at top with buttons
    JPanel panToolbar = new JPanel(new FlowLayout(FlowLayout.CENTER));

    // New, Open, Save
    // New
    ImageIcon icoNewQuery = new ImageIcon("icons/page_white.png");
    butNewQuery = new JButton(icoNewQuery);
    butNewQuery.addActionListener(this);
    butNewQuery.setPreferredSize(new Dimension(26, 26));
    butNewQuery.setToolTipText("Create a new empty query");
    panToolbar.add(butNewQuery);
    // Open
    ImageIcon icoOpenQuery = new ImageIcon("icons/folder.png");
    butOpenQuery = new JButton(icoOpenQuery);
    butOpenQuery.addActionListener(this);
    butOpenQuery.setPreferredSize(new Dimension(26, 26));
    butOpenQuery.setToolTipText("Open a query file");
    panToolbar.add(butOpenQuery);
    // Save
    ImageIcon icoSaveQuery = new ImageIcon("icons/page_save.png");
    butSaveQuery = new JButton(icoSaveQuery);
    butSaveQuery.addActionListener(this);
    butSaveQuery.setPreferredSize(new Dimension(26, 26));
    butSaveQuery.setToolTipText("Save current query");
    panToolbar.add(butSaveQuery);
    // Save as
    ImageIcon icoSaveQueryAs = new ImageIcon("icons/page_save_as.png");
    butSaveQueryAs = new JButton(icoSaveQueryAs);
    butSaveQueryAs.addActionListener(this);
    butSaveQueryAs.setPreferredSize(new Dimension(26, 26));
    butSaveQueryAs.setToolTipText("Save current query under a new file name");
    panToolbar.add(butSaveQueryAs);

    // Open definitions file
    ImageIcon icoOpenDef = new ImageIcon("icons/folder_table.png");
    butOpenDef = new JButton(icoOpenDef);
    butOpenDef.addActionListener(this);
    butOpenDef.setPreferredSize(new Dimension(26, 26));
    butOpenDef.setToolTipText("Select a new definitions file");
    panToolbar.add(butOpenDef);

    // Run Query button
    ImageIcon icoRunQuery = new ImageIcon("icons/control_play_blue.png");
    butRunQuery = new JButton("Run Query", icoRunQuery);
    butRunQuery.setPreferredSize(new Dimension(130, 26));
    butRunQuery.addActionListener(this);
    butRunQuery.setToolTipText("Run the current query using CorpusSearch");
    panToolbar.add(butRunQuery);

    // TextField for root node label
    JLabel labRootNode = new JLabel("Root:");
    panToolbar.add(labRootNode);
    txtRootNode = new JTextField("", 12);
    txtRootNode.setPreferredSize(new Dimension(50, 26));
    txtRootNode.addKeyListener(this);
    txtRootNode.setMargin(new Insets(3, 3, 3, 3));
    txtRootNode.setToolTipText("<html>Search within instances of a particular type of node,<br/>"
            + "such as IP-*, IP-SUB, NP-*, etc. $ROOT matches<br/>"
            + "the root node of every tree in the corpus.</html>");
    panToolbar.add(txtRootNode);

    chkNodesOnly = new JCheckBox("Nodes only");
    chkNodesOnly.addItemListener(this);
    chkNodesOnly.setToolTipText("<html>If checked, CorpusSearch prints out only the nodes that<br/>"
            + "contain the structure described in \"Query\". If not checked,<br/>"
            + "CorpusSearch prints out the entire sentence that contains the<br/>"
            + "structure described in \"Query\".</html>");
    panToolbar.add(chkNodesOnly);

    chkRemoveNodes = new JCheckBox("Remove nodes");
    chkRemoveNodes.addItemListener(this);
    chkRemoveNodes.setToolTipText("<html>Remove subtrees whose root is of the same syntactic category<br/>"
            + "as the node boundary embedded within a instance of that node<br/>"
            + "boundary. \"Remove nodes\" thus removes recursive structure.</html>");
    panToolbar.add(chkRemoveNodes);

    // Create panel at top with buttons
    JPanel panBottombar = new JPanel(new FlowLayout(FlowLayout.CENTER));
    // panBottombar.setBorder(new EmptyBorder(0, 0, 10, 5));
    ImageIcon icoOpenFolder = new ImageIcon("icons/folder.png");
    butOpenFolder = new JButton("Show result in folder", icoOpenFolder);
    butOpenFolder.setEnabled(false);
    butOpenFolder.addActionListener(this);
    panBottombar.add(butOpenFolder);

    ImageIcon icoTextEditor = new ImageIcon("icons/page_white_go.png");
    butTextEditor = new JButton("Open result in text editor", icoTextEditor);
    butTextEditor.setEnabled(false);
    butTextEditor.addActionListener(this);
    panBottombar.add(butTextEditor);

    ImageIcon icoCopyResults = new ImageIcon("icons/page_copy.png");
    butCopyResults = new JButton("Copy result to clipboard", icoCopyResults);
    butCopyResults.setEnabled(false);
    butCopyResults.addActionListener(this);
    panBottombar.add(butCopyResults);

    // Add stuff to top level content pane                
    frame.getContentPane().setLayout(new BorderLayout());
    frame.getContentPane().add(panToolbar, BorderLayout.NORTH);
    frame.getContentPane().add(panMainArea, BorderLayout.CENTER);
    frame.getContentPane().add(panBottombar, BorderLayout.SOUTH);

    this.configureFileFilters();

    //Display the window.
    frame.pack();
    frame.setVisible(true);
}

From source file:edu.ku.brc.specify.BackupAndRestoreApp.java

/**
 * Tries to do the login, if doAutoLogin is set to true it will try without displaying a dialog
 * and if the login fails then it will display the dialog
 * @param userName single signon username (for application)
 * @param password single signon password (for application)
 * @param usrPwdProvider the provider//from w  w w .  ja  v a2 s.  c  o  m
 * @param engageUPPrefs indicates whether the username and password should be loaded and remembered by local prefs
 * @param doAutoLogin whether to try to automatically log the user in
 * @param doAutoClose whether it should automatically close the window when it is logged in successfully
 * @param useDialog use a Dialog or a Frame
 * @param listener a listener for when it is logged in or fails
 * @param iconName name of icon to use
 * @param title name
 * @param appName name
 * @param appIconName application icon name
 * @param helpContext help context for Help button on dialog
 */
public static DatabaseLoginPanel doLogin(final boolean engageUPPrefs,
        final MasterPasswordProviderIFace usrPwdProvider, final boolean doAutoClose,
        final DatabaseLoginListener listener, final String iconName, final String title, final String appName,
        final String appIconName, final String helpContext) //frame's icon name
{

    ImageIcon icon = IconManager.getIcon("AppIcon", IconManager.IconSize.Std32);
    if (StringUtils.isNotEmpty(appIconName)) {
        ImageIcon imgIcon = IconManager.getIcon(appIconName);
        if (imgIcon != null) {
            icon = imgIcon;
        }
    }

    // else
    class DBListener implements DatabaseLoginListener {
        protected JFrame frame;
        protected DatabaseLoginListener frameDBListener;
        protected boolean doAutoCloseOfListener;

        public DBListener(JFrame frame, DatabaseLoginListener frameDBListener, boolean doAutoCloseOfListener) {
            this.frame = frame;
            this.frameDBListener = frameDBListener;
            this.doAutoCloseOfListener = doAutoCloseOfListener;
        }

        public void loggedIn(final Window window, final String databaseName, final String userNameArg) {
            log.debug("UIHelper.doLogin[DBListener]");
            if (doAutoCloseOfListener) {
                frame.setVisible(false);
            }
            frameDBListener.loggedIn(window, databaseName, userNameArg);
        }

        public void cancelled() {
            frame.setVisible(false);
            frameDBListener.cancelled();
        }
    }
    JFrame.setDefaultLookAndFeelDecorated(false);

    JFrame frame = new JFrame(title);
    DatabaseLoginPanel panel = new DatabaseLoginPanel(null, null, false, usrPwdProvider,
            new DBListener(frame, listener, doAutoClose), false, false, title, appName, iconName, helpContext);

    panel.setAutoClose(doAutoClose);
    panel.setWindow(frame);
    frame.setContentPane(panel);
    frame.setIconImage(icon.getImage());
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    frame.pack();

    UIHelper.centerAndShow(frame);

    return panel;
}

From source file:es.emergya.ui.plugins.admin.aux1.SummaryAction.java

private JFrame createJDialog(final String titulo) {
    final JFrame d = new JFrame(titulo);
    d.setResizable(false);/*  www. j  av a2s.c  o  m*/
    d.setAlwaysOnTop(true);
    d.setIconImage(window.getIconImage());
    d.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    d.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            super.windowClosing(e);
            if (cambios) {
                int res = JOptionPane.showConfirmDialog(d,
                        "Existen cambios sin guardar. Seguro que desea cerrar la ventana?",
                        "Cambios sin guardar", JOptionPane.OK_CANCEL_OPTION);
                if (res != JOptionPane.CANCEL_OPTION) {
                    e.getWindow().dispose();
                }
            } else {
                e.getWindow().dispose();
            }
        }
    });
    d.setLayout(new BorderLayout(5, 5));
    d.setBackground(Color.WHITE);
    d.getContentPane().setBackground(Color.WHITE);
    return d;
}

From source file:components.FrameDemo2.java

public void showNewWindow() {
    JFrame frame = new MyFrame();

    //Take care of the no window decorations case.
    //NOTE: Unless you really need the functionality
    //provided by JFrame, you would usually use a
    //Window or JWindow instead of an undecorated JFrame.
    if (noDecorations) {
        frame.setUndecorated(true);/*  w  w  w .j a  va 2s.  co  m*/
    }

    //Set window location.
    if (lastLocation != null) {
        //Move the window over and down 40 pixels.
        lastLocation.translate(40, 40);
        if ((lastLocation.x > maxX) || (lastLocation.y > maxY)) {
            lastLocation.setLocation(0, 0);
        }
        frame.setLocation(lastLocation);
    } else {
        lastLocation = frame.getLocation();
    }

    //Calling setIconImage sets the icon displayed when the window
    //is minimized.  Most window systems (or look and feels, if
    //decorations are provided by the look and feel) also use this
    //icon in the window decorations.
    if (specifyIcon) {
        if (createIcon) {
            frame.setIconImage(createFDImage()); //create an icon from scratch
        } else {
            frame.setIconImage(getFDImage()); //get the icon from a file
        }
    }

    //Show window.
    frame.setSize(new Dimension(170, 100));
    frame.setVisible(true);
}

From source file:FrameDemo2.java

public void showNewWindow() {
    JFrame frame = new MyFrame();

    // Take care of the no window decorations case.
    // NOTE: Unless you really need the functionality
    // provided by JFrame, you would usually use a
    // Window or JWindow instead of an undecorated JFrame.
    if (noDecorations) {
        frame.setUndecorated(true);//from   w ww  .j a v a 2  s.c o m
    }

    // Set window location.
    if (lastLocation != null) {
        // Move the window over and down 40 pixels.
        lastLocation.translate(40, 40);
        if ((lastLocation.x > maxX) || (lastLocation.y > maxY)) {
            lastLocation.setLocation(0, 0);
        }
        frame.setLocation(lastLocation);
    } else {
        lastLocation = frame.getLocation();
    }

    // Calling setIconImage sets the icon displayed when the window
    // is minimized. Most window systems (or look and feels, if
    // decorations are provided by the look and feel) also use this
    // icon in the window decorations.
    if (specifyIcon) {
        if (createIcon) {
            frame.setIconImage(createFDImage()); // create an icon from scratch
        } else {
            frame.setIconImage(getFDImage()); // get the icon from a file
        }
    }

    // Show window.
    frame.setSize(new Dimension(170, 100));
    frame.setVisible(true);
}