How to set contents begin at the first line?

I created a JPanel setting CENTER, then use GridBagLayout and want contents begin at the top, not in the center. I try using anchor, but it doesn't work. Please help me sort it out. Thanks.
Here my code:
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class gridBagLayoutTest extends JFrame{
    public gridBagLayoutTest() {
      super("test");
      Container con = this.getContentPane();
      JPanel jp=new JPanel();
      GridBagLayout gb=new GridBagLayout();
      GridBagConstraints c=new GridBagConstraints();
      c.fill=GridBagConstraints.BOTH;
      jp.setLayout(gb);
      c.gridx=0;
      c.gridy=0;
      JButton jb=new JButton("Button1");
      gb.setConstraints(jb,c);
      jp.add(jb);
      con.add(jp, BorderLayout.CENTER);
      setSize(250,250);
      setVisible(true);
      addWindowListener(
           new WindowAdapter(){
               public void windowClosing(WindowEvent e){
                  System.exit(0);
public static void main(String[] args){
      new gridBagLayoutTest();

Hi,
well your question seems not clear, but anyway..i would suggest u make use of the NORTHWEST, NORTH, NORTHEAST, EAST constraints of the GridBagLayout..its the most tedious and difficult layout manager in java
i.e
GridBagLayout gl;
GridBagConstraints gbc;
gl = new GridBagLayout();
gbc = new GridBagConstraints();
yourpanel.setLayout (gl);
gbc.anchor=GridBagConstraints.NORTHWES;
gbc.gridx=1;     //an example of where u want to position the component at northwest.
gbc.gridy = 4;
gl.setConstraints (yourcomponent,gbc);
yourpanel.add (yourcomponent);But note that by default in java..no matter the type of layout manager used...adding of components to containers starts at at the middle..and get pushed up...depending of the number of components u add up.
Another option for u is to set layout = NULL...then u will have to work with Dimesion..to position your components.
i.e
Jlabel label1 = new JLabel("ddd");
panel.setLayout (null);
jLabel.setBounds(new Rectangle(9, 207, 120, 26));
panel.add(jlabel1);I hope this helps.
Regards.
Olumide

Similar Messages

  • How to set a dropdown to the blank line value

    Hi all,
    maybe a very easy question.
    How can I set a dropdownbyindex value to the blank line?
    If I use e.g.
    wdContext.currentActionsElement().setDescription(null);
    it adds another blank line among the values and if I try with:
    wdContext.nodeActions().setLeadSelection(0);
    it doesn't work.
    Any suggestion?
    Thanks in advance.
    Angelo

    wdContext.nodeActions().setLeadSelection(IWDNode.NO_SELECTION);
    Check that node selection is not mandatory (i.e. selection cardinality is 0..1, not 1..1).
    If this does not help set initializeLeadSelection to false for this node.
    VS

  • How to set content type for the attachment?

    Hello Everybody,
    I was trying to do the following in my send mail program:-
    1. I am making a file using FileWriter:
    FileWriter fw = new FileWriter(f);
    fw.write(str);
    2. I now want to attach this file with my mail. but before that I want to set the Content type of this as "application/smil". and trying the following code:
    mimebodyparts[0].setContent(fds[0],"application/smil");
    As this is a new MIME type perhaps I need to change the mailcap file. I found the same in the activation jar package but thought instead of chagning the default file i tried putting following code in my program:
                  File capfile = new File("simple.mailcap");
                  if (!capfile.isFile())
                        System.out.println("Cannot locate the \"simple.mailcap\" file.");
                        System.exit(1);
                  CommandMap.setDefaultCommandMap( new MailcapCommandMap(new FileInputStream(capfile)));
    and in simple.mailcap file put the following value
    application/smil;;     x-java-content-handler=com.sun.mail.handlers.application_smil  but I am still getting the following error:
    javax.activation.UnsupportedDataTypeException: no object DCH for MIME type application/smil
    Can somebody Please help to sort this out.
    regards,
    Arun

    //add related mutip-part to combine parts
    MimeMultipart multipart = new MimeMultipart("related");
    //attach a pdf
    messageBodyPart = new MimeBodyPart();
    fds = new FileDataSource("h:/something.pdf");
    messageBodyPart.setDataHandler(new DataHandler(fds));
    messageBodyPart.setFileName(fds.getName());
    multipart.addBodyPart(messageBodyPart);
    //add multipart to the message
    message.setContent(multipart);
    //send message
    Transport.send(message);

  • How do I set Pages to capitalise the first word of a new paragraph

    Does anyone know how I set Pages to capitalise the first word of a new paragraph.

    Hi Peter
    That worked, thank you
    However, what I was wanting was to set Pages to start every new paragraph with a capital letter
    Any ideas?
    Thanks

  • How do I set up voicemail for the first time?

    I feel like i am losing my mind.  I CANNOT find simple instructions (even in the manual) on how to set up my husband's voicemail on the BB 8800.  There are all kinds of questions and answers about voicemail, but I just need to know how to set it up for the first time.  The message you get when you call the phone is "This user has not yet set up voicemail" (or something to that effect).
    PLEASE HELP!
    Solved!
    Go to Solution.

    This is simple in deed! Go to Call Log -> click Menu and  select Options -> Voice Mail. Now in the Access Number put your carriers Voice Mail Box number. Some carrier requires access password which you can also put in the.
    Let know if this helps.
    tanzim                                                                                  
    If your query is resolved then please click on “Accept as Solution”
    Click on the LIKE on the bottom right if the post deserves credit

  • Could not parse the file contents as a data set. There were too many variable names in the first line of the text file.

    Could not parse the file contents as a data set. There were too many variable names in the first line of the text file.

    What are the Variables settings, what is the text file’s content, …?

  • When I set up email for the first time, I had to enter a 4 digit pin. Since then, every time I switch my phone on, I have to enter this pin.   How do I remove or bypass the pin so that I can switch on the Iphone without having to first enter a pin?

    When I set up email for the first time, I had to enter a 4 digit pin. Since then, every time I switch my phone on, I have to enter this pin.   How do I remove or bypass the pin so that I can switch on the Iphone without having to first enter a pin?

    Go to Settings>General>Passcode Lock>tap Turn Passcode Lock Off, enter your "pin".
    Edit:  Are you saying you are getting a prompt for your email pin, or are you talking about the passcode lock that appears when you turn the phone on?

  • HT201356 How on earth do you answer or change the verification questions when you never set them up in the first place?

    how on earth can you answer the verification password change questions when you never set them up in the first place?

    You need to ask Apple to reset your security questions. To do this, click here and pick a method; if that page doesn't list one for your country or you're unable to call, fill out and submit this form.
    (124244)

  • TS1424 I am trying to purchase something from app store and it is asking me to answer 2 security questions that I never set up/answered in the first place? Has this happened to anyone else? How do i fix this or reset these security questions?

    I am trying to purchase app from app store and its asking me to answer my security questions which I dont know because I never set them up in the first place! How do i get passef this or change it to reset my own security questions?? 

    Click here for information. If the option to have the answers emailed to you isn't available or doesn't work(the email may take a few hours to arrive), contact the iTunes Store staff via the link in that article.
    (88522)

  • How to set cursor at the first line in a table control?

    Hi,
           I have a customized infotype screen where a table control is being used to input new values.The tab control has 30 lines.Now, the problem is that when the screen is displayed, the cursor always starts at 8th or 4th line.The behaviour is not very consistent.I tried the following statement in the PBO, but no effect.
    SET CURSOR FIELD P9417-ZCOUNTRY LINE 1.  ( P9417-ZCOUNTRY is the name of the tab control field where i want to set the cursor ).This is the last statement in the PBO.
    Can someone please tell me why still I am not able to set the cursor at the first line? I have infact noticed that , in the debugging mode , sometimes the cursor starts at the first line.Please help. Thanks

    I have got a new requirement on this now. If the table control does not have any records , then the cursor position should be on the first row.Otherwise, if it already has some records, then the cursor should be at the first empty row.I wrote the code like below.
    if sy-ucomm = 'INSERT'.
    set cursor 'P9714-ZCOUNTRY'  line 1.
    else if sy-ucomm eq 'CHANGE'.
    describe table itab lines fill.
    fill = fill + 1.
    set cursor 'P9714-ZCOUNTRY'  line fill.
    endif.
    I am facing a strange problem now.The table control has some 10 rows when you see the screen for the first time.If the number of records already present is less than 10, I am able to position the cursor on the first empty row.But if the number is say 15, then the cursor position goes to eighth or fourth line or sometimes the first line.
    Is there any way to display the last few records , ie, if there are 15 records , is there any way to display the last five rows when I see the screen for the first time, rather than showing the first 10 records?How can I position the cursor at the first empty row, when there are more records?
    Thanks in advance..good answers will be rewarded.
    Mahesh

  • I download itext  for convert jsp to PDF. How to set content type for PDF.

    I download itext for convert jsp to PDF. How to set content type for PDF. I try
    <%@ page contentType = "application/pdf;charset=TIS-620" %>
    , but the page does not PDF.
    Thank.

    PDF files are usually binary files, JSPs are not well-suited for binary content.
    (If you download the result of your JSP you'll see that it is not a valid PDF file; it will have probably a lot of whitespace and linefeeds, that will choke your PDF reader.). The first few characters must be
    "%PDF-" without whitespace.
    You can try using PDF files encoded as text - check if you can use text-encoded PDFs in iText.
    Try using a Servlet instead.

  • How to set white spaces between the fields in dataset??

    Hi all,
    I am writing a set on information to from infotypes to a text file. Its a fixed width file. How do set white spaces in the fields for dataset?
    Example:
    TYPES: begin of header,
                    filler(40)  type c,
                    id(3)        type c,
                    filler2(7) type  c,
                    delimiter  type  c,
                 end of header.
    DATA header type header.
    header-filler1 = ' '.
    header-id       = '100'.
    header-filler2 = ' '.
    header-delimiter = cl_abap_char_utilities=>newline.   ( do it to get a new line)
    my_table = header.
    append my_table.
    DATA: out_file(256) type C,
          codepage_ref type ref to CX_SY_CONVERSION_CODEPAGE,
          out_char type c,
          size type i,
          insert_string type string,
          insert_size type i.
      out_file = filename.
      open dataset out_file for output in text mode ENCODING NON-UNICODE.
      LOOP AT my_table.
        size = strlen( my_table ).
        insert_string = ''.
        DO size TIMES.
          offset = sy-index - 1.
          try.
              out_char = my_table+offset(1).
              IF out_char = SPACE.
                CONCATENATE insert_string '' INTO insert_string SEPARATED BY SPACE.
              ELSE.
                CONCATENATE insert_string out_char INTO insert_string.
                transfer insert_string to out_file NO END OF LINE .
                insert_string = ''.
              ENDIF.
            catch CX_SY_CONVERSION_CODEPAGE.
              insert_size = strlen( insert_string ) - 1.
              insert_string = insert_string(insert_size).
          endtry.
        ENDDO.
       transfer CL_ABAP_CHAR_UTILITIES=>NEWLINE TO out_file NO END OF LINE.
      ENDLOOP.
      close dataset out_file.
    How do I get to insert the space for filler1 and filler2?
    Edited by: Siong Chao on Oct 4, 2011 4:56 AM
    Edited by: Siong Chao on Oct 4, 2011 8:27 AM
    Edited by: Siong Chao on Oct 4, 2011 8:29 AM

    problem lies in the open dataset codes
    Used:
    open dataset out_file for output in text mode encoding non-unicode message msg.
    if sy-subrc= 0.
    loop at my_table.
    transfer my_table to out_file
    transfer cl_abap_char_utilities=>newline to out_file no end of line.
    endloop.

  • How to set a song in the playlist to be phone ringtone

    how to set my song in the playlist to be my ringtone

    you have to convert it to a ringtone first. searching google will give you many ways to do it. also, there are some ringtone apps with pros and cons to each one. you cannot just pick a song on your phone and make it a ringtone unfourtunately.

  • How to set Where clause in the View Object of the MessageChoice ?

    Hi,
    How to set Where clause in the View Object of the
    MessageChoice ?
    Example:
    <bc4j:rootAppModuleDef name="EdEscolaCampusView1AppModule"
    definition="ed00050.Ed00050Module"
    releaseMode="stateful" >
    <bc4j:viewObjectDef name="EdEscolaCampusView1" >
    <bc4j:rowDef name="CreateEdEscolaCampusView1" autoCreate="true" >
    <bc4j:propertyKey name="key" />
    </bc4j:rowDef>
    </bc4j:viewObjectDef>
    <bc4j:viewObjectDef name="ListaTipLocalView1"
    rangeSize="9999">
    </bc4j:viewObjectDef>
    </bc4j:rootAppModuleDef>
    </bc4j:registryDef>
    messageChoice declaration:
    <bc4j:messageChoice name="SeqTipoLocalCampus"
    attrName="SeqTipoLocalCampus"
    prompt="Local do Campus">
    <contents>
    <bc4j:optionList attrName="SeqTipoBasico"
    textAttrName="NomTipoBasico"
    voName="ListaTipLocalView1"/>
    </contents>
    </bc4j:messageChoice>
    I would like set where clause of ViewObject, with dinamic parameters (using attribute1 = :1), before populate messageChoice.
    thanks...
    Danilo

    Hi Andy,
    I try set a where clause using the message:
    Set where Clause parameter using UIX , but my UIX Page have 2 messageChoice's of different ViewObject's, then I need implement this Java Class:
    //Nome da Package da Tela Detail
    package br.com.siadem.siaed.ed00050;
    // Importa as Bibliotecas necessárias
    import oracle.jbo.ViewObject;
    import oracle.jbo.ApplicationModule;
    import oracle.jbo.client.Configuration;
    import oracle.cabo.servlet.BajaContext;
    import oracle.cabo.servlet.Page;
    import oracle.cabo.servlet.event.PageEvent;
    import oracle.cabo.servlet.event.EventResult;
    import oracle.cabo.data.jbo.servlet.bind.*;
    import oracle.cabo.ui.data.BoundValue;
    import oracle.cabo.ui.data.DataBoundValue;
    import javax.servlet.http.HttpServletRequest;
    import br.com.siadem.siaed.util.*;
    import javax.servlet.http.Cookie;
    import oracle.cabo.data.jbo.def.NestedAppModuleDef;
    import oracle.cabo.data.jbo.def.ViewObjectDef;
    import oracle.cabo.data.jbo.def.AppModuleDef;
    // Classe que configura os parametros para a execução da Query,
    // utilizando variáveis de Sessao
    public class FunPreQueryLista
    public static EventResult FunConfiguraQuery(BajaContext context, Page page, PageEvent event) throws Throwable
    // TrataDadosSessao - Classe utilizada para retornar os valores das variáveis de sessão genéricas
    // Ex: CodCliente, CodMunicipio etc...
    TrataDadosSessao varDadosSessao = new TrataDadosSessao();
    // 1o. Parametro Configurado - Através da classe TrataDadosSessao, utilizando um método Get
    // <alterar>
    String valor1 = varDadosSessao.getCodCliente();
    String valor2 = varDadosSessao.getCodMunicipio();
    //Cria o objeto que retorna o ApplicationModule
    ApplicationModule am = ServletBindingUtils.getApplicationModule(context);
    // Início das Configurações da Query da Lista
    //Cria o objeto que retorna o view object da lista desejada
    //alterar
    ViewObject TipoLocal = am.findViewObject("ListaTipoLocalView1");
    //Configuração dos parametros definidos na query do view Object
    //alterar
    TipoLocal.setWhereClauseParam(0,valor1);
    TipoLocal.setWhereClauseParam(1,valor2);
    // Executa a Query
    TipoLocal.executeQuery();
    // Fim das Configurações da Query da Lista
    // Início das Configurações da Query da Lista
    //Cria o objeto que retorna o view object da lista desejada
    //alterar
    ViewObject TipoDestLixo = am.findViewObject("ListaDestinoLixoView1");
    //Configuração dos parametros definidos na query do view Object
    //alterar
    TipoDestLixo.setWhereClauseParam(0,valor1);
    TipoDestLixo.setWhereClauseParam(1,valor2);
    // Executa a Query
    TipoDestLixo.executeQuery();
    // Fim das Configurações da Query da Lista
    // Retorna o Resultado para a Página
    return new EventResult(page);
    The code works very well...
    And, I'm sorry for my two repost's in UIX Forum about this in a few time.
    Thank very much...
    Danilo

  • How to separate content area from the image area in cs6

    how to separate content area from the image area in cs6? looks just fine in design view but when opened up in explorer my text /content area is over the image area. the content is suppose to be below the image not over it. How do I move it down? Everything I have tried has not worked ;(

    Is your image in the CSS (background) or the HTML (foreground)? 
    Try copying and pasting this code into a new, blank document.  Change placehold.it images to your own.  Save and preview in browsers.
    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>HTML5 with CSS 2-Col Layout</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!--[if IE]>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <![endif]-->
    <!--[if lt IE 9]>
    <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <style>
    /**CSS Reset**/
        padding: 0;
        -webkit-box-sizing: border-box;
        -moz-box-sizing: border-box;
        box-sizing: border-box;
    img {
        width: 100%;
        vertical-align: baseline;
    /**Layout**/
    body {
        padding: 0;
        width: 90%; /**adjust width in px or % as desired**/
        margin: 0 auto; /**this is centered**/
        background: #CFF;
        color: #505050;
        font-family: Segoe, "Segoe UI", "DejaVu Sans", "Trebuchet MS", Verdana, sans-serif;
        font-size: 100%;
        box-shadow: 2px 2px 4px #333;
    header {
        margin: 0;
        padding: 0 1%;
        width: 100%;
        background: #B00202;
        color: #FFF;
    /**top menu**/
    nav {
        background: #EAEAEA;
        font-family: Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif;
        font-size: 14px;
        font-weight: bold
    nav ul {
        margin: 0;
        padding: 0;
    nav li {
        list-style: none;
        display: inline-block;
        margin: 0 3% 0 5%;
    /**menu link styles**/
    nav li a {
        color: #666;
        text-decoration: none;
        line-height: 2.5em;
        padding: 6px;
        border: 1px solid #CCC;
    /**on select or mouseover**/
    nav li a:hover, nav li a:active, nav li a:focus {
        background: #CCC;
        color: #505050;
    #wrapper {
        background: #EAEAEA;
        overflow: hidden; /**float contaiment**/
    /**main content**/
    article {
        padding: 0 2%;
        background: #FFF;
        float: left;
        width: 70%;
    figure {
        width: 80%;
        margin: 4% auto 4% auto;
        text-align: center;
    /**right sidebar**/
    aside {
        padding: 0 2%;
        float: left;
        width: 30%;
    footer {
        clear: both;
        background: #B00202;
        color: #FFF;
        text-align: center;
        margin: 0;
    /**typography**/
    header h1, header h2 {
        display: inline;
        color: #F5DD83;
        padding: 0 1%;
    h3 {
        color: #2294AE;
        margin-bottom: 0
    p { margin: 0 0 1em 0 }
    figcaption {
        text-align: center;
        font-style: oblique;
        font-size: small;
        color: #2294AE;
    </style>
    </head>
    <body>
    <!--begin header-->
    <header> <h1>Sitename</h1>
    <h2>|  Responsive CSS Layout</h2>
    </header>
    <!--begin navigation-->
    <nav>
    <ul>
    <li><a href="#">Menu Item1</a></li>
    <li><a href="#">Menu Item1</a></li>
    <li><a href="#">Menu Item1</a></li>
    <li><a href="#">Menu Item1</a></li>
    <li><a href="#">Menu Item1</a></li>
    </ul>
    </nav>
    <div id="wrapper">
    <!--begin main content-->
    <img class="banner" src="http://placehold.it/1056x100/198EBA/FFFFFF&text=Banner.jpg" alt="banner" />
    <article> <h3>Article</h3>
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.  Mauris vitae libero lacus, vel hendrerit nisi!  Maecenas quis velit nisl, volutpat viverra felis. Vestibulum luctus mauris sed sem dapibus luctus.  Pellentesque aliquet aliquet ligula, et sagittis justo auctor varius. Quisque varius scelerisque nunc eget rhoncus.  Aenean tristique enim ut ante dignissim. </p>
    <figure> <img src="http://placehold.it/500x325" alt="placeholder">
    <figcaption>Figure 2 Caption</figcaption>
    </figure>
    </article>
    <!--begin right sidebar-->
    <aside> <h3>Aside</h3>
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.  Mauris vitae libero lacus, vel hendrerit nisi!  Maecenas quis velit nisl, volutpat viverra felis. Vestibulum luctus mauris sed sem dapibus luctus. </p>
    <hr>
    <p>Pellentesque aliquet aliquet ligula, et sagittis justo auctor varius. Quisque varius scelerisque nunc eget rhoncus.  Aenean tristique enim ut ante dignissim. </p>
    <hr>
    <p>Pellentesque aliquet aliquet ligula, et sagittis justo auctor varius. Quisque varius scelerisque nunc eget rhoncus.  Aenean tristique enim ut ante dignissim. </p>
    </aside>
    <!--end wrapper--></div>
    <!--begin footer-->
    <footer> <small>© 2014 Your Site Name. All rights reserved</small> </footer>
    </body>
    </html>
    Nancy O.

Maybe you are looking for

  • Jabber and Outlook Pressence

    Hello, We are using a mix of CUPC and Jabber clients, and having trouble with some of the Outlook integration.  I'm sorry if this is the wrong forum, but I couldn't find a better category. What is happening is, if you receive an email from someone, o

  • I am trying to sync my ipod to my laptop but it told me to restore it. i did so and it failed but there was nothing on it to restore to begin with

    I am trying to sync my ipod nano to my windows laptop. I previously synced it to a different laptop but the music didnt sync to the ipod. The previous laptop is old so I figured a newer laptop would be more sufficient. While on the new laptop it is t

  • No airport signal!

    Hello, here's a question for the pros.. My Mac Book Pro is not picking up any signal. Network connect says airport is turned on, but no network is available. However.. My friend's computer, placed right next to mine receives full signal and can selec

  • Off-the-shelf user login/registration and credit card processing

    Does anyone know where I can find prebuilt components for user login and registration of new users. I also need credit card validation and payment components. Any help would be appreciated. -- Thanks for any help Marc

  • Mass Delete of BDocs in SAP CRM system

    Dear SDC team, We like to hard delete some BDocs which are hanging in the txn SMW01 in CRM 5.2 system. As of now we do not see a option to delete these unnecessary BDocs,  as they are in Intermediate state (I04) . Please tell us if there any standard