How to design a browser-like swing app ?

I'm about to write a browser-like application. There is a login screen and there are multiple windows much like these old web browser before they got tabs.
- Should I extend JFrame and implement Runnable or shall I extend Thread and handle the JFrame inside ?
- Should I put the class with generates the main window(s) inside another class which handles the number of threads and the login ?
- Where should I put the database access ? (opening and closure of the database link ?)
- Are there any patterns for this ?

- Should I extend JFrame and implement Runnable or shall I extend Thread and handle the JFrame inside ?You should never extend Thread, IMO. Better to implement Runnable.
The larger question is: Why are you making your class a JFrame and a Runnable? Where's the MVC separation here? The Runnable should be the Controller. The JFrame is View. They should be separate.
- Should I put the class with generates the main window(s) inside another class which handles the
number of threads and the login ?I think this is what I'd call the Controller.
- Where should I put the database access ? (opening and closure of the database link ?)A separate object that the Controller instantiates and invokes should handle database access.
- Are there any patterns for this ?I think MVC is pertinent, among others.

Similar Messages

  • [solved] How to set default browser for qt apps ?

    hi ,
    I'm running a LXDE session and I can't figure out how to set opera as a default browser in qt apps . they default to firefox .
    Any ideas ?
    Last edited by Nezmer (2008-11-21 11:37:52)

    grep wrote:
    http://kb.mozillazine.org/Setting_Your_Default_Browser
    I read this guide before .
    The DE I'm running is LXDE and the apps are pure qt4 .
    how can this guide be helpful ?
    Last edited by Nezmer (2008-11-16 19:06:23)

  • How to design simple person like this image(attached) using illustrator ??

    hi ,
    i want any one help me and tell me steps to design simple person like this using illustrator :

    hello,
    thanks ,

  • How can we implement view like Photo Apps in iphone

    Hi,
    I have to create one view and have to put images on view like Photo apps on iphone. I though that we can use UITableView but in iphone table view doesn't have column so i think that we can't do like this way.
    Is there any other way to do like this,
    Thanks.

    is there anyone know about this problem?

  • How to write initial installer for swing app

    Hi,
    can anyone out there help me in writing the installer for an swing application which involves dowloading jars, external jars(third party) and some data files like xml etc..
    how should i write the starting installer file for my app?
    Thanks in advance
    TSR

    Hi there,
    We found the solution to download the external jars we have kept all the
    external jars seperatly untouched and unsigned by us in a directory in webserver and in the main jnlp we are specifying the extension jnlp file where i am specifying the list of jar files will be downloaded to the client without any hic-ups of security check.
    Note:
    1) In extension jnlp file <security> tag should be omitted.
    2) In main jnlp file the application startup main class should have
    System.setSecurityManager(null); as the first statement in the
    main() method.
    3) Place all the jars which are signed by you in the main jar file
    where you need to put <security> tag with "all-permissions" value.
    Thanks,
    TSR

  • How to create a storyline-like mobile app player

    Hello,
    I was checking out the Storyline elearning dev tool and their free mobile player app. For branding purposes I would like to create my own similar app in html5 and javascript wrapped in something like phonegap for submission to the App Store. I'm enrolled as an apple dev but somewhat of a newbie to javascript. The way I see it there are 3 or 4 things the app does:
    1. When your elearning, stored on a web server, is accessed by URL from the iPads browser it automatically launches the ipad app and lists the module ready for playback. Accessing additional modules launches the app and list them along with previously launched modules.
    2. There is a toggle button to allow the user to download the elearning module for offline viewing if not connected to the Internet.
    3. There is a way to add a module to your favorites (would be nice to be able to remove from favorites or ipad altogether also).
    Those are the three main things I'm needing help with. Being such a "noob" to javascript I'm not sure where to look for the right tutorials/help. Any suggestions?
    Thanks in advance for any help.

    Sure it can be done in AI, so what is actually your question?
    Mylenium

  • How to design a forum like that?

    Hello,
    I'm studying web design and forum development,
    by chance, I visited a webmaster forum http://www.webmastersun.com via google
    I really want to design a forum look like that.
    can you show me ways ? which CMS should I choose ?
    what should I know ?
    Thank much!

    It is designed using vBulletin - http://www.vbulletin.com/.But you can also use following CMS to develop sites like this:-
    Vanilla - http://vanillaforums.org/
    BBPress / BuddyPress - http://bbpress.org/
    Simple Press - http://simple-press.com/
    Mini BB - http://www.minibb.com/
    Phorum - http://www.phorum.org/

  • How to design crystal report like bellow..

    patient Name:-Basuraj Kumbhar
    1) Tablet   ABCD    10
                   At night 1 tablet.
                   Morning 1 tablet.
    2) Capsule  XYAZ  100
                   At night 2 tablet.
                   Morning 2 tablet.
    3) Syrup  JKLM   100ml
                   At night 2 spoon.
    here Tablet,Capsule,Syrup are type of medicine, ABCD,XYAZ,JKLM are name of medicine and 10,100,100ml are medicine quantity.
    I want to create report like this.
    How can create the like this.
    Thanks in advance....

    Hi Basuraj,
    Create report using below groups :
    First group on PatientName
    Second Group on MedicineType
    Now place MedicineName & TotalQuantity on second group header
    Place MedicineTime & TabletEatingQuantity on Detail section and suppress rest of the sections.
    Try to move your field positions to get better formatting.
    -Sastry

  • Browser in swing application without JEditorPane

    Hi,
    We are developing a free software for the school
    children.
    In our application, we want to display HTML file into
    swing frame. So we are using class JEditorPane.
    JEditorPane displays the output like a browser but it
    distrubs the alignment of text and image. Even in java
    docs they have accepted it.
    Do you know how to get proper browser in swing to
    display the HTML contents ? I mean how to render HTML
    in swing?
    The matter is bit urgent for us.
    Waiting for the early reply.
    regards,
    Anand Kulkarni

    Take a look at the JDIC project:
    https://jdic.dev.java.net/
    Then take a look at the Browser demo near the bottom of the page.
    JDIC is a project by Sun to get closer ties to the native system. The Browser portion of the project lets you embed IE in a Swing app.

  • Browser Like Application

    Hi Everyone,
    I am going to create a browser-like application in Java. This application can read and render html file. Links provided in the html file is an information to any application and if click, it launches the specified application.
    At first, I created an Active-X control and a sample html file that uses this active-X control. Specified in the PARAM of the OBJECT tag is the application path as well as the application exe file. So when the Active-X control is clicked,
    it launches the specified application (set in the PARAM). But my manager told me not to use any browser but to create my own browser in Java.
    Does anyone has any idea how to implement a browser like application? I may be using DTD to create a set of properties like the OBJECT tag. Any help is greatly appreciated.
    Thank you very much,
    Ferdinand

    hi,
    I am just giving a code written in swings for simple web browser.This may not have much features but it is functional. Hope it would help you.
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.net.*;
    import java.io.*;
    /** Very simplistic "Web browser" using Swing. Supply a URL on the
    * command line to see it initially, and to set the destination
    * of the "home" button.
    public class Browser extends JFrame implements HyperlinkListener,
    ActionListener {
    public static void main(String[] args) {
    if (args.length == 0)
    new Browser("http://www.yahoo.com");
    else
    new Browser(args[0]);
    private JIconButton homeButton;
    private JTextField urlField;
    private JEditorPane htmlPane;
    private String initialURL;
    public Browser(String initialURL) {
    super("Simple Swing Browser");
    this.initialURL = initialURL;
    // addWindowListener(new ExitListener());
    // WindowUtilities.setNativeLookAndFeel();
    JPanel topPanel = new JPanel();
    topPanel.setBackground(Color.lightGray);
    homeButton = new JIconButton("home.gif");
    homeButton.addActionListener(this);
    JLabel urlLabel = new JLabel("URL:");
    urlField = new JTextField(30);
    urlField.setText(initialURL);
    urlField.addActionListener(this);
    topPanel.add(homeButton);
    topPanel.add(urlLabel);
    topPanel.add(urlField);
    getContentPane().add(topPanel, BorderLayout.NORTH);
    try {
    htmlPane = new JEditorPane(initialURL);
    htmlPane.setEditable(false);
    htmlPane.addHyperlinkListener(this);
    JScrollPane scrollPane = new JScrollPane(htmlPane);
    getContentPane().add(scrollPane, BorderLayout.CENTER);
    } catch(IOException ioe) {
    warnUser("Can't build HTML pane for " + initialURL
    + ": " + ioe);
    Dimension screenSize = getToolkit().getScreenSize();
    int width = screenSize.width * 8 / 10;
    int height = screenSize.height * 8 / 10;
    setBounds(width/8, height/8, width, height);
    setVisible(true);
    public void actionPerformed(ActionEvent event) {
    String url;
    if (event.getSource() == urlField)
    url = urlField.getText();
    else // Clicked "home" button instead of entering URL
    url = initialURL;
    try {
    htmlPane.setPage(new URL(url));
    urlField.setText(url);
    } catch(IOException ioe) {
    warnUser("Can't follow link to " + url + ": " + ioe);
    public void hyperlinkUpdate(HyperlinkEvent event) {
    if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
    try {
    htmlPane.setPage(event.getURL());
    urlField.setText(event.getURL().toExternalForm());
    } catch(IOException ioe) {
    warnUser("Can't follow link to "
    + event.getURL().toExternalForm() + ": " + ioe);
    private void warnUser(String message) {
    JOptionPane.showMessageDialog(this, message, "Error",
    JOptionPane.ERROR_MESSAGE);
    import javax.swing.*;
    public class JIconButton extends JButton {
    public JIconButton(String file) {
    super(new ImageIcon(file));
    setContentAreaFilled(false);
    setBorderPainted(false);
    setFocusPainted(false);
    Bye.
    -Dani

  • How to create printable report from a swing app.

    Hi,
    I have googled quite a bit and have searched the forum extensively but haven't found answers to my questions.
    I have a small swing based application (that uses jtextfields, jbuttons, jlist, etc) that collects information from user
    and stores in some variables; which are like strings, integers, hashmap, etc.
    Now this information is to be formatted and is to be printed as a report.
    Formatted as in, some part of the collected text is to be printed in certain font and other in different color and so on.
    Also the report is to be printed on a paper leaving some space at left and at the top. That means margins need to be set.
    And before all info is to be sent to printer I need to display this information in some report viewer (preview).
    How can I format certain text and set margins? (Is there some Document kind of api which allows me to set margins, change font of certain text?)
    How should I display this text / information as a print preview? (Should I use jeditorpane / jtextpane ?)
    How should I send all the information to the printer? (What java api should be used for printing?)
    The data entered by the user is not saved / persisted to any database. It's to be sent to the printer after submit button is pressed on the swing app.
    Since there is no database I couldn't use jasper-reports.
    Following are links to all threads (not useful) I found when I searched for swing / print / report in the forum :
    http://forums.sun.com/thread.jspa?forumID=331&threadID=225351
    http://forums.sun.com/thread.jspa?forumID=57&threadID=576758
    http://forums.sun.com/thread.jspa?forumID=57&threadID=570629
    http://forums.sun.com/thread.jspa?forumID=1&threadID=489905
    http://forums.sun.com/thread.jspa?forumID=57&threadID=571093
    http://forums.sun.com/thread.jspa?forumID=257&threadID=138450
    http://forums.sun.com/thread.jspa?forumID=57&threadID=583150
    http://forums.sun.com/thread.jspa?forumID=57&threadID=5399572
    http://forums.sun.com/thread.jspa?forumID=57&threadID=579619
    http://forums.sun.com/thread.jspa?forumID=57&threadID=593199
    Help would be much appreciated.

    alan_mehio wrote:
    The simplest thing to do in your case is to load the file content into the JTextArea
    then to create the header and the footer if there is any from java.text.MessageFormat
    then you invoke the print method on the JTextArea instance object> Just let me know if you are face any furrher problem
    Alan Mehio,
    I have been able to set margins and get the printout just the way I want it (after some experiments / trial & error).
    But the problem is, parameters to paper.setImageableArea() are hard coded as in the example code below :
            System.out.println("print?");
            PrinterJob printJob = PrinterJob.getPrinterJob();
            if (printJob.printDialog()) {
                PageFormat pf = printJob.defaultPage();
                Paper paper = pf.getPaper();
                paper.setSize(8.5 * 72, 11 * 72);
                System.out.println("paper width : " + paper.getWidth());// expecting 612
                System.out.println("paper height : " + paper.getHeight());// expecting 792
                System.out.println("ImageableHeight : " + paper.getImageableHeight());
                System.out.println("imageable width : " + paper.getImageableWidth());
                System.out.println("ImageableX : " + paper.getImageableX());
                System.out.println("Imageable y : " + paper.getImageableY());
                //paper.setImageableArea(108, 144, paper.getWidth() - 108, paper.getHeight() - 144);
                paper.setImageableArea(222, 244, paper.getWidth() - 222, paper.getHeight() - 244);
                pf.setPaper(paper);
                printJob.setPrintable(jTextArea1.getPrintable(null, null), pf);
                try {
                    printJob.print();
                } catch (Exception ex) {
                    System.out.println("exception while printing...");
                    ex.printStackTrace();
            }In my case the left margin should be 1.5 inches (38.1mm) and top margin should be 2 inches (50.8 mm)
    Considering 72dpi printer for a A4 size page (8.5in X 11in), the parameters to paper.setImageableArea() should be
    (108, 144, paper.getWidth() - 108, paper.getHeight() - 144);
    But the printout leaves only 1inch for top and left margins.
    Here are o/p lines for method-call with above said params :
    paper width : 612.0
    paper height : 792.0
    ImageableHeight : 648.0
    imageable width : 468.0
    ImageableX : 72.0
    Imageable y : 72.0
    When I pass the following values I get text printed with desired margins on the paper but the above printlns remain exactly the same!
    paper.setImageableArea(222.4, 244, paper.getWidth() - 222.4, paper.getHeight() - 244);
    Although I have been able to achieve what I wanted to without using 3rd party libraries,
    I feel this hard coding of values isn't a good idea and leaves a doubt whether this will work on other systems with different printers.
    My question is, how to get these numbers correct every time? Is there a formula for obtaining these numbers?
    Also formatting of certain part of to-print text is something that is yet to be figured out.
    Thanks.

  • How Do I Wrap Text Like the iOS Camera App?

    Hello. I am in yearbook, and I have been challenged with designing the cover of the yearbook, and I have been having a few problems along the way. One of these problems is to wrap text. Specifically, I'm stuck on how I would wrap text like the iOS camera app on the bottom of the screen. The words seem like they are wrap around a 3D object to give it that effect, but I can't really tell. If anyone can help me, it would be greatly appreciated.

    JJMack wrote:
    There is a big difference between being a casual user than real work or development. I own a iPod its a great MP3 player and a device I can display my pictures on out of my pocket. I'll even Facetime my kids at time to see my grand kids or help fix something.  My wife has a mini iPad for quick internet access and quire music and uses her iPod to entertain our two year old grandson with games.   She uses a Canon 1D mark 4 and I a Cannon 1D mark II.  The only use the iPad and iPod cameras get is Facetime. No iOS apps are use to work on images  they have no value when you have Photoshop. The iPod is better for displaying image then the iPad mini it has a 3:2 aspect ratio display and travels better the the mini iPad which has a 4:3 aspect ratio display.  I also crop image for display on wall mounted HDTV. The iPad is better for casual internet access then the iPod. All our kids have iPhones and they all use computers either Mac or PC for work and internet access.  When you have a Unix or Windows why would you want to touch an iOS device for work or serious internet access.  Apple mobile devices are convenient for casual use and grand kids don't get that dirty finger painting on them as they do using real paint. Nothing of real value is maintained on an iOS device.
    Well...there's Photoshop Touch and Photoshop Mix as well as Lightroom Mobile. It could be argued that they're don't exactly mirror their desktop cousins, yes, but they weren't meant to be. They were meant as extensions to the desktop experience.  (e.g., Lightroom Mobile lets one work with the RAW images they have in their Lightroom desktop collections.)
    The more powerful Windows tablets can run Photoshop desktop (like Photoshop CC) too.
    @bluebocat: Are you looking for text with a perspective? Like it has a vanishing point? As if it was turned in a certain direction in 3D space?

  • HT1222 When there is a browser update like this Safari 5.1.4, Is there an article that instructs one the ideal way to update to a newer version of a browser like this newer version of Safari?  Is it best to close Safari and all other apps, restart...

    When there is an update to a newer version of a browser like this update to Safari 5.1.4, is there an article that goes over the best way to update to a newer version of a browser that one knows of? Is it best to close all apps, install the update, turn the computer off, turn it on and hold down the shift key until the gear and progress bar are showing, when this is finished, do a restart of the computer.  I hav always wondered the best way (if there is a best way) to update to a newer version of a browser so you avoid potential problems.  Is there a Support Article that goes over installing and updating to a newer version of one's browser, in this case Safari?
    Thanks.

    The following may or may not apply to Lion:
    Repairing permissions is important, and should always be carried out both before and after any software installation or update.
    Go to Disk Utility (this is in your Utilities Folder in your Application folder) and click on the icon of your hard disk (not the one with all the numbers).
    In First Aid, click on Repair Permissions.
    This only takes a minute or two in Tiger, but much longer in Later versions of OS X.
    Background information here:
    http://support.apple.com/kb/HT1452?viewlocale=en_US
    and here:
    http://docs.info.apple.com/article.html?artnum=302672
    An article on troubleshooting Permissions can be found here:
    http://support.apple.com/kb/HT2963
    By the way, you can ignore any messages about SUID or ACL file permissions, as explained here:
    http://support.apple.com/kb/TS1448?
    If you were having any serious problems with your Mac you might as well complete the exercise by repairing your hard disk as well. You cannot do this from the same start-up disk. Reboot from your install disk (holding down the C key). Once it opens, select your language, and then go to Disk Utility from the Utilities menu. Select your hard disk as before and click Repair.
    Once that is complete reboot again from your usual start-up disk.
    More useful reading here:
    Resolve startup issues and perform disk maintenance with Disk Utility and fsck
    http://support.apple.com/kb/TS1417?viewlocale=en_US
    For a full description of how to resolve Disk, Permission and Cache Corruption, you should read this FAQ from the X Lab:
    http://www.thexlab.com/faqs/repairprocess.html
    Apple's advice on general maintenance:
    http://support.apple.com/kb/HT1147?viewlocale=en_US

  • How to design a GUI Python app properly?

    Hi guys. As motivation to actually learn Python, I want to carry out a fairly simple application that's been brewing in my head for months; a "game manager" that a gamer can use to keep track of the games he owns, the games he's beaten, and any specific challenges he's completed in said games.
    The problem is that I can't seem to wrap my head around Python. I look through its docs to solve problems but I almost always end up lost. I come from PHP, which is supposedly sloppy, but it's also very easy to get almost anything done quickly. In my frustration, I proved that I could get more progress in 15 minutes in PHP than I had gotten in 2 hours in Python. I was right, but I know that PHP isn't the right tool for the job. I want to make an actual desktop application that relies on an sqlite db.
    With my frivolous backstory out of the way, could anyone offer any enlightenment on Python? I've tried the tutorials, I've tried the docs... where can I go to learn not only how to code my app, but how to design it? Design is more important than syntax, imo, because it relies on concepts which form the foundation of whatever app you're building.
    I can post an overview of how I want the app to behave, if that would help others advise me on how to build it in Python. I'd really like to pick the language up, but it's being anything but "easy to learn".

    Are you sure you've read the helpful tutorial? If you can't grasp it, perhaps PHP has finally penetrated the shell of coding sense surrounding your brain and started eating. (I used to be close to that point. Now I believe Python is god.)
    Oh, and never start with something as big as a full-blown graphical application. Trust me, it is never as simple as it first seems when you conceive the idea. Start with small, one-file utilities and work your way up from there. Consider downloading the full documentation so you always have a local copy.
    And remember: If your code seems ugly, it probably is. There is almost always a better way in Python.
    Last edited by Peasantoid (2010-02-06 05:14:43)

  • How to design socket client-server app for 2-way communication

    Hi, I am writing a client-server application. I have a single server and many clients. Each client will need the ability to send information to the server at any time. The server will also need the ability to send information to a client at any time. Its this second part that I am not sure how to design. Would I need to create a SocketServer on each client to accept incoming messages, or is there a better way? Thanks

    scranchdaddy wrote:
    Don't my requirements sound a lot like an IM application, where a chat server might need to send a message to a chat client at any time?Not really. If that is what you are designing
    in my opinion one could easily be forgiven for thinking you were deliberately obfuscating your goal...
    How does the server know where the client is? Does it know the IP address of the client?I would imagine the server would contain a directory of IPs? I'm not sure.
    What happens if the client is not running?Then I guess the message would not get delivered.
    What happens if the client is behind a firewall that does not allow incoming connections?How do IM chat clients work? How have people solved this in the past?Typically the server would only care about clients currently connected to the server.
    Maybe you should re-think your design. I don't really have a design, just requirements, that's why I'm writing this post.Your subject says "+How to *design* socket client-server app for 2-way communication+".
    Are you saying you expect someone else to do the design for you?

Maybe you are looking for

  • Bin fitting with a counter using both analytics and model clause.

    11.2.0.3 This falls under 'just want to figure out how to do it'. Its not critical for work. I want to try to see if its possible to do this with both analytic function and with a model clause. Just to see if its possible. It has been stumping me. I

  • How to check the analysis of material determination in sales order

    hi, We are trying to create a sale order with material determination. Material determination analysis is on. After  switching this on  while adding a new line item, in an existing sales order, we are able to do analysis as the system itself takes us

  • VOFM routine - NO frame work

    Hi all,     By posting an inbound idoc we are creatin a purchase order and post goods issue for the purchase order.     When a purchase order is getting created an entry is getting updated in NAST table which trigger the idoc ORDERS05.     This idoc

  • Help: iMac logs on automatically to BSD/Darwin commmand line

    Hi folks, I got a wee little problem with my iMac G5 running OS 10.3.9. I left the computer for a while last night to download and install the system updates (ipod updater and the recent Security update). Later my girlfriend went into the room and sa

  • Does anyone have a VI for calculating orifice flow using AGA or ASME methonds

    I'm taking data from an orifice flow meter including pressure, temperature, and orifice DP. Has anyone coded the AGA 3 or AGA 8 or ASME orifice flow calculations into a VI. I'm using LV 7.1. Thanks