Frame, Panel, Componant Formatting.

My goal is to have a Frame that when it resizes the left and Right Panel take up 50% each and the Left panel should show a image that takes up the whole panel this is my Code:
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.FlowLayout;
import java.awt.Dimension;
public class MyFrame
    private JPanel myLeftPanel = null;
    private JPanel myRightPanel = null;
    private JFrame frame = null;
     public MyFrame(JPanel leftPanel, JPanel rightPanel)
         myLeftPanel = leftPanel;
         myRightPanel = rightPanel;
         makeFrame();
         addPanels();
     public void swapPanels(JPanel leftPanel, JPanel rightPanel)
         myLeftPanel = leftPanel;
         myRightPanel = rightPanel;
         addPanels();
     public void makeFrame()
         JFrame myFrame = new JFrame();
         frame = myFrame;
         frame.setSize(500, 500);
         frame.setTitle("Nasa Program");
         frame.setVisible(true);
         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     public void addPanels()
         frame.getContentPane().setLayout(new FlowLayout());
         myLeftPanel.setPreferredSize(new Dimension(frame.getWidth()/2, frame.getHeight()));
         frame.getContentPane().add(myLeftPanel);
         frame.getContentPane().add(myRightPanel);
import javax.swing.JPanel;
import javax.swing.JButton;
import javax.swing.JButton;
import javax.swing.JComponent;
import java.awt.*;
import java.io.IOException;
import java.net.MalformedURLException;
public class LeftPanelEarth extends JPanel
     public LeftPanelEarth()
         Image map = null;
          try {
               map = javax.imageio.ImageIO.read(new java.net.URL(getClass().getResource("calgary_small.gif"), "calgary_small.gif"));}
               catch (MalformedURLException mue) {       }
              catch (IOException ioe) {          }
         MapComponant mapPanel = new MapComponant(map);
         mapPanel.setPreferredSize(this.getSize());         /**                   REFERANCE POINT */
         this.add(mapPanel);
     public class MapComponant extends JComponent
         Image map = null;
         public MapComponant (Image mapGiven)
             map = mapGiven;
     public void paintComponent(Graphics g)
         Graphics2D g2 = (Graphics2D) g;
               if (map != null)
                    g2.drawImage(map,
                              0,
                              0,
                              getWidth(),
                              getHeight(),
                              this);
}And the Right Panel just has a Button that does appear.
So what I end up with is that I get a frame with the left side empty and the Right side with the button. If i replace the "REFERANCE POINT" above with values such as new Dimension(200,200) the image will appear on the left side but It is not drawn in the (0,0) part of the Panel like it is soppose to.
So I can't get the Image to take the intire Panel up and When I give it a Dimension it dosent draw it at (0,0) anyone know whats going on?
Frame>2Panels (Left Panel is given Dimension (Frame/2, Frame))>Image is given(Dimension (Panel, Panel))
I dunno why it isn't woking.

try this
import javax.swing.*;
import java.awt.*;
class MyFrame
    private JPanel myLeftPanel = null;
    private JPanel myRightPanel = null;
    private JFrame frame = null;
  public MyFrame(JPanel leftPanel, JPanel rightPanel)
      myLeftPanel = leftPanel;
      myRightPanel = rightPanel;
      makeFrame();
      addPanels();
      frame.setVisible(true);//moved to here
  public void makeFrame()
      JFrame myFrame = new JFrame();
      frame = myFrame;
      frame.setSize(500, 500);
      frame.setTitle("Nasa Program");
      //frame.setVisible(true);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  public void addPanels()
      //frame.getContentPane().setLayout(new FlowLayout());
      frame.getContentPane().setLayout(new GridLayout(1,2));
      myLeftPanel.setPreferredSize(new Dimension(frame.getWidth()/2, frame.getHeight()));
      frame.getContentPane().add(myLeftPanel);
      frame.getContentPane().add(myRightPanel);
  public static void main(String[] args){new MyFrame(new LeftPanelEarth(),new RightPanel());}
