How to make buttons of Strings from a db

I have this program "SokGenre" which connects to a db and take out some Strings and put them in a vector.
Now I would like to have an applet with Buttons and each button shall have text from one of the strings from the db.
Any tips? How shall I do?
How do I "link" the programs to eachother? Im a newbie....
import java.sql.*;
import java.util.*;
class SokGenre {
     public static void main(String[] args) {
          Connection conn = null;
     try {
          Class.forName("org.gjt.mm.mysql.Driver");
     conn = DriverManager.getConnection( "jdbc:mysql://localhost/MyDb?user=root&password=" );
     Statement stmt = conn.createStatement();
     String query = "SELECT Gnamn FROM genre WHERE Gover='-'ORDER BY Gama";
     ResultSet rs = stmt.executeQuery(query);
     Vector vektor = new Vector();
     while (rs.next()){
                    vektor.addElement(rs.getString("Gnamn"));
          System.out.println("Vektor: "+vektor);
     catch(Exception e) {e.printStackTrace(System.err);}
     finally {
          try {conn.close();}
          catch(Exception e) {e.printStackTrace(System.err);}

Here's some info on Applets.
http://java.sun.com/docs/books/tutorial/applet/index.html
You can create a Button using a String so that shouldn't be any problem. You can add Buttons to an Applet. You will have to learn about ActionListeners if you want your program to do something when a Button is clicked.
The code you have might be included in the Applet class that you create. Or you might have a button to "Retrieve" the data from the db and clicking the button causes the ActionListener to call the SokGenre main method.

Similar Messages

  • Hello Anybody, I have a question. Can any of you please suggest me how to make an xml file from the database table with all the rows? Note:- I am having the XSD Schema file and the resulted XML file should be in that XSD format only.

    Hello Anybody, I have a question. Can any of you please suggest me how to make an xml file from the database table with all the records?
    Note:- I am having the XSD Schema file and the resulted XML file should be in that XSD format only.

    The Oracle documentation has a good overview of the options available
    Generating XML Data from the Database
    Without knowing your version, I just picked 11.2, so you made need to look for that chapter in the documentation for your version to find applicable information.
    You can also find some information in XML DB FAQ

  • How to make buttons work in Interactive Adobe Forms

    Hi Experts,
    I am new to interactive form. Though i have worked in normal/non-Interactive form, i do not know how to make buttons work in interactive adobe forms using ABAP  (I don't know JAVA). Can any one help me out and walk me through to how to code in ABAP to make buttons work.
    Kind Regards,
    Sharat.

    Please refer to my earlier post ... You will get an idea
    Please refer to the below thread for detail solution
    Sample Interactive form example ?....urgent...
    Cheers
    Satya

  • How to make a jar file from a java file?

    how to make a jar file from a java file, is there any one tht can help me thank you;

    You can study this.
    http://java.sun.com/docs/books/tutorial/jar/basics/index.html

  • How to make a conference call from an iPhone

    How to make a conference call from an iPhone

    http://manuals.info.apple.com/en_US/iphone_user_guide.pdf user manual

  • How do I Display a string from a servlet into a JSP Page???? NEED HELP!!!!

    Hi guys,
    How do I Display a string from a servlet into a JSP Page...
    Ive tried so many bloody things!.....
    Simply.
    I get text from JSP. The servlet does what ever it does to the string.
    Now. Ive create sessions and bean things,.... how the hell do I display it in a text box... I can display on the screen.. but not in the text box.!!!
    please help!!!

    hmmm, I dont really like using JSP programming, u should be using JAVA..
    the way to do it is:
    Call and cast to the bean like this:
    <%@ page import="beans.*" %>
    <% //cast to bean get request create object
    userNameBean u= (userNameBean) request.getSession().getAttribute("userNameBean");
    then... all you do is call it like this:
    <input type="text" name="firstName" value="<%= u != null? u.getFirstName(): "" %>">
    this is the real programmers way,,,
    chet.~

  • How to make a ARCH package from local folder?

    hello ARCH lovers
    I can't seem to figure out how to make a installable
    package from a folder on my desktop?
    Coming from Slackware; the procedure would be simple enough just issuing
    "makepkg /root/pkgname.txz"
    Now; how would I do the same in ARCH?
    I know about PKGBUILD, etc but there is no source or any url's
    I just need to make it into a .pkg.tar.xz
    The package is my "kernel-live-kit" for both x86 and x86_64 versions of arch
    enabling one to remaster there existing install into a livecd/usb, etc
    The kernel itself is kernel26-zen from AUR
    http://aur.archlinux.org/packages.php?ID=30330
    however; mine is quite different and also includes all components to make the livecd using modified linux-live-6.3.0
    scripts and special stuff
    The pkg includes a premade kernel with modules and full kernel source
    The resulting live media is similar to my nFluxOS builds
    http://multidistro.com/
    As I will be releasing the new four horsemen of nFluxOS today; I also made 4 Kernel pkg's for the arch and slack versions
    Those will be for x86/x86_64 versions for both arch and slackware
    I did this in lieu of creating a quartet of x86_64 versions of nFluxOS; as that would up the number of versions to 8
    and I would then have to maintain 8 distro's instead of 4.
    I made a testing version of ARCH x86_64 live
    http://www.linuxquestions.org/questions … ost4017796
    so, I really need to make the ARCH x86 and x86_64 kernel kits into installable pkg's because there are many symlinks that would get corrupted if I just tarred it and then the end user untars it and copies it somewhere it would mess up the symlinks.
    as I said, in slackware I do makepkg and it creates a script named "doinst.sh" that makes all the symlinks, etc
    so, any help appreciated!
    thanks

    You can read a simple introduction to using the ABS here.
    By the way, it's not hard. Out of all the distributions I've used, Arch Linux is the only one I've figured out how to make packages for.

  • Not clear how to make button iconic

    i am not clear how to make button in forms iconic and where that icons come.where i have to kept that specific icon.what is the path of the directory where to keep image

    Just to add a little on what Gerd said, for web deployed forms your icon files must be of type .gif
    You cannot have .ico files in web deployed forms
    For more information on Web deployed icons read [url http://www.oracle.com/technology/products/forms/pdf/webicons.pdf]Webicons
    If you're using client/server technology, you also specify the UI_ICON registry and put your icons under that directory. In client server you can use .ico files
    Tony

  • Help!! i dont know how to make use of token from string tokenizer :(

    Hi,
    I would like to ask how to manipulate the token that are taken from string tokenizer. For example :
    input = a b 1 f 986
    supposed output:
    a
    b
    1
    f
    986
    How to make the output look like this?
    Output = (a,b,f),(1,986)
    Below is the source code of Algebra.java
    import java.io.*;
    import java.util.*;
    * Read and print, using BufferedReader from System.in, onto System.out
    public class Algebra {
    public static void main(String[] av) {
    try {
    BufferedReader is = new BufferedReader(new InputStreamReader(System.in));
    String inputLine;
    System.out.print("Input =");
    while ((inputLine = is.readLine()) != null) {
    System.out.println("Output="+inputLine);
    StringTokenizer st =
    new StringTokenizer(inputLine, ", |");
    while (st.hasMoreElements())
    System.out.println("Token: " + st.nextElement());
    break;
    is.close();
    } catch (IOException e) {
    System.out.println("IOException: " + e);
    Thank You

    You can modify this to serve your goal.
    BufferedReader is=null;
    try {
    is = new BufferedReader(new InputStreamReader(new FileInputStream("Data.txt")));
    StreamTokenizer st = new StreamTokenizer(is);
    int n=0,k=0,q=0;
    String[] s=new String[20];
    String[] s0=new String[10];
    while(st.nextToken() != StreamTokenizer.TT_EOF) {
            switch(st.ttype) {
              case StreamTokenizer.TT_EOL:
                s[k] = new String("EOL");k++;
                break;
              case StreamTokenizer.TT_NUMBER:
                s0[q] = Double.toString(st.nval);q++;
                break;
              case StreamTokenizer.TT_WORD:
                s[k] = st.sval; // Already a String
                 k++;
                break;
              default: // single character in ttype
                s[k] = String.valueOf((char)st.ttype); k++;
            }  //end of while
       //   Some output processing here
    }catch(IOException ioe){
       ioe.printStackTrace();
    }catch(ArrayIndexOutOfBoundsException bx){
       System.err.println(bx);
    }finally{
           try{      if(is !=null)     is.close();}catch(IOException ioe){;}
    }

  • How to make button to format a HardDrive or USB, How to remove all files from folder, and How to delete a process in listbox with a textbox?

    Hello!
    Here's the question with explaniation: How can i format the USB or Drive by clicking a button what's meant for it?
    and the second question what's also in vb.net: How can i remove all files from folder ? 
     Here's the Look of program: *
    Using the PC button, it will delete the free space of the PC, do you guys/girls know where it's location?

    Example Code:
    Imports System.Runtime.InteropServices
    Imports System.IO
    Public Class Form1
    Dim CBoxDrives As New ComboBox
    WithEvents FButton As New Button
    <DllImport("shell32.dll")> _
    Private Shared Function SHFormatDrive(ByVal hwnd As IntPtr, ByVal drive As UInteger, _
    ByVal fmtID As UInteger, ByVal options As UInteger) As ULong
    End Function
    Private Enum SHFormatFlags As Integer
    SHFMT_ID_DEFAULT = &HFFFF
    SHFMT_OPT_FULL = &H1
    SHFMT_OPT_SYSONLY = &H2
    SHFMT_ERROR = &HFFFFFFFF
    SHFMT_CANCEL = &HFFFFFFFE
    SHFMT_NOFORMAT = &HFFFFFFD
    SHFD_FORMAT_FULL = 0 ' full format
    SHFD_FORMAT_QUICK = 1 ' quick format
    End Enum
    Private Sub FButton_Click_1(sender As System.Object, e As System.EventArgs) Handles FButton.Click
    If CBoxDrives.Text = "" Then
    MsgBox("No Drive Selected")
    Exit Sub
    End If
    Dim Iresult As ULong = SHFormatDrive(CType(Me.Handle.ToInt32, IntPtr), CUInt(Asc(CBoxDrives.Text.Substring(0, 1)) - Asc("A")), CUInt(SHFormatFlags.SHFMT_ID_DEFAULT), 1)
    End Sub
    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    Me.Size = New Size(200, 100)
    With FButton
    .Size = New Size(50, 25)
    .Location = New Point(5, 5)
    .Text = "Format"
    End With
    Me.Controls.Add(FButton)
    With CBoxDrives
    .Size = New Size(50, 25)
    .Location = New Point(75, 5)
    .DropDownStyle = ComboBoxStyle.DropDown
    End With
    Me.Controls.Add(CBoxDrives)
    Dim DrivesFound As Integer = 0
    Dim allDrives() As DriveInfo = DriveInfo.GetDrives()
    Dim d As DriveInfo
    For Each d In allDrives
    If ((d.DriveType = DriveType.Fixed) Or (d.DriveType = DriveType.Removable)) AndAlso Environment.GetEnvironmentVariable("SYSTEMROOT").StartsWith(d.Name) = False Then
    CBoxDrives.Items.Add(d.Name)
    DrivesFound += 1
    End If
    Next
    CBoxDrives.SelectedIndex = DrivesFound - 1
    End Sub
    End Class

  • Make Button load Words from List

    Hey Guys!!!
    Just a note, I dont know about proramming and I am new to flash so please say you responses in the simplest way possible, thankyou!
    So I am making an app that when you click a button it will randomly select a Who, What, When, Where, and Why from a list that I make.
    So say there is a button that says New Idea.
    When I click the button there is:
    Who:
    What:
    When:
    Where:
    Why:
    Say a small list of who is 1, 2, and 3
    A small list of what is 4, 5, and 6
    A small list of when is 7, 8, and 9
    A small list of where is 10, 11, 12
    And a small list og why is 13, 14, and 15
    How can I make it so when I click the New Idea Button it will select (by random) a who, what, when, where, and why from their lists?
    Please help me saying what to do from making the button make get a word from a list, to what I am asking!
    Please!!!
    Thankyou!!!

    To make a random selection from a list you first have to have the list.  An array makes a good list, so for each category create an array and fill each with whichever choices you intend.
    To randomly pick one of the items in the list you can use the Math methods that Actionscript is supported by.
    var whoList:Array = [1,2,3];
    var randomWho = whoList[Math.floor(Math.random()*whoList.length)];
    Please don't start new postings for the same topic

  • How to make an app deleted from iTunes library be deleted from all the iOS devices synced with this library?

    Hello!
    I have 3 iOS devices synced with iTunes apps library (OS X 10.10.2)
    Can someone tell me how to make not only added but deleted apps be synced also? I mean I want an app deleted in iTunes library be deleted from any iOS devices synced with this library.

    But it was working some time before! What and when has changed?
    There was even a warning popup window something about "this application will be deleted from all the devices synced with this library"
    Now there's opposite message - "This application will not be deleted from any device syncing with this account". Isn't it some kind of clue that there can be conrarily circumstances - when application IS deleted from ANY device synced with this computer?

  • How to make comparison between strings using Labview

    helo, i want to know, how to make comparison between array of string.?
    the transmitter have send the assign text such as
    A hello            Bhye  Cbye

    Hi Syanitaa,
    You actually only need to post the question once. 
    Multiple duplication. Please refer to this thread.

  • How to make GC remove  weakReference from ReferenceHashSet

    Hi there,
    I opened and then close some GUI forms. and take heapdump file. the GUIformeditor are still in memory.
    and I used Jprobe and Heapanalyzer to check. both list ReferenceHashSet as the referrer for my GUIeditor.
    but I checke the source of org.eclipse.core.internal.runtime.referencehashset and it says A hashset whose values can be garbage collected.
    I requested a GC before I took the memory snapshot.
    could somebody shed some light into this? how to make the GC to collect those weakreference??
    Thanks a lot.

    I think you could try something like this.....
    Add with a power limit of zero and then drop the disks with a powerlimit of 11.
    alter system set ASM_POWER_LIMIT=0;
    select * from v$asm_operation;
    alter diskgroup DBFILE01_GRP
    add disk 'ORCL:DB0009', 'ORCL:DB0010', 'ORCL:DB0011', 'ORCL:DB0012';
    alter diskgroup DBFILE01_GRP drop disk DB0001, DB0002, DB0003, DB0004;
    alter diskgroup DBFILE01_GRP rebalance power 11;
    select * from v$asm_operation;

  • How to make buttons enabled after the data is entered in JTextField?

    I got a JTextField. I want to test the entered data in JTextField is eight length. If the data is of length eight then i want to enable two buttons. How to make it enable? I am getting the length eight, but the buttons are not enable. What listeners I have to use.
    Can anybody help me out.
    Thanks for your help in advanced.

    Create a class that extends KeyAdapter. Add a field that is an array of buttons. Override the keyTyped(KeyEvent e) method to use getSource() to access the text area, check the length of the text, and if > 8, go through the array and enable the buttons in the array. Then, when you create the text area, create an instance of your listener, passing it an array of the two buttons you want to enable, and then use addKeyListener(yourKeyListener) to add your key listener to the text area.
    Doug

Maybe you are looking for

  • How to query opening balance for all customer or Vendor for an speci. date

    Hi, How to query opening balance for all customer or Vendor for an specific date? Example: put any date and query will show all customer/ Vendor  that date opening/current balance. Regards, Mizan

  • How do I save an SVG via save for web?

    I can't save for web to SVG format from illustrator CS6. The option isn't in the format list of the save for web dialogue; I only have gif, jpeg, png-8 and png-24. I am sure it used to be there, so where has it gone? Have I got to do something in the

  • Can I sync iPhone notes to my laptop?

    How do I sync (save) my iPhone notes to my laptop?

  • IBook chargers - Must it be 45watt?

    Hi I've just recently purchased an iBook, But its in need of a new charger. The piece that actually goes into the machine is no longer round and it its quite difficult to seat it properly. And occasionally it just stops charging so I'm guessing its n

  • Application Express performance - tuning required?

    We have recently implemented a new Application Express system running under Oracle10g on a Linux/RedHat 4 server (actually a Dell PowerEdge 2850 with 8gb RAM and twin 3gb CPU's). The application mostly flies but on odd days (increasingly) performance