Using extends in Java SWING GUI

i have designed this login page and this other page for checking marks.
The idea is, if the person who logs on is the particular unique user, he will be able to check the marks of that subject, If other person who logs on and try to check the mark, he will be given a message instead.
So in order to retrieve the person's username n check to see if he can be authorized, i have to retrieve the textfield results from the login page and then implemented it into my method in the mark's page. so i just extends the Login page.
I did the dispose method n everything, and now
a) when i logged on as that user, my marks page dioesn't come out as planned, instead a login page comes out
b) when i run the marks page , the login page and my mark's page come out at the same time ?
why is this so ?

The reason your login page is showing up on your next panel is because you extend it. When you extend a class you inherit everything about that class including the gui. You should just make 2 seperate classes and pass in the values you want either through the constructor or make some methods to pass in the value. So what you should do is make your login class take the username and password then validate it. If the user has entered a valid username/password then pass the next class the username.Here is some suedo code I'm not going to write out everything because it would take too long.class Login extends JDialog
   private String userName;
   private String passWord;
   public Login()
       // add your textfields and other gui components
      // take in the username and password
      // verify them in some other method
      if(this.validateUser() == true)
          MarksPanel markPanel = new MarksPanel(username);
   public boolean validateUser()
        // some code to check username and password
class MarksPanel extends JPanel
   public MarksPanel(String Username)
       // now you have the username in a seprate class and
       // since you don't extend Login here you won't see the same
      // Login panel on top of this

