How to use JFrame's setLayeredPane() method?

I want to custom JFrame's LayeredPane by setLayeredPane() method,but it does't work.
Anyone who can help me?
The code as follows:
import javax.swing.*;
import java.awt.*;
public class LayeredTest{
    public static void main(String[] args){
        SwingUtilities.invokeLater(new Runnable(){
            public void run(){
                new MyFrame().setVisible(true);
class MyFrame extends JFrame{
    public MyFrame(){
        super("LayeredTest");
        setLayeredPane(new JLayeredPane());           //this line, I want to set the LayeredPane myself;
                                                      //but it doesn't work.
        JPanel panel =new JPanel();
        panel.setPreferredSize(new Dimension(320,240));
        panel.add(new JLabel("Label"));
        panel.add(new JButton("Button"));
        add(panel);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        pack();   
}

Thanks!
But the very thing I want to know is "How to set Layered Pane(by setLayeredPane() method)",
not "How to use Layered Pane".

Similar Messages

  • How to use two split this method in my code

    How to use two split this method in my code
    if i got one string line which like this
    ("aa!bb!cc~ab!bc!cd") a
    nd want to use two split to spare ! and ~ this seal for my spare point how that output
    has come diff ?
    public static void main(String[] args) {
        String str = "aa!bb!cc~ab!bc!cd";
        String strs[]= str.split("~");
        String strE[]= str.split("!");
        int count =0;
        for(int j=0; j < strs.length; j++){
          for (int i = 0; i < strE.length; i++){   
              System.out.println(count + " " + strE);
    count++;
    the output how can it be like this
    0 aa
    0 bb
    0 cc
    1 ab
    1 bc
    1 cd

    Move your second slit inside the first loop, so you are splitting the substring, not the entire string.

  • Need help!! How to use super in equals() method and makeCopy() method?

    This is my Name class:
    class Name {
        private String title;
        private String name;
        public Name(){
             title=" ";
             name=" ";
        public Name(String title){
             setTitle(title);
             name=" ";
        public Name(String title,String name){
             setTitle(title);
             setName(name);
        public void setTitle(String title){
             this.title=title;
        public String getTitle(){
             return title;
        public void setName(String name){
             this.name=name;
        public String getName(){
             return name;
        }   This is my Person Class
    class Person extends Name{
        private String address;
        private String tel;
        private String email;     
        public Person(){
             super();
             address=" ";
             tel=" ";
             email=" ";
        public Person(String name){
             super(name);
             address=" ";
             tel=" ";
             email=" ";
        public Person(String title,String name,String addressStr){
             super(title,name);
             setAddress(addressStr);
             tel=" ";
             email=" ";
        public Person(String title,String name,String addressStr,String phoneNum){
             super(title,name);
             setAddress(addressStr);
             setTel(phoneNum);
             email=" ";
        public Person(String title,String name,String addressStr,String phoneNum,String emailStr){
             super(title,name);
             setAddress(addressStr);
             setTel(phoneNum);
             setEmail(emailStr);
        public void setAddress(String add){
             address=add;
        public String getAddress(){
             return address;
        public void setTel(String telephone){
             tel=telephone;
        public String getTel(){
             return tel;
        public void setEmail(String emailAdd){
             email=emailAdd;
        public String getEmail(){
             return email;
         public boolean equals(Person inputRecords){
             boolean equalOrNot=false;
             if(inputRecords.super(getTitle()).equals(title))         //this is wrong
                  if(inputRecords.super(getName()).equals(name))           //this is wrong
                       if(inputRecords.getAddress().equals(address))
                            if(inputRecords.getTel().equals(tel))
                                 if(inputRecords.getEmail().equals(email))
                                      equalOrNot=true;
             return equalOrNot;   
            public void makeCopy(Person copyInto){
                 copyInto.super(setTitle(title));             //this is wrong
                 copyInto.super(setName(name));           //this is wrong
                 copyInto.setAddress(address);
                 copyInto.setTel(tel);
                 copyInto.setEmail(email);
    }How can I correct the wrong part?
    I don't understand how to use super in equals() method and makeCopy() method.

    Try something like this ...
    public boolean equals(Object other) {
      if (other==null || !(other instanceof Person)) return false;
      Person that = (Person) other;
      return getTitle().equals(that.getTitle())
          && getName().equals(that.getName())
          && getAddress().equals(that.getAddress())
          && getTel().equals(that.getTel())
          && getEmail().equals(that.getEmail())
    Notes:
    * This overrides Object's public boolean equals(Object other), which is (probably) what you meant.
    * You don't need to call "super.getWhatever" explicitly... just call "getWhatever" and let java workout where it's defined... this is better because if you then override getTitle() for example you don't need to change your equals method (which you would otherwise probably forget to do, which would probably have some interesting side effects.
    Cheers. Keith.

  • How to use results of ejbfind methods when it is a collection ?

    How to use ejbFind methods result , when it is a collection ?
    Hi thank you for reading my post.
    EJB find methods return a collection , i want to know how i can use that collection ?
    should i use Collection.toArray() and then use that array by casting it?
    what is DTOs and ho i can use them in this case?
    How i can use the returned collection is a swing application as it is a colection of ejbs ?
    Should i Cast it back to ejb class which it comes from or some other way ?
    for example converting it to an array of DTO (in session bean) and return it to swing application ?
    or there are some other ways ?
    Thank you

    Hi
    pleas , some one answer
    Collection collection = <home-interface>.<finderMethod>;
    Iterator iter = collection.iterator();
    while (iter.hasNext()) {
    <remote-interface> entityEJB = (<remote-interface>) iter.next();
    } what if i do the above job in session bean and convert the result to a DTO and pass the dto back ?
    thank you

  • Urgent!!! How to use IN_PARAMETER in CONSTRUCT_BSP_URL method

    Hi sdn,
    Iam new to bsp.I created a application with 2 controllers and 2 views.i want to transfer the values from one controller to another controller by using the runtime->construct_bsp_url().
    in that one parameter " in_parameter" is used to pass the values from another controller.but i don't know how to use that parameter.please give me sample example or give me syntax for that parameter.
    thank you for advance.
    Award the useful answer.
    thanks,
    Ramkumar

    hI,
    method DO_HANDLE_EVENT.
    DATA: event1 TYPE REF TO CL_HTMLB_EVENT.
    DATA: data TYPE REF TO CL_HTMLB_INPUTFIELD.
    DATA: V_TARGET_URL TYPE STRING,
            W_APP_NAME TYPE STRING.
    event1 = CL_HTMLB_MANAGER=>get_event( runtime->server->request ).
    if event1->name = 'button' and event1->event_type = 'click'.
    data:button_event type ref to cl_htmlb_event_button.
    button_event ?= event1.
    if button_event->server_event = 'submit'.
    data ?= CL_HTMLB_MANAGER=>GET_DATA( request = runtime->server->request
                                        name     = 'inputField'
                                        id       = 'ip1'
    IF data IS NOT INITIAL.
    input1 = data->value.
    ENDIF.
    data ?= CL_HTMLB_MANAGER=>GET_DATA( request = runtime->server->request
                                        name     = 'inputField'
                                        id       = 'ip2'
    IF data IS NOT INITIAL.
    input2 = data->value.
    ENDIF.
                  DATA: lt_params TYPE tihttpnvp.
                  FIELD-SYMBOLS: GOTO_PAGE( V_TARGET_URL ).
    endif.
    endif.
    endmethod.
    THE ABOVE CODE I WROTE IN DO_HANDLER_EVENT() METHOD.I ACTIVATED AND TESTED.IN THE FIRST VIEW ASKING THE APPLICATION NAME AND CONTROLLER I GAVETHAT INPUTFIELDS BUT THE NEXT VIEW IN THE OTHER CONTROLLER NOT DISPLAYING.IT GEETING THE ERROR
    BSP Exception: Das Objekt default.htm in der URL /sap/bc/bsp/sap/zehro_gr_fw_1/default.htm?input1=ZWFA_ESS04&input2=ZWFA_ESS04_01%2eDO&sap-sessioncmd=open ist nicht gültig.
    Please resolve my issue.

  • How to use $controller.DateTimeUtils.DateGet method ?

    Hi everyone,
    Can someone tell me how to use the $controller.DateTimeUtils.DateGet method ? I would like to know whether a date is a saturday or sunday but I can't figure out how to use the method.
    Thanks in advance
    Chris

    See the JMX documentation.
    http://java.sun.com/javase/6/docs/api/javax/management/modelmbean/ModelMBeanInfo.html

  • How to use FileOutputStream in a method??

    Dear friend,
    Now I want to write a program use java swing. I can get text from JPasswordField but I can't write the password in a document. I try to use FileOutputStream in a method with actionPerformed. But it seem no work. The problem is where should I put the 'throws IOException'? At the main or at the method?? Thank you very much.
    Ah Siew.

    Hi!
    You can write this methode in a
    try
    }catch(IOException)
    or you write an throws IOException after the Methode.
    Thats the Problem with to IOException
    Now your other problem:
    first: an JPasswordField is an javax.swing element.
    You can get the String with the
    String1 = PasswordFieldObject.getText(); Methode.
    and than you can save it in an "Global" Var.
    Greetings
    F@b

  • How to use the VBS MoveFolder methode in DIAdem without any error message?

    Hi,
    I want to move folders with the VBS MoveFolder methode, but in DIAdem I run in problems. When I use the following comman    fso.MoveFolder(project_folder & test_folder, project_folder & test_folder & "\" & test_ & " " & test_count) 
    I get error message
    "During call a sub routine no parentheses are allowed!"
    When I remove the brackets and use    fso.MoveFolder project_folder & test_folder, project_folder & test_folder & "\" & test_ & " " & test_count 
    I get the error message
    "Invalid sub routine call."
    How I have to use the command right?
    (the text of error messages is free translated from German Version of DIAdem 11.0! Take only the sense, not the exact wording!)
    Thanks for help.
    Regards
    Sven

    Hello Sven!
    Just add a 'Call' at the beginning of your first line will solve the syntatic error. I recommend always to use 'Call' and parenthesis.
    But there is a fundamental problem in your code: MoveFolder moves a folder from a source to a new destination and the old source folder will be deleted. You try to move a folder to a location below the same folder. If the MoveFolder wouldn't recognize these situtation and throws an error all of your data would be deleted!
    Just print out your paths in a Messagebox to clearify the situation.
    Matthias
    Matthias Alleweldt
    Project Engineer / Projektingenieur
    Twigeater?  

  • How to use JCoIDoc.JCoDocument.fromXML method

    I want to restore an IDoc from XML string which is saved by method of IDoc.Document.toXML. But I can not find any api I can use. There is JCoIDoc.JCoDocument.fromXML method which can do this task. But I don't know how to get the instance of this class. Does anyone can give me some help?
    Thanks,
    Jun

    See the JMX documentation.
    http://java.sun.com/javase/6/docs/api/javax/management/modelmbean/ModelMBeanInfo.html

  • Please help on how to use variables inside a method call

    Hello guys,
    How's it goin?
    Pardon me if you find my question silly, but I am relatively
    new in ActionScript 2.0 programming.
    I have here a simple problem. It seems I can't use a variable
    inside a method call of an object. Here's the code. Please note of
    the authParams string variable below.
    import AkamaiConnection;
    import mx.services.WebService;
    var GeneratedToken:String;
    var authParams:String;
    // Create a Web Service object
    var TokGenService:WebService = new WebService("
    http://webservice.asmx?wsdl");
    // Call the web service method
    var myToken:Object = TokGenService.GenerateToken();
    // Create an AkamaiConnection object
    var connection:AkamaiConnection = new AkamaiConnection();
    connection.addEventListener("onConnect", this);
    connection.addEventListener("onError", this);
    // If you get a result from the web service, save the result
    in a variable
    myToken.onResult = function(result)
    // If you get a result from the web service, save the result
    in a variable
    myToken.onResult = function(result)
    GeneratedToken = result;
    authParams = GeneratedToken +
    "&aifp=v001&slist=37414/test/Streaming/";
    //Call the Connect method of the AkamaiConnection class
    connection.connect("cp37414.edgefcs.net/ondemand",true,true,5,true,false,"443","rtmpt",
    authParams);
    But then, if I use a hard-coded string value in lieu of the
    variable, the method call works!
    connection.connect("cp37414.edgefcs.net/ondemand",true,true,5,true,false,"443","rtmpt",
    "testStringvalue");
    I don't know what I'm missing or what I'm doing wrong... Can
    somebody help me please? I am using a 30-day trial version of Adobe
    Flash CS3. Also, when I Trace output the variables, the values are
    there. It just that they can't be read or recognize inside the
    method call. Is this a ActionScript limitation?
    Thanks so much in advance!

    The result param is a returned, “Decoded ActionScript
    object version of the XML”. I am not exactly sure what that
    means but I have had issues of returned XML values and their
    datatype. When I did have these issues I had to cast or convert
    into the desired datatype. Try one of the following, assuming the
    problem is related to the code that you have bolded.
    GeneratedToken = result.toString();
    authParams = GeneratedToken +
    "&aifp=v001&slist=37414/test/Streaming/";
    Or
    GeneratedToken = String(result);
    authParams = GeneratedToken +
    "&aifp=v001&slist=37414/test/Streaming/";
    Or
    GeneratedToken = result.toString();
    authParams = String(GeneratedToken +
    "&aifp=v001&slist=37414/test/Streaming/");

  • Beginner question - How to use JFrame class?

    How can we use a JFrame class created? Shld you run it like JApplet on browser or appletviewer?

    First, if I understand what you want to do exactly, you need to write two classes. The main one will be your class that extends javax.swing.JFrame. Wherehas the second will be your "container class" and will extends java.applet.Applet. This second class will do nothing more than instantiate your JFrame subclass. This is this last class that will be called in your HTML file.
    I made up some code quickly to give you an idea:
    import javax.swing.JFrame;
    public class TestJFrame extends JFrame {
    //Constructor
    public TestJFrame() {
    super("My test JFrame"); //calls the superclass constructor
    this.setSize(200,200);
    this.setVisible(true);
    // Main (optionnal here: just in case you need to
    // instantiate the class within an application)
    public static void main(String[] args) {
    new TestJFrame();
    =======================
    import java.applet.Applet;
    public class TestJFrameApplet extends Applet {
    public void init() {
    new TestJFrame();
    Hope this help

  • What does findObject() method do, How to use it with changeObject() method?

    Hi all,
    Can anyone tell me what is the use of findObject() method can i use it to find and replace actual pageItems.
    Thanks

    The ADF is used to automatically feed a number of pages for scanning, copying or faxing.  Paper is loaded into the ADF with the printed side facing up.  When you then copy (or scan or fax) the pages will be automatically pulled into the scanner mechanism one at a time and then deposited in the output tray. 
    Bob Headrick,  HP Expert
    I am not an employee of HP, I am a volunteer posting here on my own time.
    If your problem is solved please click the "Accept as Solution" button ------------V
    If my answer was helpful please click the "Thumbs Up" to say "Thank You"--V

  • How to use Character.toUpperCase(c) method in below program?

    Dear,
    I have a source code as below. I want to ask how to convert all lower case letters in input file(farrago.txt) to upper case letters in the output file(outagain.txt)? Where the method Character.toUpperCase(c) adds into the code?
    Please help!
    import java.io.*;
    public class Copy {
    public static void main(String[] args) throws IOException {
         File inputFile = new File("farrago.txt");
         File outputFile = new File("outagain.txt");
    FileReader in = new FileReader(inputFile);
    FileWriter out = new FileWriter(outputFile);
    int c;
    while ((c = in.read()) != -1)
    out.write(c);
    in.close();
    out.close();
    }

    Sorry, i did not see that c is an int, so do it like this
    while ((c = in.read()) != -1)
        char C  = Character.toUpperCase((char)c);
        out.write(C);
    }Noah

  • One question about how to use JFrame

    Hello friends,
    I use a JFrame to show one webpage, I want to follow a link in this page by a new window, but when I used it, I find, each time I create a new window to follow a link, the old window will be nothing, what should I do?
    Thanks in advance!
    See the following codes:
    import javax.swing.text.*;
    import javax.swing.*;
    import java.net.*;
    import java.io.*;
    import java.awt.*;
    public class SimpleWebBrowser {
    public static void main(String[] args) {
    // get the first URL
    String initialPage = "http://www.yahoo.com";
    if (args.length > 0) initialPage = args[0];
    // set up the editor pane
    JEditorPane jep = new JEditorPane();
    jep.setEditable(false);
    jep.addHyperlinkListener(new LinkFollower(jep));
    try {
    jep.setPage(initialPage);
    catch (IOException e) {
    System.err.println("Usage: java SimpleWebBrowser url");
    System.err.println(e);
    System.exit(-1);
    // set up the window
    JScrollPane scrollPane = new JScrollPane(jep);
    JFrame f = new JFrame("Simple Web Browser");
    f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    f.getContentPane().add(scrollPane);
    f.setSize(512, 342);
    f.show();
    import javax.swing.*;
    import javax.swing.event.*;
    public class LinkFollower implements HyperlinkListener {
    private JEditorPane pane;
    private JScrollPane window;
    public LinkFollower(JEditorPane pane) {      
    this.pane = pane;
    public void hyperlinkUpdate(HyperlinkEvent evt) {
    if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
    try {
         pane.setPage(evt.getURL());
         window = new JScrollPane(pane);
         JFrame.setDefaultLookAndFeelDecorated(true);
    JFrame t = new JFrame();
    t.getContentPane().add(window);
         t.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    t.setSize(800, 600);
    t.show();
    catch (Exception e) {       

    the old window will be nothingBecause you abandon the old frame.
    Use it forever.
    Beware: Java HTML rendering framework is almost endlessly incomplete. You shouldnIt implement real browser with them.
    See Q6.3.2 - Q6.3.6 of this FAQ:
    http://groups.google.com/groups?hl=en&lr=&selm=cjr8er%24oo0%241%40newstree.wise.edt.ericsson.se&rnum=37

  • How To Use The SPULSRetriever.GetULSEntries Method

    This is the method in question:
    https://msdn.microsoft.com/EN-US/library/office/microsoft.sharepoint.diagnostics.spulsretriever.getulsentries.aspx
    I recently found this method and was interested in using it for a solution. However, the count is always 0 when executed. I create an instance of the SPULSRetriever class with the start time as 180 minutes ago, the forward check time of 300 minutes,
    and 1000 max entries.
    I then call GetULSEntries with a correlation ID that I found in the logs within the timeframe, but it never finds anything.
    I am simply running the code from visual studio on the same server as the SharePoint instance.
    Any suggestions?
    SPULSRetriever ulsRetriever = new SPULSRetriever(300, 1000, DateTime.Now.AddMinutes(-180));
    IList<LogFileEntry> ulsLogEntries = ulsRetriever.GetULSEntries(new Guid("8c65f19c-0237-605e-e12e-53328ffb7868"));

    I tried your code and I have no trouble getting entries back. Looking at the internal code, if and exception occurs the method just returns an empty IList. So you  need to check for something like this in the ULS logs "Cannot access ULS share
    on \\{0}\logs", appears to  be a permissions issue.
    Blog | SharePoint Field Notes Dev Tools |
    SPFastDeploy | SPRemoteAPIExplorer

Maybe you are looking for

  • Error while Test Map in Biztalk 2010

    Hello, I have made some changes to the existing map and tried to test the map.The Changes I made is adding a scripting functoid with the following code public string Code(string recode, string amount) { double k = Convert.ToDouble(amount); if(k>0) {

  • What are the minimum system requirements for GB 4?

    What are the minimum system requirements for GB 4? I did search this forum but wasn't able to find a direct answer. I'm running version 3.0.4 successfully on a lowly G4 733 but I suspect this is as far as I can go. I'm updating to iDvd'08 and was als

  • Dynamic List Selection as a Parameter in another Recordset

    Please help. I have an ASP VBScript webpage. The first field on this page is a dynamic menu / list which lists footballers from a recordset. Whichever player is selected I then want to populate additional fields on the page (e.g. team he plays for) b

  • Doubt in receiver determination

    Hi all, I have a SAP Business system that is configured in XI and an IDoc that comes from the SAP Business System. Already there is a scenario with the SAP BS and IDoc. Now I want a new scenario with the same BS and IDoc but a different receiver syst

  • Tracking AR credit memo to AP invoices..

    Hi Guys, can anyone help me in getting invoices generated in AP against credit memo applied in AR. Thanks In Advance Reju