How can I set a default file for JFileChooser

Hi. I am developing a p2p chat application and I have to unrelated questions.
1. How can I set a default file name for JFileChooser, to save a completly new file?
2. I have a JTextArea that I append recieved messages. But when a message is appended, the whole desktop screen refreshes. How can I prevent that?
Hope I was clear. Thanks in advance.

Thank you for the first answer, it solved my problem. Here is the code for 2nd question, I've trimmed it a lot, hope I didn't cut off any critical code
public class ConversationWindow extends JFrame implements KeyListener,MessageArrivedListener,ActionListener,IOnlineUsrComp{
     private TextArea incomingArea;
     private Conversation conversation;
     private JTextField outgoingField;
     private JScrollPane incomingTextScroller;
     private String userName;
     private JButton inviteButton;
     private JButton sendFileButton;
     private JFileChooser fileChooser;
     private FontMetrics fontMetrics;
     private HashMap<String, String> onlineUserMap;
     public void MessageArrived(MessageArrivedEvent e) {
          showMessage(e.getArrivedMessage());
     public ConversationWindow(Conversation conversation)
          this.conversation=conversation;
          userName=User.getInstance().getUserName();
          sendFileButton=new JButton("Dosya G�nder");
          sendFileButton.addActionListener(this);
          inviteButton=new JButton("Davet et");
          inviteButton.addActionListener(this);
          incomingArea=new TextArea();
          incomingArea.setEditable(false);
          incomingArea.setFont(new Font("Verdana",Font.PLAIN,12));
          fontMetrics =incomingArea.getFontMetrics(incomingArea.getFont());
          incomingArea.setPreferredSize(new Dimension(300,300));
          outgoingField=new JTextField();
          outgoingField.addKeyListener(this);
          incomingTextScroller=new JScrollPane(incomingArea);          
          JPanel panel=new JPanel();
          panel.setLayout(new BoxLayout(panel,BoxLayout.PAGE_AXIS));
          panel.add(inviteButton);
          panel.add(sendFileButton);
          panel.add(incomingTextScroller);
          panel.add(outgoingField);
          add(panel);
          pack();
          setTitle("Ki&#351;iler:");
          setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
          setLocationRelativeTo(null);
          addWindowListener(new CloseAdapter());
     //Sends the message to other end
     public void keyPressed(KeyEvent e) {
          if(e.getKeyCode()==KeyEvent.VK_ENTER && e.getSource()==outgoingField)
               String message=outgoingField.getText();
               if(message.equals("")) return;
               showMessage(userName+": "+message);
               conversation.sendMessages(userName+": "+message);
               outgoingField.setText("");     
     //Displays the recieved message
     public void showMessage(String message)
          if(fontMetrics.stringWidth(message)>incomingArea.getWidth())
               int mid=message.length()/2;
               StringBuilder sbld=new StringBuilder(message);
               for(;mid<message.length();mid++)
                    if(message.charAt(mid)==' ')
                         sbld.setCharAt(mid, '\n');
                         message=sbld.toString();
                         break;
          incomingArea.append("\n"+message);
}

Similar Messages

  • How can i set a default font for premiere cs6

    I am hoping to find a way to set a default font for cs6.  I work for a company where i need to use Meta book. Every time I create a new title/text slide, i have to change the font to meta book.  is there a way to make meta book the font that always comes up(as a default) when i go to create a new title/text
    thanks for the help(if there is any)

    You set up your font in the Title Properties then go the panel (dropdown) menu of the Title Styles and select New Style.

  • How can I set a default currency for all my Numbers 03 files - currently it's Lithuanian!

    I have Numbers 03, and I downloaded bought some extra templates through an app in the app store. Graphic Node Version 1.6
    When I open the templates, the default currency is Lithuanian, and it appears that I can only adjust the currency cell by cell, column by column page by page.
    I want the default currency for any of my work to be Aussie Dollars so I don't have to change the spreadsheet each time I want a new file.
    Can this be done?/

    G'day 5508,
    Some thoughts. Try System settings first (this may not be the culprit).
    System Preferences > Language and Region > Advanced > Currency > Australian Dollar
    I can only adjust the currency cell by cell, column by column page by page.
    Forgive my stupidity, but if the currency is a cell format in the template, can you select all currency cells at once, then change the currency? You will have to do this separately for each Table, but within a Table, you can select a range of cells. Quicker than cell by cell.
    Once you have reformatted the document that emerged from that template, save the document as a template with the same name to overwrite the old template.
    Hope this helps, mate.
    Regards,
    Ian.

  • How can I set a default zoom for the browser (freeze it)?

    Hello, there's an option of using the Ctrl + + to zoom the Web page, but it reverts to the Firefox default zoom in the midst which is very annoying. Generally, I'd like to be able to set a certain default zoom level and then only if needed use the CTRL +/- zoom in and out options. So my optimal zoom level is used for all my browsing unless I change it.

    I have listed 2 add-ons below for you to consider. I have not used NoSquint, but I use and rely on Default FullZoom Level.
    *You can set a default zoom level in DFZL Options
    *You can use the mouse scroll wheel on the Add-on Bar DFZL icon to increase or decrease the zoom or click the icon and choose from the available zoom percentages.
    *In NoSquint, it says it saves the zoom level by web site/page.
    *'''''Default FullZoom Level''''': https://addons.mozilla.org/en-US/firefox/addon/default-fullzoom-level/
    *'''''NoSquint''''': https://addons.mozilla.org/en-US/firefox/addon/nosquint/
    **More info on NoSquint: http://urandom.ca/nosquint/
    You can also set a "Minimum Font Size" in Firefox Options > Content > Fonts & Colors Advanced".
    *See --> [https://support.mozilla.com/en-US/kb/Options%20window%20-%20Content%20panel#w_fonts-colors Options window-Content panel-Fonts & Colors]
    '''If this reply solves your problem, please click "Solved It" next to this reply when <u>signed-in</u> to the forum.'''
    Not related to your question, but...
    You may need to update some plug-ins. Check your plug-ins and update as necessary:
    *Plug-in check: https://www-trunk.stage.mozilla.com/en-US/plugincheck/
    *Adobe Shockwave for Director Netscape plug-in: [https://support.mozilla.com/en-US/kb/Using%20the%20Shockwave%20plugin%20with%20Firefox#w_installing-shockwave Installing ('''''or Updating''''') the Shockwave plugin with Firefox]
    *Adobe PDF Plug-In For Firefox and Netscape: [https://support.mozilla.com/en-US/kb/Using%20the%20Adobe%20Reader%20plugin%20with%20Firefox#w_installing-and-updating-adobe-reader Installing/Updating Adobe Reader in Firefox]
    *Shockwave Flash (Adobe Flash or Flash): [https://support.mozilla.com/en-US/kb/Managing%20the%20Flash%20plugin#w_updating-flash Updating Flash in Firefox]
    *Next Generation Java Plug-in for Mozilla browsers: [https://support.mozilla.com/en-US/kb/Using%20the%20Java%20plugin%20with%20Firefox#w_installing-or-updating-java Installing or Updating Java in Firefox]

  • How can one set a default location for the pictures on the hard drive?

    Since Windows normally places the pictures on a typical drive as "My Pictures" about four or five levels down from the root, any effort to import picture files into Lightroom requires multiple clicks to drill down to the "My Pictures" then (for example) year, month, date, etc.
    Can I define a location as the default starting point to find the pictures?  I don't see how to put that into presets. Or can a key shortcut be created to go straight to c:/users/name/mypictures/2013/April15 etc?
    Steve Board

    dj is right. Any Folder can be a picture folder.
    Create a root level folder and add it to your Pictures Library in Windows.  It will show up with all the scattered pictures from other programs. It can even be a different dirve if you like.  You  can even specify one to be the default save location for pictures in this dialog.
    Navigate to Pictures in your Libraries in Windows Explorer Right Click and select Properties.
    Message was edited by: Rikk Flohr forgot the instructions...

  • Interactive Form Element 7.1:  How can I set the default file name?

    I am using Interactive Form Element with 7.1 to display a pdf.  When one clicks the save button in Adobe's toolbar, the dialog defaults the file name to "F.pdf".  Is there a way to default this to a different value?

    Making customisation from the default profile is generally considered poor practice and quite often doesn't work out as planned. (If you're interested in some more information on this, [http://mockbox.net/windows-7/227-customise-windows-7-default-profile.html see here] see here)
    This article should help you with developing and deploying your customised Firefox 4 installation (without touching the Windows 7 default user profile):
    http://mockbox.net/configmgr-sccm/174-install-and-configure-firefox-silently.html

  • How can I set a default for webpages to expand to full screen?

    How can I set a default for webpages to expand to full screen? Every webpage I go to does not expand to a full screen which causes me to have to ctrl+++ each time. How can I set my preference to expand to full screen automatically?
    Thanks.

    The Firefox [https://support.mozilla.com/en-US/kb/Page+Zoom Page Zoom] feature does a domain by domain level of saving the users preferred zoom level settings, there is no default Page Zoom level setting in Firefox, as with some other browsers.
    Try the Default FullZoom Level extension: <br />
    https://addons.mozilla.org/en-US/firefox/addon/6965
    Or the NoSquint extension: <br />
    https://addons.mozilla.org/en-US/firefox/addon/2592/

  • How do I set the default folder for file - open file... ?

    When I save a file, photo, etc., the default folder for OPENING a file becomes the last folder I SAVED to - even after closing and reopening Firefox. Is there a way to maintain the same default folder for opening files?
    Thanks.

    Originally posted by: kwarner.uneedspeed.net
    Well... I found over 200 bugs none of which seemed to talk about setting
    the default folder. I probably missed the relevant bug in the spew.
    I ask a question here as a last resort -- after I've done what I think
    is an appropriate search for answers.
    But thanks for your help in any case.
    Daniel Megert wrote:
    > DemonDuck wrote:
    >
    >> When I need to open a file not in the workspace, I use File -> Open File.
    >>
    >> But the default folder it opens is in C:\Documents and
    >> Setting\Administrator
    >>
    >> I would like File -> Open File to first open in someplace more
    >> reasonable -- like the workspace.
    >>
    >> How do I set the default folder for File -> Open File ????
    >
    >
    > Is your '?' key broken? Check bugzilla there's a feature request
    > regarding your question.
    >
    > Dani

  • :-)  How can we change the default file path for Bank file ( dmee ) ?

    Hi All,
    We encounter a problem.
    Electronic bank file ( created after a F110 run ) are created, in an automatic way to the DIR_TEMP directory. ( On the SAP server )
    How can we change the default file path for Bank files ( dmee ) ?
    We'd like to specify another path.
    Thx for your help.
    Erwan

    Hello,
    Make sure that you have created the directory in transaction code AL11 with the help of basis consultants.
    You can link your PC directory to the application server.
    You can maintain the path whether your file needs to get saved in OBPM4 against your DMEE structure example GB_BACS etc.
    If you do not maintain any path in OBPM4, then the file gets saved to temporary directory. If you give the directory path name in OBPM4, then the file gets saved to that directory with numbers 0001, 0002, 0003 etc till it reaches 9999 and reset from the beginning.
    If you give the path as well as file name as ABCD, then the file gets generated to that directory folder with ABCD0001, ABCD0002, ABCD0003 etc. till it reaches ABCD9999 and reset from the beginning.
    Hope this solves your problem.
    Regards,
    Ravi

  • How do you set the default magnification for Acrobat.  All documents that I open enlarge to 174% and are too big.

    How do you set the default magnification for Acrobat.  All documents that I open enlarge to 174% and are too big.  I see how to change the size after the document is open by going to File/properties/initial view and saving this setting.  I want all documents to open at 100% when they are first opened.  Can I set this as a default view?

    Hey Kris,
    You might go to Edit> Preferences> Zoom
    Do this without opening any particular PDF so that it applies to the program itself and not just one document.
    Try this and then let me know.
    Regards,
    Anubha

  • Can I set the default locale for jvm

    Hi,
    Can I set the default locale for jvm?
    How to do it?
    Pan

    My windows default locale is chinese .I have thought of your opinion. But in
    windows nt , if I change the locale , all the environment will be
    destroyed(just like reinstall it , it's difficult for me) . So , Is there
    any other approach?
    Dimitri Rakitine <[email protected]> wrote in message
    news:[email protected]...
    Did you try to change the locale in the Windows control panel?
    (Control panel -> Regional Options -> Your locale)
    Pan YangBin <[email protected]> wrote:
    I have tried changing this system property and other properties such
    as -Duser.language=en -Dfile.encoding=Cp1252 , but all these properties
    did
    not changed, you can get this infomation from the log file .Maybe these
    system properties are readonly.
    Thanks very much.
    Pan
    Chris Halstead <[email protected]> wrote in message
    news:[email protected]...
    Try adding -Duser.region=US to the java command line used to start
    WebLogic...
    -chris
    "Pan YangBin" <[email protected]> wrote in message
    news:[email protected]...
    Hi,
    The problem exists in my project still exist.That is it.
    When I did not set weblogic.jsp.encoding to GB2312 in my web
    application(web.xml), and when the jsp file contain's chinese , the
    output
    will be error(error chinese) .And when I did not set it , the output
    is
    correct, but when I use request.getParameter("SomeFormElement")(theelement
    inputed chinese), the return value is error(still chinese error).And
    when
    I
    am in windows nt english version and do not set this property, all
    these
    two
    problems dispear. And I try to compare the java files those were
    generated
    by weblogic from the jsp file , there is only two additional clause
    in
    the
    java file. That's it:
    ((weblogic.servlet.jsp.JspWriterImpl)out).setEncoding("GB2312");
    response.setHeader("Content-Type", "text/html; charset=GB2312");
    (the web.xml has <context-param>
    <param-name>weblogic.jsp.encoding</param-name>
    <param-value>GB2312</param-value>
    </context-param> to be set
    So, I think maybe it works well if I change the default locale toenglish.
    And unfortunately, your method is also failed.(I have to use weblogic
    in
    chinese environment)
    Would you please help me to solve this problem?
    Pan
    Dimitri Rakitine <[email protected]> wrote in message
    news:[email protected]...
    Try java ... -Duser.language=en ...
    or mode con cp select=437 in the command prompt before running
    weblogic.
    Pan YangBin <[email protected]> wrote:
    I'm using weblogic server 5.1 sp6 in chinese environment, and I
    want
    weblogic compile my jsp with en_us locale . So I can't use
    Locale.setDefault(new Locale(...)) to set the default locale ,butI
    really
    want someway configure.
    Pan
    Dimitri Rakitine <[email protected]> wrote in message
    news:[email protected]...
    Locale.setDefault(new Locale(...)) ?
    Pan YangBin <[email protected]> wrote:
    Hi,
    Can I set the default locale for jvm?
    How to do it?
    PanDimitri
    Dimitri
    Dimitri

  • How can I set a DEFAULT zoom size at ctrl+++ that will hold while changing sites--even in private browsing?

    How can I set a DEFAULT zoom size at ctrl+++ that will hold while changing sites--even in Private Browsing?
    I'm just starting using Firefox but I won't be using it for long if I have to re-size the screen with every new location viewed.

    Try this add-on
    [https://addons.mozilla.org/en-US/firefox/addon/6965/ Default FullZoom Level ]

  • How can I set the default saving setting in Acrobat 9 to Acrobat 1.4 Compatibility

    How can I set the default saving in Acrobat 9 to Acrobat 1.4 Compatibility...
    My imposition program requires 1.4 compatibility - it handles files from acrobat 8 perfectly - however to use from 9 i have to re-postscript and redistill.
    Ive tried saving as optimised but it doesnt always work.
    I cant seem to find anything in the settings to change it....
    Can anyone enlighten me please??
    Paul

    fatdouglas wrote:
    Ive tried saving as optimised but it doesnt always work.
    I cant seem to find anything in the settings to change it....
    Can anyone enlighten me please??
    Paul
    In your Optimize settings if you set it to "Make Compatible with Acrobat 5.0 or Later" it will bring it down to PDF 1.4

  • How can I set the default print settings of my document as color.  I want the default print setting to be color when someone opens a document.  similar to duplex print preset is there a color print preset?

    How can I set the default print settings of my document as color.  I want the default print setting to be color when someone opens a document.  similar to duplex print preset is there a color print preset?

    Hi,
    Try saving your settings as a Preset by clicking the Preset drop down and then select Save Current Settings as a Preset.
    Next try changing the settings by selecting the saved preset.
    That allow saving the settings for a specific printer, I assume it may also allow selecting these settings for another printer.

  • Pls advise on how can i set my default page

    may i know how can i set my default page if i m using Apache as my web server n tomcat as my servlet container. thank u in advance

    hi....i tried but cannot.
    even when i jus change the "DirectoryIndex Index.html" to "DirectoryIndex abc.html it still gives me the page which shows the file in my directory of htdocs.
    i guess if someone can advise me on how to change away this page first....
    thank u

Maybe you are looking for

  • Time capsule is not working!!!! help me!!!

    Ok my time capsule is showing an amber light and will not connect to internet i've had it for 6 months and it was working now it will not. ok so I know my internet is working because i have a hard line on one computer and that one is connected. I've

  • SQL Query to get Date Range Values

    Hi, The database is Oracle11i. I am looking for a way to generate list of dates from a fixed date in the past (could be hardcoded) to current day (sysdate). That is, if the fixed date is 19 June 2011 and assuming that today is 24 June 2011 the SQL sh

  • 160gb classic crashes when selecting specific album

    Infuriatingly my ipod's decided to crash whenever I try to pick a certain album. One of a few things will happen; the ipod will straight up freeze on the song list for that album, each song will be 'played' in the album (by which I mean each will las

  • Rows_Processed in v$SQL

    Hi everybody, How can you explain that the number of total rows of a table is different from the rows_processed in v$SQL when i execute the sql statement 'count(*) from the <table>'??? O.K. I FOUND WHY THE DIFFERENCE OCCURED.......!!!! Thanks, Simon

  • NF 980 PS2 Mouse & Keyboard PS2 IC just stopped working.

    Hello, My PS2 Mouse & Keyboard intergrated circuit connections just stopped working. My Rig is only 6weeks old & was using Win 7 Ultimate 64bit. Everything was fine untill yesterday. all of a sudden the connections don't work. I tried doing a system