Similar Messages

  • Loading large files in Java Swing GUI

    Hello Everyone!
    I am trying to load large files(more then 70 MB of xml text) in a Java Swing GUI. I tried several approaches,
    1)Byte based loading whith a loop similar to
    pane.setText("");
                 InputStream file_reader = new BufferedInputStream(new FileInputStream
                           (file));
                 int BUFFER_SIZE = 4096;
                 byte[] buffer = new byte[BUFFER_SIZE];
                 int bytesRead;
                 String line;
                 while ((bytesRead = file_reader.read(buffer, 0, BUFFER_SIZE)) != -1)
                      line = new String(buffer, 0, bytesRead);
                      pane.append(line);
                 }But this is gives me unacceptable response times for large files and runs out of Java Heap memory.
    2) I read in several places that I could load only small chunks of the file at a time and when the user scrolls upwards or downwards the next/previous chunk is loaded , to achieve this I am guessing extensive manipulation for the ScrollBar in the JScrollPane will be needed or adding an external JScrollBar perhaps? Can anyone provide sample code for that approach? (Putting in mind that I am writting code for an editor so I will be needing to interact via clicks and mouse wheel roatation and keyboard buttons and so on...)
    If anyone can help me, post sample code or point me to useful links that deal with this issue or with writting code for editors in general I would be very grateful.
    Thank you in advance.

    Hi,
    I'm replying to your question from another thread.
    To handle large files I used the new IO libary. I'm trying to remember off the top of my head but the classes involved were the RandomAccessFile, FileChannel and MappedByteBuffer. The MappedByteBuffer was the best way for me to read and write to the file.
    When opening the file I had to scan through the contents of the file using a swing worker thread and progress monitor. Whilst doing this I indexed the file into managable chunks. I also created a cache to further optimise file access.
    In all it worked really well and I was suprised by the performance of the new IO libraries. I remember loading 1GB files and whilst having to wait a few seconds to perform the indexing you wouldn't know that the data for the JList was being retrieved from a file whilst the application was running.
    Good Luck,
    Martin.

  • How to run Java Swing GUI on embedded ARM Linux platform?

    The object is:
    A touch panel, running Java Swing GUI, with a 25 fps 320x320 mono JPEG image animation and other control buttons.
    What I have now:
    A Developing Board with: ARM926 CPU at 266MHz, 128M RAM, 64M ROM, ported with arm-linux and MiniGUI.
    My plan is:
    1. installing a X-window system to the platform, discarding the MiniGUI.
    2. install j2re-1.3.1-RC1-linux-arm.tar.bz2 to the platform.
    3. run my program developed on a PC.
    My concerns are:
    1. Both X and Java is resource consuming, can a 266MHz ARM CPU meet my requirement?
    2. Is the X a must to run Java Swing GUI? If yes, how can I configure it to minimize the footprint, I mean, install only necessary modules.
    3. Can J2RE 1.3.1, the only port for arm linux, support Swing classes?
    4. Are there other options, such as CDC + PP(AGUI?), how to do it?
    Thanks alot!

    3. Can J2RE 1.3.1, the only port for arm linux, support Swing classes?I'm not entirely sure from your post: is this a J2SE port? If so it will support Swing, but probably needs Qt.

  • Java Swing GUI Button Image

    Hi, I really need help with this one, I have tried many things and looked at many pages for this but to no avail as of yet.
    I have a Swing GUI in which I want to display an image. The way I am displaying it at the moment is as a button icon as I do not need to be able to alter the images. I can also use the button functionality as displaying something when the image is clicked. So I have an array of image paths which are accesed to load an image into the button and a "Next" button to change the image as required.
    My problem is that when I load an image into the button it moves from it's original location. When there is no image displayed the button is where I want it to be, but when I load an image it moves, this cannot happen. Any ideas.
    Also, when I am trying to click thru the array of images, it starts at the 1st image in the array but then skips to the last image in the array. Here is the code for that.
    // Handle events that arise from the "Next" button being clicked
    private void jButton5MouseClicked(java.awt.event.MouseEvent evt) {
    if (jComboBox1.getSelectedIndex() == 1)
         for (int i = 1; i < juniorImageIndex.length; i++)
         jButton8.setIcon(new javax.swing.ImageIcon(juniorImageIndex));
    else if (jComboBox1.getSelectedIndex() == 2)
         for (int i = 1; i < seniorImageIndex.length; i++)
         jButton8.setIcon(new javax.swing.ImageIcon(seniorImageIndex[i]));
    juniorImageIndex and seniorImageIndex are obviuosly the arrrays with the file paths for the images. The reason I start at index 1 is that I use the 0 index image as the starting image for each part.
    Any help gratefully appreciated, I really hope someone can help, Thanks.

    // Handle events that arise from the "Next" button
    being clicked
    private void
    jButton5MouseClicked(java.awt.event.MouseEvent evt) {
      myImageIndex =(myImageIndex + 1) % imageArray.size();
      resetButtonImage();
    private void resetButtonImage() {
    if (jComboBox1.getSelectedIndex() == 1)
    {//take this out
    //> for (int i = 1; i < juniorImageIndex.length; i++)
    //> {
    jButton8.setIcon(new//> javax.swing.ImageIcon(array[myImageIndex]));
    //> }
    else if (jComboBox1.getSelectedIndex() == 2)
    {//this too
    //> for (int i = 1; i < seniorImageIndex.length; i++)
    //> {
    jButton8.setIcon(new
    javax.swing.ImageIcon(array2[myImageIndex]));//> }

  • How to use java api while java programming especially using javase and java swing?

    i need help for java api for undo, redo, htmleditorkit,editorkit.
    in my project i have to use java swing for desktop application but, i need help for how to implement and how to retrieve java api.
    please reply with example or code..

    i need help for java api for undo, redo, htmleditorkit,editorkit.
    in my project i have to use java swing for desktop application but, i need help for how to implement and how to retrieve java api.
    please reply with example or code..
    You find examples and code by searching the internet, not by using forums.
    Start with The Java Tutorials - it has trails for the bulk of the Java functionality.
    See the trail 'How to Write an Undoable Edit Listener'
    http://docs.oracle.com/javase/tutorial/uiswing/events/undoableeditlistener.html
    You learn by DOING - not by reading. Actually DO the tutorial example and try to understand WHAT it does and HOW it does it.
    Then search for other tutorial trails that are of interest.

  • New help on java swing GUI.....

    k, im new to java. Just started learning a month ago. Anyway, I was wondering how one can link gui together using buttons. For example, when i press enter on a registration gui, it'll take me to the confirmation gui. What's the best way to do this? anyone has any idea or can point me to a website with info. Thanks A lots folks.

    Well, bascially you would add a Button (e.g. "Next" or "Submit") to your Window/Panel (whatever you prefer). This add has an ActionListener assigned which will open up the next Window/Panel.
    Then you define this button to be your default button on that window (check JRootPane.setDefaultButton() for this) so that Enter will fire the button.
    Check the Swing online tutorial for an introduction to Swing and how Buttons (and their associated ActionListener) work.
    Thomas

  • Skins in java swing/gui

    hi!!! i just wanna ask you guys and gals if there is a way for Java GUI to implement a skin, you know, those what we can see in Winamp. That's all. Thanks a lot!!! Have a nice day!!! :-)

    //first make sure you define the image in the class, then override the method
    //defining image
    ImageIcon imageIcon = new ImageIcon("images/background.jpg");
    Image image = imageIcon.getImage();
    //overriding the method that paints the background of the JPanel
    public void paintComponent(Graphics g) {
    super.paintComponent(g); //paint background
    if (image != null) { //there is a picture: draw it
    int height = this.getSize().height;
    int width = this.getSize().width;
    g.drawImage(image,0,0, width, height, this);
    //g.drawImage(image, 0, 0, this); //original image size
    } //end if
    } //end paint

  • Java Swing Help

    Hi, I am currently using a program called JPadPro for my java source codes. I am just beginning to learn java and I have just started on Java Swing GUI codings. My problem is that the program compiles, but it doesn't run. It always give me an error saying
    "Cannot find main method, Program will exit". there is nothing wrong with my source code because I can run somewhere else. I think I didn't configure my Jpadpro correctly. (but anything without GUI does work)
    Thank You for your help :)

    Even though you are running a swing application, you still need a main method just as in non-GUI applications. The main should create an instance of the JFrame at the base of you swing app. A simple example is as follows:
    public class mySwingApp extends JFrame {
    public mySwingApp(String title) {
    super(title);
    // GUI components, layouts, possible listeners here
    public static void main(String[] args) {
    JFrame mainFrame = new mySwingApp("My first swing app");
    mainFrame.setSize(200, 200);
    mainFrame.setVisible(true);
    }Hope this helps some!
    -JBoeing

  • Launching Swing GUI from Oracle Forms Web Based

    Hi there,
    I have oracle forms which call a shell script which initiates the java swing gui. I am using host command to run this script. When I am doing it on unix server everything works fine. Now we want same application on web now i am getting problem. The host command is not working in this case. It can not launch the java gui. Can anybody tell me what will be the nice approach to do it.
    Thanks
    Ranjan

    Hi,
    you'll have to create a Java Bean in Forms that calls the runtime. You can also use webutil, available on otn to call a client side host command.
    Frank

  • Session in java swing??

    Hi friends,
    I need to create session in java swing...
    I have a client running in swing and can access resources in multi-threaded server. I need to validate user using session. But i don't know how to use session.
    User has to login with username & password (authentication verified at server using socket communication).
    If successful the login frame vanishes and other options are displayed. user has a feature that he can send files to other
    user. so i need to use session for security purpose.
    Anyone help me with code
    Edited by: sathya_vn on Apr 20, 2008 5:41 PM

    Anyone help me with the code-----> u got tat wrong..
    I need to know how to use session with java swing. I requested if anyone has such code....
    This is a part of my project .
    Am using MySQL Database to store username and password.
    Cleint side interface has a frame (first frame--frame1) requesting client to provide login information. The login details <username and password> are sent to server. server validates whether the login info are correct or not and return true or false .
    If false the frame1 will show a JOptionPane ... message stating that wrong username or password specified.
    If true i need to create a session and other operations are done after session validation. I am using ssl socket.
    If u want the code then i have post around 300 or more lines..

  • Writing Urdu in java swing component

    Hi firiends,
    I am searching out how to write urdu as input in java swing JTextField. I have searched a lot but still i am unable to get right information. So plz guys help me how i do use urdu on java swing JTextField. i will be higly thankful to you..
    i am waiting your good reponses .
    THANKS
    Sahibzada

    This forum is exclusively for Sun Java Studio Creator. Please post your queries on appropriate forums to have better discussions :
    e.g.
    Swing Forum :
    http://forum.java.sun.com/forum.jspa?forumID=57
    Here are some helpful URLs :
    How to Use Text Areas
    http://java.sun.com/docs/books/tutorial/uiswing/components/textarea.html
    http://java.sun.com/docs/books/tutorial/uiswing/components/textarea.html#contents

  • Unicode characters with accents won't display in Java Swing applications

    I'm using FreeMind (a Java Swing application) and I need to enter classical Greek characters with accent marks. When I type an accented Greek character, FreeMind displays the unaccented character. However, I can type the accented character in MS Word, then copy and paste into FreeMind, the accented character appears.
    One of the FreeMind developers indicated this was a Java Swing issue, not FreeMind, and suggested I test with another Swing application. So, I installed jEdit and got exactly the same results. I can paste an accented character into jEdit, but I cannot type it in directly.
    I'm using Windows Vista with Java 6 Update 22 (build 1.6.0_22-b04). I also tested on a XP Pro box with Java 1.6.0_18-b07 and got the same result.
    One other note: A couple days ago, I was able to type accented Greek characters into FreeMind. But it only worked for a couple days and then the behavior reverted to unaccented characters. It is possible, but I don't recall specifically, that I updated Java during the time and that may indicate a bug in one version of Java but not another.
    Any assistance or guidance would be greatly appreciated!
    Darin

    Walter,
    The link you provided does not appear to describe the Greek Polytonic keyboard. (The page also describes using the "Option" key as the dead key. There is no "Option" key on my keyboard. I'm using a Sony VGN-NS140E purchased in Chicago, i.e. standard physical US keyboard.)
    Please see http://darindavis.net/languages/keyboard_Greek.pdf for a detailed description of how to use the Greek (Polytonic) keyboard in Windows to produce a complete set of accented classical Greek characters. This method works in MS Word and Notepad. I enabled the Greek (Polytonic) keyboard with:
    Windows (Vista) Start > Control Panel > Regional and Language Options > Change Keyboards > General > Add > Greek (Greece) > Greek Polytonic
    A test that will demonstrate whether you can replicate the error is to do the following in both MS Word (or Notepad) and jEdit (or FreeMind):
    1. Enable the Greek Polytonic keyboard
    2. Type "\" then "e" which should produce an epsilon with smooth breathing and grave accent (ἒ)
    When I do this in MS Word or Notepad, I see the epsilon with smooth breathing and grave accent. When I do this in jEdit and FreeMind, I only see an epsilon.
    I recorded a screencast to illustrate the problem: http://www.screencast.com/t/TRKkKQrCgbN
    Actually, this problem is transient. Sometimes FreeMind or jEdit will display accented characters, other times it won't. Ironically, the first time I recorded the above referenced screencast, a few characters in jEdit did appear with accents. A couple minutes later, I re-recorded the screencast and as you can see jEdit did not display the accents. Between the two recordings I literally did nothing other than stop the Jing recording and start a new one. There is another variable at play here and I can't determine what it is. The most likely source seems to be Java since MS Word and Notepad consistently display accent characters.
    Thanks,
    Darin

  • Creating file browser GUI using java swing tree

    Hi all,
    I have some questions which i wish to clarify asap. I am working on a file browser project using java swing. I need to create 2 separate buttons. 1 of them will add a 'folder' while the other button will add a 'file' to the tree when the buttons are clicked once. The sample source code known as 'DynamicTreeDemo' which is found in the java website only has 1 add button which is not what i want. Please help if you know how the program should be written. Thx a lot.
    Regards,

    Sorry, don't know 'DynamicTreeDemo'import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.tree.*;
    import java.io.File;
    public class Test extends JFrame {
      JTree jt = new JTree();
      DefaultTreeModel dtm = (DefaultTreeModel)jt.getModel();
      JButton newDir = new JButton("new Dir"), newFile = new JButton("new File");
      public Test() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container content = getContentPane();
        newDir.setEnabled(false);
        newFile.setEnabled(false);
        jt.setShowsRootHandles(true);
        content.add(new JScrollPane(jt), BorderLayout.CENTER);
        File c = new File("C:\\temp");
        DefaultMutableTreeNode root = new DefaultMutableTreeNode(c);
        dtm.setRoot(root);
        addChildren(root);
        jt.addTreeSelectionListener(new TreeSelectionListener() {
          public void valueChanged(TreeSelectionEvent tse) { select(tse) ; }
        JPanel jp = new JPanel();
        content.add(jp, BorderLayout.SOUTH);
        jp.add(newDir);
        jp.add(newFile);
        newDir.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            TreePath tp = jt.getSelectionPath();
            if (tp!=null) {
              DefaultMutableTreeNode dmtn = (DefaultMutableTreeNode)tp.getLastPathComponent();
              File newFile = new File((File)dmtn.getUserObject(),"foo");
              if (newFile.mkdir()) {
                dmtn.add(new DefaultMutableTreeNode(newFile));
                dtm.nodeStructureChanged(dmtn);
              } else System.out.println("No Dir");
        newFile.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            TreePath tp = jt.getSelectionPath();
            if (tp!=null) {
              DefaultMutableTreeNode dmtn = (DefaultMutableTreeNode)tp.getLastPathComponent();
              File newFile = new File((File)dmtn.getUserObject(),"foo.txt");
              try {
                if (newFile.createNewFile()) {
                  dmtn.add(new DefaultMutableTreeNode(newFile));
                  dtm.nodeStructureChanged(dmtn);
                } else System.out.println("No File");
              catch (java.io.IOException ioe) { ioe.printStackTrace(); }
        setSize(300, 300);
        setVisible(true);
      void select(TreeSelectionEvent tse) {
        TreePath tp = jt.getSelectionPath();
        newDir.setEnabled(false);
        newFile.setEnabled(false);
        if (tp!=null) {
          DefaultMutableTreeNode dmtn = (DefaultMutableTreeNode)tp.getLastPathComponent();
          File f = (File)dmtn.getUserObject();
          if (f.isDirectory()) {
            newDir.setEnabled(true);
            newFile.setEnabled(true);
      void addChildren(DefaultMutableTreeNode parent) {
        File parentFile = (File)parent.getUserObject();
        File[] children = parentFile.listFiles();
        for (int i=0; i<children.length; i++) {
          DefaultMutableTreeNode child = new DefaultMutableTreeNode(children);
    parent.add(child);
    if (children[i].isDirectory()) addChildren(child);
    public static void main(String[] args) { new Test(); }

  • Java Swing/AWT and FX is so old school! Give me HTML and CSS for GUI!

    Dear Java,
    I am a seasoned programmer and I feel it's time JAVA implements a GUI system where it uses HTML and CSS for the GUI. For the love of god just look at the interfaces you can make using HTML and CSS alone. I am a big fan of Java Swing and the recent GUI designer for FX is quite cool. But they are just not as simple as HTML and CSS. And JavaFX has some interesting requirements for the graphics.
    I know it is possible to use JavaFX and implement the WebView/WebDriver and make it load a HTML page, etc... but why go through all the trouble?
    Just imagine... if you make Java where it has powerful back-end to do what it does best and the HTML/CSS powered GUI on the front-end. It will make the lives of many developers much much easier.
    I am not sure whether a Swing designed GUI will be faster than a HTML designed GUI... but if you look at a traditional browser and how fast it renders HTML/CSS, I am sure if Java had a native Form where it uses HTML and CSS to render the GUI, Java will make the dreams of many programmers a reality.
    Make it happen!!!!

    Check this i solve problem just now using this
    https://wiki.archlinux.org/index.php/Ja … ow_Manager

  • How to create a semi circuler slider using java swing or awt

    I am trying to create a Jslider like thing but in semicirculer shape. Thanks in advance for providing any help.

    Is it possible to create such UI in java swing?Just to further illustrate, Swing only provides the raw foundation you need to be able to build a GUI. With the stock components you can create static user interfaces with standard controls. If you want to go further, you need to either find a component that somebody else already wrote, or you go into custom painting as previous posters suggested. To do an animating component for example, you would need all the frames as BufferedImage objects and you would combine custom painting with a Swing timer to update the displayed frame at a specified framerate.
    if you search for "java swing animation" using google, I'm sure you can find the examples you need. And here is the trail about swing timers:
    http://java.sun.com/docs/books/tutorial/uiswing/misc/timer.html

Maybe you are looking for

  • Create Simple Printable SQL Reports in APEX 3.2 Without a Print Server

    Oracle Apex 3.2 Oracle 11g OHS I thought I'd post an answer on how to get a printable SQL report in Oracle Apex without having to configure a print server. I'm sure that similar things have been posted in various other places, but I found the documen

  • Can't insert custom HTML or change social widgets to update Phone layout

    MUSE 2014.2.1.10, CL 787362  on  Windows 8.1  i7 processor 24 GB RAM Anytime I try to insert custom HTML in the phone layout pages I get a window that says webpage could not be found  in a window that is too wide for the screen size and can't be re-s

  • Website elements out of alignment

    I have a new computer, new install of firefox, there are some webpages that do not have the correct alignment. As if there is a compatibility issue. I'm a project manager for a web development company, and I have some websites where the alignment of

  • How to convert date which is coming from a file

    Hi All, I am reading the content from the file in which date is also one field, but i am while inserting into the database i'm getting an exception because it is not able to insert into the database because the database date format is different from

  • AD Trusted Recon - Disabling user deletes him in OIM

    Hello, I'm having trouble changing a user state to 'Disabled' in OIM when I disable him in the Active Directory. Has anyone ever encountered this problem and know how to solve it? Thanks in advance