Search Results

Search found 9 results on 1 pages for 'seticonimage'.

Page 1/1 | 1 

  • Java Folder Location for Image NetBeans 6.8

    - by ikurtz
    greetings, today i have started to learn java using netbeans ide. i would like my jframe to display an icon as stated in the following: setIconImage(Toolkit.getDefaultToolkit().getImage("SartreIcon.jpg")); the questin is under netbeans ide.. exactly in which folder do i place the graphic in question in order to load it? thanks.

    Read the article

  • Set Icon Image problem in Jar file

    - by Mr CooL
    The following code works when running the NetBeans IDE. this.getFrame().setIconImage(Toolkit.getDefaultToolkit().getImage("PlagiaLyzerIcon.png")); However, once it was built into Jar file, the icon was gone. Anyone has idea what's the problem? I realized I've to put the icon image on the root directory, however, after compiling into JAR, the icon gone. Thanks for any help..

    Read the article

  • Having difficulty add a custom icon to a JFrame

    - by Oliver
    Hi, I have been trying to change the icon in the frame. I have virtually tried everything: The icon is 16x16 which is the right size ....doesn't work I've trying PNG,GIF and JPG formats none of them work. Tried different way of setting the icon....doesn't work. I've tried relative (local paths) e.g. "icon.gif" and absolute paths e.g. "c:\work\java\icon.gif" ...doesn't work Here is my code and see if you can figure it out Thanks Oli import javax.swing.*; public class androidDriver { public static void main(String[] args) throws IOException { JFrame f = new JFrame("Android Data Viewer"); f.setResizable(false); f.setSize(300,300); f.setLocationRelativeTo(null); f.setVisible(true); f.setIconImage(new ImageIcon("androidIcon2.gif").getImage()); } }

    Read the article

  • Java applet icon doesn't show

    - by user295744
    I have a java applet where I've changed the image icon that appears in the top left corner of the window. The code I use is this: Toolkit kit = Toolkit.getDefaultToolkit(); Image frameIcon = kit.getImage("src/myapp/resources/logo.png"); getFrame().setIconImage(frameIcon); Everything works fine until I deploy the applet to a standalone jar. In this case the icon that shows is the default icon, as if the code couldn't find the image. But the image is inside, although it is in the folder: myapp/resources/ What am I doing wrong here? Is this some weird java bug?

    Read the article

  • Malformed Farsi characters on AWT

    - by jlover2010
    Hi As i started programming by jdk6, i had no problem in text components neither in awt nor in swing. But for labels or titles of awt components, yes : I couldn't have Farsi characters displayable on AWTs just as simple as Swing by typing them into the source code. lets check this SSCCE : import javax.swing.*; import java.awt.*; import java.io.*; import java.util.Properties; public class EmptyFarsiCharsOnAWT extends JFrame{ public EmptyFarsiCharsOnAWT() { super("????"); setDefaultCloseOperation(3); setVisible(rootPaneCheckingEnabled); } public static void main(String[] args) throws AWTException, IOException { JFrame jFrame = new EmptyFarsiCharsOnAWT(); MenuItem show ; // approach 1 = HardCoding : /* show = new MenuItem("\u0646\u0645\u0627\u06cc\u0634"); * */ // approach 2 = using simple utf-8 saved text file : /* BufferedReader in = new BufferedReader(new FileReader("farsiLabels.txt")); String showLabel = in.readLine(); in.close(); show = new MenuItem(showLabel); * */ // approach 3 = using properties file : FileReader in = new FileReader("farsiLabels.properties"); Properties farsiLabels = new Properties(); farsiLabels.load(in); show = new MenuItem(farsiLabels.getProperty("tray.show")); PopupMenu popUp = new PopupMenu(); popUp.add(show); // creating Tray object Image iconIamge = Toolkit.getDefaultToolkit().getImage("greenIcon.png"); TrayIcon trayIcon = new TrayIcon(iconIamge, null, popUp); SystemTray tray = SystemTray.getSystemTray(); tray.add(trayIcon); jFrame.setIconImage(iconIamge); } } Yes, i know each of three approaches in source code does right when you may test it from IDE , but if you make a JAR contains just this class, by means of NetBeans project clean&build ,you won't see the expected characters and will just get EMPTY/BLANK SQUARES ! Unfortunately, opposed to other situations i encountered before, here there is no way to avoid using awt and make use of Swing in this case. And this was just an SSCCE i made to show the problem and my recent (also first) application suffers from this subject. Note: it seems i can not attach anything, so the contents od the text file would be this: ????? and the contents of properties file: #Sun May 02 09:45:10 IRDT 2010 tray.show=????? but i don't think by giving you the unicode-scape sequence, these would be necessary any way... And i think should have to let you know I posted this question a while ago in SDN and "the Java Ranch" forums and other native forums and still I'm watching... By the way i am using latest version of Netbeans IDE... I will be so grateful if anybody has a solution to this damn AWT components never rendered any Farsi character for me... Thanks in advance

    Read the article

  • mulformed Farsi characters on AWT

    - by jlover2010
    Hi As i started programming by jdk6, i had no problem in text components neither in awt nor in swing. But for labels or titles of awt components, yes : I couldn't have Farsi characters displayable on AWTs just as simple as Swing by typing them into the source code. lets check this SSCCE : import javax.swing.*; import java.awt.*; import java.io.*; import java.util.Properties; public class EmptyFarsiCharsOnAWT extends JFrame{ public EmptyFarsiCharsOnAWT() { super("????"); setDefaultCloseOperation(3); setVisible(rootPaneCheckingEnabled); } public static void main(String[] args) throws AWTException, IOException { JFrame jFrame = new EmptyFarsiCharsOnAWT(); MenuItem show ; // approach 1 = HardCoding : /* show = new MenuItem("\u0646\u0645\u0627\u06cc\u0634"); * */ // approach 2 = using simple utf-8 saved text file : /* BufferedReader in = new BufferedReader(new FileReader("farsiLabels.txt")); String showLabel = in.readLine(); in.close(); show = new MenuItem(showLabel); * */ // approach 3 = using properties file : FileReader in = new FileReader("farsiLabels.properties"); Properties farsiLabels = new Properties(); farsiLabels.load(in); show = new MenuItem(farsiLabels.getProperty("tray.show")); PopupMenu popUp = new PopupMenu(); popUp.add(show); // creating Tray object Image iconIamge = Toolkit.getDefaultToolkit().getImage("greenIcon.png"); TrayIcon trayIcon = new TrayIcon(iconIamge, null, popUp); SystemTray tray = SystemTray.getSystemTray(); tray.add(trayIcon); jFrame.setIconImage(iconIamge); } } Yes, i know each of three approaches in source code does right when you may test it from IDE , but if you make a JAR contains just this class (and its resources) by means of NetBeans project clean&build ,you won't see the expected characters and will just get EMPTY/BLANK SQUARES ! Unfortunately, opposed to other situations i encountered before, here there is no way to avoid using awt and make use of Swing in this case. And this was just an SSCCE i made to show the problem and my recent (also first) application suffers from this subject. And i think should have to let you know I posted this question a while ago in SDN and "the Java Ranch" forums and other native forums and still I'm watching... By the way i am using latest version of Netbeans IDE... I will be so grateful if anybody has a solution to this damn AWT components never rendered any Farsi character for me... Thanks in advance

    Read the article

  • How can I set an image for background of GUI interface?

    - by enriched
    hey everyone, im having some troubles displaying the background image for a GUI interface in java. Here is what i have at the moment, and with current stage of code it shows default(gray) background. import javax.swing.*; import java.awt.event.*; import java.util.Scanner; import java.awt.*; import java.io.File; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.IOException; ////////////////////////////////// // 3nriched Games Presents: // // MIPS The Mouse!! // ////////////////////////////////// public class mipsMouseGUI extends JFrame implements ActionListener { private static String ThePDub = ("mouse"); //the password JPasswordField pass; JPanel panel; JButton btnEnter; JLabel lblpdub; public mipsMouseGUI() { BufferedImage image = null; try { //attempts to read picture from the folder image = ImageIO.read(getClass().getResource("/mousepics/mousepic.png")); } catch (IOException e) { //catches exceptions e.printStackTrace(); } ImagePanel panel = new ImagePanel(new ImageIcon("/mousepics/neonglowOnwill.png").getImage()); setIconImage(image); //sets icon picture setTitle("Mips The Mouse Login"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); pass = new JPasswordField(5); //sets password length to 5 pass.setEchoChar('@'); //hide characters as @ symbol pass.addActionListener(this); //adds action listener add(panel); //adds panel to frame btnEnter = new JButton("Enter"); //creates a button btnEnter.addActionListener(this);// Register the action listener. lblpdub = new JLabel(" Your Password: "); // label that says enter password panel.add(lblpdub, BorderLayout.CENTER);// adds label and inputbox panel.add(pass, BorderLayout.CENTER); // to panel and sets location panel.add(btnEnter, BorderLayout.CENTER); //adds button to panel pack(); // packs controls and setLocationRelativeTo(null); // Implicit "this" if inside JFrame constructor. setVisible(true);// makes them visible (duh) } public void actionPerformed(ActionEvent a) { Object source = a.getSource(); //char array that holds password char[] passy = pass.getPassword(); //characters array to string String p = new String(passy); //determines if user entered correct password if(p.equals(ThePDub)) { JOptionPane.showMessageDialog(null, "Welcome beta user: USERNAME."); } else JOptionPane.showMessageDialog(null, "You have enter an incorrect password. Please try again."); } public class ImagePanel extends JPanel { private BufferedImage img; public ImagePanel(String img) { this(new ImageIcon(img).getImage()); } public ImagePanel(Image img) { Dimension size = new Dimension(img.getWidth(null), img.getHeight(null)); } public void paintComponent(Graphics g) { g.drawImage(img, 0, 0, null); } } }

    Read the article

  • Java JTextPane JScrollPane Display Issue

    - by ikurtz
    The following class implements a chatGUI. When it runs okay the screen looks like this: Fine ChatGUI The problem is very often when i enter text of large length ie. 50 - 100 chars the gui goes crazy. the chat history box shrinks as shown in this image. Any ideas regarding what is causing this? Thank you. package Sartre.Connect4; import javax.swing.*; import java.net.*; import java.awt.*; import java.awt.event.*; import javax.swing.text.StyledDocument; import javax.swing.text.Style; import javax.swing.text.StyleConstants; import javax.swing.text.BadLocationException; import java.io.BufferedOutputStream; import javax.swing.text.html.HTMLEditorKit; import java.io.FileOutputStream; import java.io.IOException; import java.io.FileNotFoundException; import javax.swing.filechooser.FileNameExtensionFilter; import javax.swing.JFileChooser; /** * Chat form class * @author iAmjad */ public class ChatGUI extends JDialog implements ActionListener { /** * Used to hold chat history data */ private JTextPane textPaneHistory = new JTextPane(); /** * provides scrolling to chat history pane */ private JScrollPane scrollPaneHistory = new JScrollPane(textPaneHistory); /** * used to input local message to chat history */ private JTextPane textPaneHome = new JTextPane(); /** * Provides scrolling to local chat pane */ private JScrollPane scrollPaneHomeText = new JScrollPane(textPaneHome); /** * JLabel acting as a statusbar */ private JLabel statusBar = new JLabel("Ready"); /** * Button to clear chat history pane */ private JButton JBClear = new JButton("Clear"); /** * Button to save chat history pane */ private JButton JBSave = new JButton("Save"); /** * Holds contentPane */ private Container containerPane; /** * Layout GridBagLayout manager */ private GridBagLayout gridBagLayout = new GridBagLayout(); /** * GridBagConstraints */ private GridBagConstraints constraints = new GridBagConstraints(); /** * Constructor for ChatGUI */ public ChatGUI(){ setTitle("Chat"); // set up dialog icon URL url = getClass().getResource("Resources/SartreIcon.jpg"); ImageIcon imageIcon = new ImageIcon(url); Image image = imageIcon.getImage(); this.setIconImage(image); this.setAlwaysOnTop(true); setLocationRelativeTo(this.getParent()); //////////////// End icon and placement ///////////////////////// // Get pane and set layout manager containerPane = getContentPane(); containerPane.setLayout(gridBagLayout); ///////////////////////////////////////////////////////////// //////////////// Begin Chat History ////////////////////////////// textPaneHistory.setToolTipText("Chat History Window"); textPaneHistory.setEditable(false); textPaneHistory.setPreferredSize(new Dimension(350,250)); scrollPaneHistory.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); scrollPaneHistory.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); // fill Chat History GridBagConstraints constraints.gridx = 0; constraints.gridy = 0; constraints.gridwidth = 10; constraints.gridheight = 10; constraints.weightx = 100; constraints.weighty = 100; constraints.fill = GridBagConstraints.BOTH; constraints.anchor = GridBagConstraints.CENTER; constraints.insets = new Insets(10,10,10,10); constraints.ipadx = 0; constraints.ipady = 0; gridBagLayout.setConstraints(scrollPaneHistory, constraints); // add to the pane containerPane.add(scrollPaneHistory); /////////////////////////////// End Chat History /////////////////////// ///////////////////////// Begin Home Chat ////////////////////////////// textPaneHome.setToolTipText("Home Chat Message Window"); textPaneHome.setPreferredSize(new Dimension(200,50)); textPaneHome.addKeyListener(new MyKeyAdapter()); scrollPaneHomeText.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); scrollPaneHomeText.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); // fill Chat History GridBagConstraints constraints.gridx = 0; constraints.gridy = 10; constraints.gridwidth = 6; constraints.gridheight = 1; constraints.weightx = 100; constraints.weighty = 100; constraints.fill = GridBagConstraints.BOTH; constraints.anchor = GridBagConstraints.CENTER; constraints.insets = new Insets(10,10,10,10); constraints.ipadx = 0; constraints.ipady = 0; gridBagLayout.setConstraints(scrollPaneHomeText, constraints); // add to the pane containerPane.add(scrollPaneHomeText); ////////////////////////// End Home Chat ///////////////////////// ///////////////////////Begin Clear Chat History //////////////////////// JBClear.setToolTipText("Clear Chat History"); // fill Chat History GridBagConstraints constraints.gridx = 6; constraints.gridy = 10; constraints.gridwidth = 2; constraints.gridheight = 1; constraints.weightx = 100; constraints.weighty = 100; constraints.fill = GridBagConstraints.BOTH; constraints.anchor = GridBagConstraints.CENTER; constraints.insets = new Insets(10,10,10,10); constraints.ipadx = 0; constraints.ipady = 0; gridBagLayout.setConstraints(JBClear, constraints); JBClear.addActionListener(this); // add to the pane containerPane.add(JBClear); ///////////////// End Clear Chat History //////////////////////// /////////////// Begin Save Chat History ////////////////////////// JBSave.setToolTipText("Save Chat History"); constraints.gridx = 8; constraints.gridy = 10; constraints.gridwidth = 2; constraints.gridheight = 1; constraints.weightx = 100; constraints.weighty = 100; constraints.fill = GridBagConstraints.BOTH; constraints.anchor = GridBagConstraints.CENTER; constraints.insets = new Insets(10,10,10,10); constraints.ipadx = 0; constraints.ipady = 0; gridBagLayout.setConstraints(JBSave, constraints); JBSave.addActionListener(this); // add to the pane containerPane.add(JBSave); ///////////////////// End Save Chat History ///////////////////// /////////////////// Begin Status Bar ///////////////////////////// constraints.gridx = 0; constraints.gridy = 11; constraints.gridwidth = 10; constraints.gridheight = 1; constraints.weightx = 100; constraints.weighty = 50; constraints.fill = GridBagConstraints.BOTH; constraints.anchor = GridBagConstraints.CENTER; constraints.insets = new Insets(0,10,5,0); constraints.ipadx = 0; constraints.ipady = 0; gridBagLayout.setConstraints(statusBar, constraints); // add to the pane containerPane.add(statusBar); ////////////// End Status Bar //////////////////////////// // set resizable to false this.setResizable(false); // pack the GUI pack(); } /** * Deals with necessary menu click events * @param event */ public void actionPerformed(ActionEvent event) { Object source = event.getSource(); // Process Clear button event if (source == JBClear){ textPaneHistory.setText(null); statusBar.setText("Chat History Cleared"); } // Process Save button event if (source == JBSave){ // process only if there is data in history pane if (textPaneHistory.getText().length() > 0){ // process location where to save the chat history file JFileChooser chooser = new JFileChooser(); chooser.setMultiSelectionEnabled(false); chooser.setAcceptAllFileFilterUsed(false); FileNameExtensionFilter filter = new FileNameExtensionFilter("HTML Documents", "htm", "html"); chooser.setFileFilter(filter); int option = chooser.showSaveDialog(ChatGUI.this); if (option == JFileChooser.APPROVE_OPTION) { // Set up document to be parsed as HTML StyledDocument doc = (StyledDocument)textPaneHistory.getDocument(); HTMLEditorKit kit = new HTMLEditorKit(); BufferedOutputStream out; try { // add final file name and extension String filePath = chooser.getSelectedFile().getAbsoluteFile() + ".html"; out = new BufferedOutputStream(new FileOutputStream(filePath)); // write out the HTML document kit.write(out, doc, doc.getStartPosition().getOffset(), doc.getLength()); } catch (FileNotFoundException e) { JOptionPane.showMessageDialog(ChatGUI.this, "Application will now close. \n A restart may cure the error!\n\n" + e.getMessage(), "Fatal Error", JOptionPane.WARNING_MESSAGE, null); System.exit(2); } catch (IOException e){ JOptionPane.showMessageDialog(ChatGUI.this, "Application will now close. \n A restart may cure the error!\n\n" + e.getMessage(), "Fatal Error", JOptionPane.WARNING_MESSAGE, null); System.exit(3); } catch (BadLocationException e){ JOptionPane.showMessageDialog(ChatGUI.this, "Application will now close. \n A restart may cure the error!\n\n" + e.getMessage(), "Fatal Error", JOptionPane.WARNING_MESSAGE, null); System.exit(4); } statusBar.setText("Chat History Saved"); } } } } /** * Process return key for sending the message */ private class MyKeyAdapter extends KeyAdapter { @Override @SuppressWarnings("static-access") public void keyPressed(KeyEvent ke) { DateTime dateTime = new DateTime(); String nowdateTime = dateTime.getDateTime(); int kc = ke.getKeyCode(); if (kc == ke.VK_ENTER) { try { // Process only if there is data if (textPaneHome.getText().length() > 0){ // Add message origin formatting StyledDocument doc = (StyledDocument)textPaneHistory.getDocument(); Style style = doc.addStyle("HomeStyle", null); StyleConstants.setBold(style, true); String home = "Home [" + nowdateTime + "]: "; doc.insertString(doc.getLength(), home, style); StyleConstants.setBold(style, false); doc.insertString(doc.getLength(), textPaneHome.getText() + "\n", style); // update caret location textPaneHistory.setCaretPosition(doc.getLength()); textPaneHome.setText(null); statusBar.setText("Message Sent"); } } catch (BadLocationException e) { JOptionPane.showMessageDialog(ChatGUI.this, "Application will now close. \n A restart may cure the error!\n\n" + e.getMessage(), "Fatal Error", JOptionPane.WARNING_MESSAGE, null); System.exit(1); } ke.consume(); } } } }

    Read the article

1