How to realize them with Java Swing?

1.I want to realize the function - Save, which is similar with "save" in windows notepad - after clicking "save", a dialog box is poped up, then i can input the filename and save it. Is there any ready class like JFileChooser in Java Swing?
2.I want to set Font and color in the text area. I can do it now. But I must set the font and color b4 input the words. How can I do it like Windows Word - I just input my words, then I highlight them and select the font and colour....all highlighted words r change....can I don it with Java swing and how?
Thanks..

1.I want to realize the function - Save, which is
similar with "save" in windows notepad - after
clicking "save", a dialog box is poped up, then i can
input the filename and save it. Is there any ready
class like JFileChooser in Java Swing?JFileChooser is a Swing based dialog, use it for your problem.
>
2.I want to set Font and color in the text area. I can
do it now. But I must set the font and color b4 input
the words. How can I do it like Windows Word - I just
input my words, then I highlight them and select the
font and colour....all highlighted words r
change....can I don it with Java swing and how?
Thanks..I am currently working this, try the ElementIterator w/ the Document that your inputing, as you iterate throught the nodes, you modify the attribute sets there.
Hope this helps.
>

Similar Messages

  • Problem with java swing button and loop

    Problem with java swing button and loop
    I�m using VAJ 4.0. and I�m doing normal GUI application. I have next problem.
    I have in the same class two jswing buttons named start (ivjGStart) and stop (ivjGStop) and private static int field named Status where initial value is 0. This buttons should work something like this:
    When I click on start button it must do next:
    Start button must set disenabled and Stop button must set enabled and selected. Field status is set to 1, because this is a condition in next procedure in some loop. And then procedure named IzvajajNeprekinjeno() is invoked.
    And when I click on stop button it must do next:
    Start button must set enabled and selected and Stop button must set disenabled.
    Field status is set to 0.
    This works everything fine without loop �do .. while� inside the procedure IzvajajNeprekinjeno(). But when used this loop the start button all the time stay (like) pressed. And this means that a can�t stop my loop.
    There is java code, so you can get better picture:
    /** start button */
    public void gStart_ActionEvents() {
    try {
    ivjGStart.setEnabled(false);
    ivjGStop.setEnabled(true);
    ivjGStop.setSelected(true);
    getJTextPane1().setText("Program is running ...");
    Status = 1;
    } catch (Exception e) {}
    /** stop button */
    public void gStop_ActionEvents() {
    try {
    ivjGStart.setEnabled(true);
    ivjGStart.setSelected(true);
    ivjGStop.setEnabled(false);
    getJTextPane1().setText("Program is NOT running ...");
    Status = 0;
    } catch (Exception e) {
    /** procedure IzvajajNeprekinjeno() */
    public void IzvajajNeprekinjeno() {  //RunLoop
    try {
    int zamik = 2000; //delay
    do {
    Thread.sleep(zamik);
    PreberiDat(); //procedure
    } while (Status == 1);
    } catch (Exception e) {
    So, I'm asking what I have to do, that start button will not all the time stay pressed? Or some other aspect of solving this problem.
    Any help will be appreciated.
    Best regards,
    Tomi

    This is a multi thread problem. When you start the gui, it is running in one thread. Lets call that GUI_Thread so we know what we are talking about.
    Since java is task-based this will happen if you do like this:
    1. Button "Start" is pressed. Thread running: GUI_Thread
    2. Event gStart_ActionEvents() called. Thread running: GUI_Thread
    3. Method IzvajajNeprekinjeno() called. Thread running: GUI_Thread
    4. Sleep in method IzvajajNeprekinjeno() on thread GUI_Thread
    5. Call PreberiDat(). Thread running: GUI_Thread
    6. Check status. If == 1, go tho 4. Thread running: GUI_Thread.
    Since the method IzvajajNeprekinjeno() (what does that mean?) and the GUI is running in the same thread and the event that the Start button has thrown isn't done yet, the program will go on in the IzvajajNeprekinjeno() method forever and never let you press the Stop-button.
    What you have to do is do put either the GUI in a thread of its own or start a new thread that will do the task of the IzvajajNeprekinjeno() method.
    http://java.sun.com/docs/books/tutorial/uiswing/index.html
    This tutorial explains how to build a multi threaded gui.
    /Lime

  • Reg: Embedding Firefox with Java Swing

    Sir,
    The thing is We all know that Mozilla Firefox is open source.
    How to embed the mozilla firefox with Java Swing or java AWT Frame.
    Could me suggest me the ways to do it, the code and also the concept behind it?
    I put the same question in forum but i didnot get any response.and i also googled a lot,but none was help ful
    Could u please help us Sir?
    Thanks..

    you can use webrenderer or jxbrowser library...to embed web browser in your swing application.
    otherwise Use OLE with java to embed IE in your swing application....

  • In program written with Java Swing, I can't input Chinese

    In program written with Java Swing, I can't input Chinese.
    But if I change my language first, then change the input method tu U.S, open the Java Swing application, finally I can input Chinese. I want to know how to fix this bug.
    My OS is Mac OS X 10.6.8.
    At the JDK version 1.6.0_29, I can input Chinese friendly in Java Swing applications. But after 1.6.0_31, I can't do it anymore. The input methods can input Chinese in other non Java Swing applications so the problem must create by JDK or JRE's Swing part. What's the different between 1.6.0_29's Swing and 1.6.0_31's ? Why ? I heard that Java Swing apps not support Chinese input methods seens 2009... Why haven't fix these yet?

    Chazza wrote:
    Perhaps you need to change your keyboard layout in Xorg?
    https://wiki.archlinux.org/index.php/Ke … ard_layout
    Thanks for your answer!
    I have tried to change the keyboard layout from "en" to "cn", but it is still not work.
    The input method coin on the righttop is right when I change the method.But it still output english even I use ibus-pinyin.There is not a box for my choosing chinese words.
    Last edited by Dilingg (2015-05-15 16:18:43)

  • How to find browser have java swing plugins

    how to find browser have java swing plugins

    Hi, you can detect it. If it is not there, you can make the installation automatically. Here is an example.This will not work with NN4 browser unless the user has Enable Java Plugin checked (see Edit | Preferences | Advanced. Nor will it work under IE if the user has disabled Java.
    The best solution, IMHO, is to trigger a JavaScript function and check to see if the applet is created. You can try:
    <html>
    <head>
    <title>....</title>
    <script>
    function checkApplet() {
    if (document.myApplet!!=null) return true;
    alert("You need to enable Java and have the proper plugin to view this document:);
    return false;
    </script>
    <noscript>You need to turn on JavaScript to view this page</noscript>
    <body onLoad="checkApplet()">
    ...... // applet tag goes here
    </body>
    </html>
    Remember that you cannot call your applet to test its status.
    V.V.

  • How to embed/perform a Java Swing form into webased Swing form

    How to embed/perform a Java Swing form into webased Swing form or any alternative.
    Suppose i have 2 or more swing forms which are desktop applications but i want those forms to be now webbased..so how can i do this.Will i need to change the swing coding or will have to keep the swing design same.what can be the best Solution.

    You can launch your existing desktop app via the web using [Java Web Start|http://java.sun.com/javase/technologies/desktop/javawebstart/index.jsp]

  • Help with java swing

    Hi people!i need some help
    Im a new user for java programming language.Well im programming an application using java swing libraries. I have some problems trying to accesing variables from those swing Jpanels. Ill make it clear....
    Im using Netbeans...
    I have a class for the window (a JFrame) including 2 Jtextfields and 2 Jlabels
    import .......
    public class myclass extends javax.swing.JFrame{
    public double gp;
    public double gv;
    public G() {
    initComponents();
    gpnom=this.gpnom;
    gvnom=this.gvnom;
    private void TXFgpnom(java.awt.event.ActionEvent evt) {        //TXField                                
    gpnom= Double.parseDouble(TXFgpnom.getText());
    gvnom= Double.parseDouble(TXFgvnom.getText());
    .......//theres a lot of more code .for listeners..next...
    Now ive created a new file (a new class)in the same package ,but i cant access public variables from swing class
    //the next class was created in a new file
    public class hi () {
    JPanel prin =(JPanel) new myclass().getContentPane(); //ok
    double number=gpnom // error variable not found
    When i try to get the value of "number" ...i always get "ERROR" And the class for that textfield was public..i think...
    HOw can i use variables from that Jpanel?
    Id appreciate an answer...
    thanx for your help!
    Paco

    In future Swing related questions should be posted in the Swing forum and camickr will be more likely to answer if you have used code tags to properly format your code.
    Luckily this problem does not seem to be Swing related in the least because the public variables you have in your other class are named gp and gv and further when you access public variables (or properties) of a class you must access them by an instance of that class. Which you don't appear to be doing either.

  • How to use connec with java 6.0 ?

    I often use the function below to connect Database:
         public Connection getConnection(){
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    conn=DriverManager.getConnection("jdbc:odbc:EmployeeManagerDB","sa","sa");
    System.out.println("Get connection successfully!");
    catch(Exception e){
                   System.out.println("Error: " +e);
    return conn;
    but now, with Java 6.0 . don't use "class.forName....for method"
    can you tell me how to use it??
    thanks !

    but now, with Java 6.0 . don't use
    "class.forName....for method" Where did you get this idea?He's perfectly correct. JDBC 4.0 takes advantage of the Java SE Service Provide mechanism in Java 6 to do away with the requirement. So, if you have Java 6 and a JDBC 4 driver (it's a mandatory feature) you simply omit the forName() call.
    The only problem is that there aren't that many complete JDBC 4 drivers out there yet.

  • Need help for connecting Ms Acces with java Swing in Mac OS

    Hi all,
    i need to connect to Ms Access in MAc os through my java swing program.
    Is it possible for accessing Ms access through dsn in Mac OS.
    If Possible which driver shall i use for Establishing Connection with MS Access in Mac OS.
    Suggestion is needed urgently.
    Can anybody help me out regarding this..
    Thanks in advance.
    Regards,
    sreand

    if I don't find a better solution I'll try your 2nd option but what do you mean by "combo" update?
    My understanding is to simply insert the OS 10.5 installation CD, reinstall the OS and the just keep updating it via the OS SSoftware update panel and stop untill I see the scary Java 8 update. Is that what you meant?
    While you can do it that way, the combo update picks up operating system updates through a collection of releases. When dealing with operating system upgrades, I've found using the combo updates to be more reliable than Software Update, as sometimes Software Update doesn't apply updates correctly, and weird things can happen. Doesn't happen often though, thankfully.
    So the OS X 10.5.5 Combo update contains all updates between 10.5.0 and 10.5. The 10.5.8 combo update contains the updates from 10.5 thru 10.8. Here are the updates:
    10.5 combo update: http://support.apple.com/kb/DL692
    10.8 combo update: http://support.apple.com/kb/DL866
    If you go down the combo path, repair permissions before and after doing each update. Then do Software Update for any other non-OS X updates, and don't apply the Java Update 8.

  • How replace XML Elements with java

    I have been usint SAX 2.0 and DOM Level 2 api's to represent XML documents, which i parse with apache's Xerces parser... I am trying to delete certain elements and replace them with others, but none of the api's allow this the closes i have come is replacing attributes of elements....

    -jverd
    You might also want to look into jdom or dom4j.Thanks jdom worked for replaceing the elements and attributes...but when i tried to store the changes in a new file, the text nodes were processed. for e.g. if i had &#8217 the char ( ' ) appeared in the new file. how do i keep the unicode...

  • How to use Entrust with java application on unix platform

    Hi all,
    i have question regarding the use of Entrust with java application on unix
    1)I want to use Entrust for encryption/decryption of the file in my core java application on unix platform.
    What should be requiremnet for the same and how it is implemented?.
    2) I want to Use Entrust for Authentication purpose in my java based web application on unix platform.
    What are requirements for Entrust Authentication and how it is implemented ?

    any one has solution?

  • Does Seagate Crystal Report Be Integrated with Java Swing

    Hello All
    We are developing java programs for quiet some time now, But what we are trying to do now is can we do the things what VB can do , Thatis the reports from the Database Query can be formatted into Crystal reports
    I use Forte For java Sun One Studio 4 For developing Swing Applicatioon
    If Any of U can give me idea, ie a report not in HTML format But Crystal Report, PLease Le me know
    Regds

    Are you developing an Applet or a standalone application?
    The way I'd handle this is to install the Crystal Reports web server and then call these reports from the web simply by specifying an appropriate URL.
    By the way: the Crytsal reports server also handles report requests in Netscape with JAVA (IE with ActiveX)
    so perhaps this is the right corner to look for answers
    Regards

  • Do you know how to call RDF with java code?

    Say me a tip!
    Environment:
    Linux, Reports 6i,java beans, jsp
    My mission is to run a report with java code.
    But I don't know how to.
    Basic flow is :
    On web browser, call jsp a program and
    that jsp call a java module,
    and the java module call a reports RDF with parameters
    I don't need reponse message from rwcgi60 or rwrun60.

    hello,
    the easiest way is to use the regular HTTP request to either the servlet or the CGI to run a report request from within a java-class.
    regards,
    the oracle reports team --pw                                                                                                                                                                                                                                                                                                                                                                                       

  • How import policy file with Java Web Start

    hi everybody,
    I wrote an application launched by Java Web Start.
    This application encrypt data on the client side and POST them to the server.
    To encrypt I use JCE packages including sunjce_provider.jar, jce1_2_1.jar and
    local_policy.jar and US_export_policy.jar.
    local_policy.jar and US_export_policy.jar are not packages, each of them contains
    a policy file.
    When I test encryption on local no problem, but when I test with Java Web Start
    I've got this exception :
    java.lang.ExceptionInInitializerError:
    java.lang.SecurityException: Cannot set up certs for trusted CAs
    It's because the application launched by Java Web Start doesn't find local_policy.jar
    and US_export_policy.jar.
    There's a problem in my JNLP file :
    <jnlp spec="1.0+" href="http://myserver/sources/test.jnlp" codebase="http://myserver/sources">
         <information>
              <title>Java Web Start TEST</title>
              <vendor>NLE Intech</vendor>
              <description>cryptage then upload</description>
         </information>
         <security>
              <all-permissions/>
         </security>
         <resources>
              <j2se version="1.3" />
              <jar href="sunjce_provider.jar" />
              <jar href="jce1_2_1.jar" />
              <jar href="local_policy.jar" />
              <jar href="US_export_policy.jar" />
         </resources>
         <application-desc main-class="HelloWorldSwing" >
              <argument>c:\myfiletoencrypt</argument>
         </application-desc>
    </jnlp>
    thank you for your answer

    Hi Nicolas,
    If you migrate to JDK1.4 and use the signed Bouncy JAR, you could resolve the problem,
    if you don't want to use unlimited cryptography.
    See my posting on your other question.
    Agnes
    PS. There is a mistake in my other reply, the "local_policy.jar" and the other files must have
    to go into JRE/LIB/SECURITY directory

  • Research - how to build OS with Java

    I intend to build the basic functionality of an OS with Java.
    Can anyone recommend a good book:
    - that explains the OS achitecture in depth.
    - gives a headstart to start programming OS concepts in Java

    you only need to know two things:
    - How to schedule threads
    - How to create a file system

Maybe you are looking for

  • My keynote has frozen and wont open but the saved version wont open either. if i restart my laptop i am afraid that it will erase my work. please help me

    my keynote has frozen and wont open but the saved version wont open either. if i restart my laptop i am afraid that it will erase my work. please help me

  • More than 1 iphone on same ATT account?

    This is probably a basic question that has been answered many times...but I can't find it on the search so my apologies for any redundancy. My wife already has an iphone on our ATT family plan and is paying an extra $50 a month for the 3g Data packag

  • Barcode Font in reports

    One of our reports has a number field in it and it shows up as bar code in the report as we have changed the font. This report is working fine on Windows but for some reason it is not working on Linux server. I have the font installed in Linux and I

  • Service charge for Customer materials..?

    Hi Our customer is giving us some material and asking us to do some service on it.Material given by customer some service work we will do it in our company .how to carryout this scenario? IN MM module we have a functionality called – subcontracting.

  • ACTIVAR EL AURICULAR DEL Q10

    Buenas Noches:                                Saludos a todos compañeros; Me podrian ayudar como activar el auricular del Q10 para oir la musica que tengo en el telefono porque no encuentro la manera muchas gracias..................