class LeftPanelEarth extends JPanel
   Image img;
  public LeftPanelEarth()
    try
      img = javax.imageio.ImageIO.read(new java.net.URL(getClass().getResource("Test.gif"), "Test.gif"));
    catch(Exception e){}//do nothing
  public void paintComponent(Graphics g)
    super.paintComponent(g);
    if(img != null) g.drawImage(img, 0,0,this.getWidth(),this.getHeight(),this);
class RightPanel extends JPanel
  public RightPanel()
    super(new GridBagLayout());
    add(new JButton("OK"),new GridBagConstraints());
}

Similar Messages

  • Beginner's frustration: Lost in a maze of boxes, frames, panels...

    Beginner's frustration: Lost in a maze of boxes, frames, panels...
    I was making some progress and feeling good after much frustration and then suddenly I got lost in this deep dark black hole in outerspace.
    1. I have managed to totally mess up all these boxes, frames, panels and cannot figure out how to get back to any resemblance of order. Totally lost in space. How to get back to earth?
    2. And, my video went from running smoothly, to a jerky motion after making various adjustments.
    3. And, somewhere, in the effects, color adjustments, I inserted a 1 second delay in the part that says something about smooth an image or something and I can't find where I was and I want to reset that back to zero. I wonder if that is causing this jerky delay? But, I also noticed it before.
    4. This is the most complicated program I've evern used. I wish they made a beginner's area where I could quickly get into it and make a quick video without getting so lost and frustrated in this massive program.
    Can anyone relate to beginner's frustration?

    Go to any clips with FX and remove them. Delete Key in FX Window)
    Sorry, my windows and everything are so messed up. i don't know where to find the FX window.
    On 2 clips,
    First clip has FX, Opacity:Opacity
    Audio clip with this has FX, Volume Level.
    2nd clip has on video portion, Brightness and Contrast: Contrast.
    On audio portion has Panner: Balance: Level.
    The clip is running rough, jerky.
    The fade in and fade out is rough, jerky.

  • Change the default country code for new contacts in Outlook 2013 for countries not listed in Control Panel Region Format

    Dear all,
    I would like to change the default country code for new Outlook 2013 contacts. My country is Mozambique (+258) and is not listed under Control Panel> Region> Formats> Format:
    Is there any place (registry maybe, anywhere) where I can manipulate the existing formats or manually add a new format to the List ??? - for example Portuguese (Mozambique).
    I am using Windows 8.1
    I have tried changing the country on the phone and modem options and nothing changes. Also changing the Home Location on Region> Location to Mozambique didn't change a thing. The only place where I change something and produces results is the
    Format List.
    Any ideias???? If not, is there a place where I can ask Microsoft to include Portuguese (Mozambique) on future windows updates???
    Kind regards,
    Osvaldo

    Hi,
    Windows uses the information set under
    'Phone and Modem'  in the Control Panel to determine the default area code.
    You can change the country/region to
    Mozambique
    and set your area code here:
    Regards,
    Steve Fan
    TechNet Community Support

  • Very intermittent JDialog issue - the panel component is transparent

    Hi,
    I am running JRE/JDK 1.6_06 on Windows XP SP2 and am getting a very intermittent issue
    (happens perhaps 1 out 200 times or so). The issue is that a new JDialog does not show its
    panel component and what should be in the panel is transparent. You see what would be underneath
    the JDialog in the panel. The JDialog itself is visible.
    Here are some additional details.
    1) If I switch to another windows app and then back to my Java App, the contents then display correctly.
    2) As a workaround, I tried repainting the JDialog after it was visible in another Thread but that did not help.
    3) I have my own application tracing to confirm no threading issue involved.
    4) The memory/cpu are all good. This is not a race condition.
    5) There is no signs of trouble in terms of an exception being thrown. The RunTime from Java is
    completely clean. No issues.
    6) If I simply close the JDialog and recreate the JDialog again all is well.
    7) In my code, I null the JDialog instance at the point when the user closes down the dialog.
    (I thought that perhaps some kind of garbage clean up might be involved?)
    I suspect a low-level devise driver type issue between the JVM and Windows.
    I will see if I can reproduce this on Linux.
    If anyone has ever heard of or seen any issue like this before that would be helpful.
    Again, there are no signs of trouble from the Java Runtime. I believe the Runtime is unaware of
    any issue. I simply do not see the contents of the dialog. Again very intermittent. Hard to reproduce.
    Let me know if I you need additional details. This is just to get going on this issue.
    Thanks.
    David Bardwell

    Here is an update as I guess this problem is very deep and I will need to come up with a
    test case for a real Swing bug and file a bug with Sun.
    The problem does not reproduce with JRE 1.5.0_15 on Windows in exhaustive testing.
    Before I launch the dialog where I see a transparent panel, I have a database query which
    is done in worker thread. I show the user a panning wait dialog which they can use to cancel
    the query. It appears that this extra work of the panning dialog is important in having this issue
    occur. If I simply do all the work in a single thread, I have not seen the issue reproduce. But again,
    it is not always easy to get the issue to reproduce.
    At this time, I suspect a threading issue (bug) which causes this issue.
    Thanks for at least reading about my issue. I will update this item as I have more information so
    that I can share what I learn with any interested readers.

  • Frame Driver Component

    #2- FRAME DRIVER COMPONENT?
    Used to build two frame HTML pages containign user selection in the "driving
    frame" and data and user interaction in the main companion or "target" frame.
    Define a frame driver name
    Define data to poplulate frames
    Set initial target frame content
    set options and details.
    Where is this further discussed and documented at?
    Where is this found at?
    Has anyone else used FRAMESETS and this FRAME DRIVER thing?
    We need to use framesets in our site and want to have a top and main frame.
    Please add any ideas you might have regarding implementing portal with using framesets? I understand you cant create content or pages that contain "framesets" however, can't you start from the index.html and put the end-user into a "frameset" before they enter the portal?
    null

    Hi,
    You can see the example of frame driver in the example application. In the example the query has a bind variable on which you can bring up a LOV in the top frame and choosing from that LOV will pass on the value to the form in the bottom frame.
    Hope that helps.
    Thanks,
    Sharmila

  • Frames panel: looping button not working

    Frames panel: looping button not working
    I use Fireworks MX 2004
    Frames panel: looping button:
    When I set looping to 2, it stops after 2, as it should.
    All other values, i.e. 1, 3, 4 etc will go on 'forever'.
    What's wrong?
    Thank you for your help.
    Adrian

    This is just a simple exercise.
    http://www.tudo.co.uk/testing/looping_problem.png
    http://www.tudo.co.uk/testing/looping_problem.gif
    In the png file, Frames panel, bottom left, where I can set
    looping to
    any number, including 'forever', I set the looping frequency
    in this
    case to 1. So I expect it to stop after one movement up into
    the right
    top corner and return to bottom left.
    When I play this in 'original' or in 'preview' in Fireworks,
    the
    animation moves continuously instead of stopping after one
    round. That
    is my 'problem'. Or can I not expect this to work while it is
    still in png?
    When I export it to gif, it works exactly as wanted - once
    only.
    Adrian
    Alex Mari�o wrote:
    > adrian,
    >
    > Could you post the png file online and explain exactly
    what you are
    > trying to achieve?
    >
    > alex
    >
    > adrian stock wrote:
    >
    >> Frames panel: looping button not working
    >>
    >>
    >> I use Fireworks MX 2004
    >>
    >> Frames panel: looping button:
    >>
    >> When I set looping to 2, it stops after 2, as it
    should.
    >>
    >> All other values, i.e. 1, 3, 4 etc will go on
    'forever'.
    >>
    >> What's wrong?
    >>
    >> Thank you for your help.
    >>
    >> Adrian

  • Datagrid itemRenderer custom component formatting

    OK, so this is my first attempt at an itenRenderer. This works below, but I have to imagine there is an easier way. There is also a problem with below, where the changed field (datafield=side) after the itemRenderer is applied, the text is all out of format, and there is a kind of selection on row one of that column. Obvisouly, though the translation is happening, I'm either overidding the wrong thing, or I'm doing something totally wrong.
    Goal..... Show in the datagrid, the three colums below from date provided from elsewhere. (This all works), but in the 'side' data it comes in, in raw form as either an 'a' or 'b' or 'both', and I'm trying to display that as something more user friendly. So when both is read it changes it to 'No'.
    Any help. This seems really easy, though I can't understanading hy my custom function screws with the cell selection, and formating?
    ---Main program---
    <mx:DataGrid x="10" y="9" width="199" height="147" id="gdimmer_checkChannel" dataProvider="{ current_rack.getItemAt(0).rackLevels }"
      change="dimmerCheckCurrentSelection(event);"
      sortableColumns="false"
      selectedIndex="{ current_rack.getItemAt(0).currentCheckIndex }" >
    <mx:columns>
      <mx:DataGridColumn headerText="UDN" dataField="udn"/>
      <mx:DataGridColumn headerText="DD" dataField="side" editable="false" itemRenderer="renderers.DataGridDDSide"/>
      <mx:DataGridColumn headerText="Circuit" dataField="circuit"/>
    </mx:columns>
    </mx:DataGrid>
    --- Component Below ---
    <?xml version="1.0" encoding="utf-8"?>
    <s:MXDataGridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
            xmlns:s="library://ns.adobe.com/flex/spark"
            xmlns:mx="library://ns.adobe.com/flex/mx"
            focusEnabled="true">
    <s:Label id="lblData" text="{dataGridListData.label}" />
    <fx:Script>
    <![CDATA[
      override public function set data(value:Object):void
        if (value.side == 'both') { lblData.text = "  No" };
       if (value.side == 'a') { lblData.text = "  a" };
       if (value.side == 'b') { lblData.text = "  b" };
    ]]>
    </fx:Script>
    </s:MXDataGridItemRenderer>

    See the latest post on my blog.  You also need to set super.data in the data
    setter.
    Alex Harui
    Flex SDK Team
    Adobe System, Inc.
    http://blogs.adobe.com/aharui

  • Error : simple Panel component : no more ID?

    Hi all,
    I made a simple class :
    package {
    public class MyPanel extends Panel
    public function MyPanel ()
    super();
    As simple as that. Before I define this simple component, my
    code was like this :
    <mx:Panel
    id = "mainPanel"
    x="131" y="84" width="719" height="609"
    borderColor="#000000" borderStyle="solid"
    borderThickness="1" backgroundColor="#dddddd"
    dragEnter="dragEnterHandler(event);"
    dragExit="dragExitHandler(event);"
    dragDrop="dragDropHandler(event);">
    </mx:Panel>
    Now, I changed it to this :
    I made a simple class :
    package {
    public class MyPanel extends Panel
    public function MyPanel ()
    super();
    As simple as that. Before I define this simple component, my
    code was like this :
    <myProject:MyPanel
    id = "mainPanel"
    x="131" y="84" width="719" height="609"
    borderColor="#000000" borderStyle="solid"
    borderThickness="1" backgroundColor="#dddddd"
    dragEnter="dragEnterHandler(event);"
    dragExit="dragExitHandler(event);"
    dragDrop="dragDropHandler(event);">
    </mx:MyPanel>
    If I remove the id="mainPanel" line, it works fine. If I keep
    it, I get the following error :
    1046: Type was not found or was not a compile-time constant:
    MyPanel.
    Ant idea? Thank you

    Narsimha (guest) wrote:
    : I am getting the following error:
    : "No more data to read from Socket"
    : I am using Oracle 8.0.3 + Jdk 1.1.5 + JDBC Driver 7.3.3.1.3
    : Follwing is my simple program. I got struck here.
    : <<< Please provide me the solution. >>>
    : import java.sql.*;
    : class JDBCTest{
    : public static void main (String args []) throws SQLException,
    : ClassNotFoundException{
    : Class.forName ("oracle.jdbc.driver.OracleDriver");
    : Connection conn =DriverManager.getConnection
    : ("jdbc:oracle:thin:@myHost:1521:orcl","scott", "tiger");
    : Statement stmt = conn.createStatement ();
    : ResultSet rset = stmt.executeQuery ("select * from
    FDMainList");
    : while (rset.next ())
    : System.out.println (rset.getString (1));
    I have the same problem with thin jdbc driver against 8.0.3
    server.
    Try to use oci8 driver - You have to install sql*net8 client
    first. It works for me.
    Looking at:
    http://technet.oracle.com/tech/java/access/info/jdbc_faq.htm#_1_
    I think no thin driver supports 8.0.3 unfortunately.
    null

  • International panel number format

    In the International panel of the System Preferences I would like to set the number format but there is no customise button.
    I would like to achieve the following combination, all of which are crucial to the operation of some applications:
    *main language:* English, then French, then Dutch then German.
    *names of the days of the week and months of the year*: in English
    *date format:* YYYY-MM-DD (e.g. 2008-06-24)
    *time format:* HH:MM:SS 24-hour clock (e.g. 23:36:34)
    *number format:* 1'234.56
    currency: euro
    *measurement system:* metric.
    If anyone can do this, please tell me how!
    The customise button for numbers disappeared already in Tiger and this problem has never been fixed to my knowledge.

    Answer obtained: you have to wait for Snow Leopard, but in the meantime you can set the format by terminal command:
    defaults write -g AppleICUNumberSymbols -dict-add 1 \'
    defaults write -g AppleICUNumberSymbols -dict-add 17 \'
    The numbers are:
    0 -- decimal separator for numbers .
    1 -- thousands separator for numbers '
    2 -- number formats ¤ #,##0.00;¤ -#,##0.00
    4 -- starting character for numbers; for example, if you set the value to a, instead of numbers 0-9 you will see characters a-j (well, this is not that useful!).
    8 -- currency symbol €
    10 -- decimal separator for currency .
    17 -- thousands separator for currency '

  • 'Spreadsheet Table' component formatting

    Hi,
    I have an excel "block" of data that is formatted to the client's expectation. Is it possible to capture those specific formats using the Spreadsheet Table Component (or some other)? It appears that most of my formats are lost, especially the "Wrap Text".
    Is there a way to wrap text using the Grid, List View, or Spreadsheet Table modules on Xcelsius 2008 SP3?
    Thanks in advance!
    -Phil

    I dont think you can do this with any other component except Spreadsheet one. Try playing more with the spreadsheet table component
    the only way i can think of is if you can delete all the text in that block of data and map the spreadsheet table on that - by doing  this you will have the basic structure of that block of data and then you can use lables to do the formatting
    hope it helps

  • [Question] accessing frames Tree component CollapseAll property?

    i have frames on my Jspx pages .
    1: header (Top)
    2: Tree at the Left side (Left)
    3: Page to show (Right)
    4 Footer (Bottom)
    In the header frame i have button/ image/ or any other component to Go to home page ( pressing on 'Home' button it should Collapse the Tree).
    My Tree is in left frame and i need to call its callapse all function to collapse the tree on pressing HOME button which is at the top frame. kindly help me as to how i can do that.
    My tree tag looks like this
    <af:tree id="ProductCatalogueTree" value="#{bindings.ProductCatalogueTree.treeModel}" var="node"
    binding="#{ProductCatalogueTree.tree}" styleClass="bgs"
    focusRowKey="#{ProductCatalogueTree.focusRowKey}" varStatus="nodeStatus">

    Hi,
    all you can do from one frame to another is to refresh its content by re-loading the page displayed in it. There is no shared context that allows you to programmatically access the displayed page content. So in your case you would need to refresh the content of the tree page and pass a request parameter about the state. This parameter then should be evaluated by the tree initialization (e.g. a managed bean reference or a pagedef reference)
    Frank

  • Resizeble frame, panel

    Hi, I am learning to build GUI's in java, I use eclipse and visual editor plug-in.
    I need a panel in a general frame. Where I will read integers(M,N) from a file and I will construct a panel in frame which will have M bye N boxes (I will write something in every box) in it. How can I do this?
    Thanks.

    Maybe you should use a JTable.
    The Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/components/table.html]How to Use Tables will get you started.

  • Stop the cursor from leaving the frame/panel?

    Im making a simple target game where you shoot targets with the mouse. What I'd like to do is stop the mouse cursor from leaving the panel/frame. I've tried moving the cursor there with the Robot class, but 1) it doesnt lock it directly to the edge, 2) it doesnt stop at the top edge and left edge, 3) the bottom edge results in the cursor being placed in the wrong place and finally, 4) if u move the cursor fast enough it breaks out anyway :(
    Hope someone can help,
    Thanx.

    Wow nice responses. I have two questions:
    1) What is native code?Write the code to capture the mouse in C/C++ (Windows supports capturing the mouse cursor - dunno about linux or solaris), then write a JNI wrapper function so you can call it from within Java.
    >
    2) Is it difficult to make it full screen? I was
    thinking of doing that but the thought of rescaling
    everything (i.e. fonts, images etc) made me think
    otherwise.Fullscreen is easy, simply graphicsDevice.setFullscreenWindow(window);
    Once in fullscreen, you can change the resolution to whatever you like (limited to what is supported by the gfx card ofcourse :p), so you shouldn't have to worry about rescaling gfx 2much.
    >
    Thanx,
    Jon

  • Redrawing frame/panel

    Hey there,
    I am having problems with redrawing frames. I use the Object.repaint() method but i have to resize the window before it redraws.
    thanks

    Do you need to call revalidate() on the main JPanel or contentPane?
    Without more information and a compilable code example, it's hard to say anything else. If this doesn't work, post code that demonstrates the problem, is compilable but doesn't do anything else, an SSCCE. To see more about this and how to create this, please look at this link:
    http://homepage1.nifty.com/algafield/sscce.html
    Remember, this code must be compilable and runnable for many of us to be able to help fully.
    Also, if you do post your code, please use code tags so that your code will be well-formatted and readable. To do this, either highlight your code block and press the "code" button at the top above the message block or place the tag &#91;code&#93; at the top of your block of code and the tag &#91;/code&#93; at the bottom, like so:
    &#91;code&#93;
       // your code block goes here
    &#91;/code&#93;Also, I recommend that if you have any future Swing problems, you should ask the question in the Swing forum.

  • Scorecard component formatting

    I am using Xcelsius Engage with SP 3. When using the Scorecard component, only the first row of data in the chart uses the formatting that is specified on the Appearance > Text > Label section of the components properties. I have used a List View component and the formatting for the same set of data carries through all of the rows. I am looking to replicate that in the scorecard component.
    Specifically, I have percentages that I only want to show whole numbers for. The number .38356 will be show as 38% in the first row, but .38356 on the second row in the same column.

    Hi Peter,
    I know it's a late reply. May be people might get benefitted in the future. I was browsing through to find solutions and read this post. Here is the solution for it.
    Issue:
    Initially you would've clicked on 'Labels' and then applied a common formatting (this applies the same formatting to all the columns). Later you would've changed the format of one or two columns that specifically needed different formatting. This way, only the first row is applied with the required formatting.
    Solution:
    - Go to Appearance --> Text
    - Click on each of the Label columns and apply the formatting individually for each column.
    E.g: Out of 10 columns, if you need to apply 'Percentage' for first and fourth columns and 'Numeric' for the rest of the columns, you need to select column 1 and apply 'Percentage', column 2 and apply 'Numeric', column 3 and apply 'Numeric', column 4 and apply 'Percentage', so on...
    Hope this helps.

Maybe you are looking for

  • How to create 'Planned service line' using BAPI_ENTRYSHEET_CREATE? Pl. help

    I need to create service entry sheet ( SES ) using input data from text file through BAPI_ENTRYSHEET_CREATE. If the input contains service line items, which are not present in PO, it should be treated as an unplanned service and correspondingly 'unpl

  • One computer with two ipods

    I am trying to set up my youngest sons new nano on the computer but we are receiving the message to "remove or repair". This is happening because my older son has his ipod already in the computer. Can we not have both and let them be completely seper

  • Authentication issue with 4.1

    We are using a custom authentication scheme. It calls the authenticatin api to authenticate agains active directory. It is working in multiple apex aplications in apex version 3.2. We created a new install of 4.1 and imported the apps from 3.2 I can'

  • Why can't I rename a podcast?

    I got into "Get Info" and change the name, but it doesn't take effect. Why is this so? Thanks.

  • When itunes is clicked, it takes me to the app store?

    recently i've noticed when i click itunes on my ipod touch, it takes me to the app store? any reason why it does this? thanks..