How to add JFrame within JFrame

Hi,
I want to add jFrame within JFrame just like JInternalFrame, But I don't want to use JInternalFrame.

Im not really sure why you would want to do this, but what you could do is add the JFrame's contentPane to a JPanel, and then put it in the other one.
So lets say you have two JFrame objects: frame1 and frame2
JPanel frame2Content = new JPanel();
frame2Content.add(frame2.getContentPane());
frame1.getContentPane().add(frame2Content);Depending on your layout manager, that would allow you to put frame2's components, as a panel, somewhere in frame1.

Similar Messages

  • How to add tooltip to jframe title?

    hi all
    does anyone knows how can i set tooltip for jframe title?
    thanks

    Since it's a slow Saturday and I'm in a good mood...import darrylbu.util.SwingUtils;
    import javax.swing.*;
    public class FrameTitleToolTip {
       public static void main(String[] args) {
          JFrame.setDefaultLookAndFeelDecorated(true);
          SwingUtilities.invokeLater(new Runnable() {
             @Override
             public void run() {
                new FrameTitleToolTip().makeUI();
       public void makeUI() {
          JFrame frame = new JFrame();
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.setSize(400, 400);
          for (JComponent component : SwingUtils.getDescendantsOfType(JComponent.class,
                frame)) {
             if (component.getClass().getName().contains("MetalTitlePane")) {
                component.setToolTipText("Tooltip for frame title bar");
                break;
          frame.setLocationRelativeTo(null);
          frame.setVisible(true);
    }You can get the SwingUtils class [_here_|http://tips4java.wordpress.com/2008/11/13/swing-utils/]
    db

  • How do add tags within text of another tag in xml...

    I have the following template I want to create in xml and read it to send out emails.... but in body i want to insert the tags <DATE> and <COUNT> in certain location of the text how is that possible this is what I have:
    <email>
    <from>[email protected]</from>
    <to>[email protected]</to>
    <cc>[email protected]</cc>
    <bcc>[email protected]</bcc>
    <subject>This is the subject</subject>
    <body>This is the body of an email message.As of <_DATE> there are <COUNT> outstanding items. Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text
    Text Text Text Text Text Text Text Text Text
    Text Text Text Text</body>
    </email>
    From: <_FROM>               
    To: <_TO>
    Cc: <>
    Subject: Hello
    As of <_DATE> there are <COUNT> outstanding items. Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text
    Text Text Text Text Text Text Text Text Text
    Text Text Text Text
    Thank you,
    Sys Admin

    In ur program
    Betweens = station.getChildren("between");here the "Between" is a List having "between" elements.
    if u want to traverse through all the <between> elements which are inside the<noservice>,.
    check with this,
    Betweens = station.getChildren("between");
    between = (Element)Betweens.get(0);
    bNames =between.getChildren("station");
    blineNames =between.getChildren("line");instead of this..
    java.util.List Between = station.getChildren("between");
    ListIterator iter = Between.listIterator();
    while(iter.hasNext())
    Element between = (Element) i.next();      
    bNames =between.getChildren("station");
    blineNames =between.getChildren("line");
    If the XMl document is something like this..
    <?xml version="1.0"?>
    <?xml-stylesheet type="text/css" href="style.css"?>
    <DisruptionsInfo>
    <Title>Disruptions on the London Underground</Title>
    <noService>
    <between>
    <description>The are no service between</description>
    <station>BAKER STREET</station>
    <description>and</description>
    <station>EUSTON SQUARE</station>
    <description>on the</description>
    <line>METROPOLITAN LINE</line>
    </between><between>
    <description> 2 The are no service between</description>
    <station>2 BAKER STREET</station>
    <description>2 and</description>
    <station>2 EUSTON SQUARE</station>
    <description>2 on the</description>
    <line>2 METROPOLITAN LINE</line>
    </between>
    <description>The following station(s) are closed due
    to engineering works:</description>
    </noService>
    <closed>
    <station> Green Park </station>
    <station> Maida Vale </station>
    </closed>
    <description>The following line(s) are closed due to
    flooding</description>
    <DelaysLine>
    <line>Jubilee line</line>
    </DelaysLine>
    </DisruptionsInfo>the above code will travel thro all the <between> children of the <noservice> element.
    i think this would help u.

  • How to add an Array within an array?

    Hi friends can any body guides me how to add array within array.
    Actually i am getting Array from server side and i have to append one more node(Array) in same array and send it back to them.
    here is the structure of my array that i am getting from server side.
    temp = Array (@4445e09)   
        [0] = mx.utils.ObjectProxy (@4314821)   
            Mylanguages = Array (@4445b69)   
                [0] = Object (@449ac91)   
                    Mylanguage = "English"   
                    Mylanguage_code = "EN"   
                    Mylanguage_id = "1"   
                    selected = "Y"   
                length = 1   
            currentpage = "1"   
            definition_id = "20"   
            delete_record = "Y"   
            edit_record = "Y"   
            insert_record = "Y"   
            numberofpages = "1"   
            numberofrecords = "1"   
            object = Object (@4432449)   
            productgroups = Array (@43cea51)   
            type = null   
            uid = "111111"   
        length = 1
    I have to add an array similar to like Mylanguages  containing object which contain some info like some ids. and my array becomes
    ttemp = Array (@4445e09)   
        [0] = mx.utils.ObjectProxy (@4314821)   
            Mylanguages = Array (@4445b69)   
                [0] = Object (@449ac91)   
                    Mylanguage = "English"   
                    Mylanguage_code = "EN"   
                    Mylanguage_id = "1"   
                    selected = "Y"   
                length = 1   
            currentpage = "1"   
            definition_id = "20"   
            delete_record = "Y"   
            edit_record = "Y"   
            insert_record = "Y"   
            numberofpages = "1"   
            numberofrecords = "1"   
            object = Object (@4432449)   
            productgroups = Array (@43cea51)
           AddedNOde= Array (@4445b69)   
                [0] = Object (@449ac91)   
                    id= "10"   
                    tempId= "100"   
                    Mylanguage_id = "1"   
                length = 1           
            type = null   
            uid = "111111"   
        length = 1   
    please tell me how it possible.
    Thanks in Advance
    Regards
    Vineet osho

    Hi Vineet,
    You can simply add another Array as shown below:
    for each(var obj:Object in temp)
         obj.AddedNOde = YourNewArray;
    By doing above NewArray is added to  all the objects of temp Array.
    Thanks,
    Bhasker
    Message was edited by: BhaskerChari

  • How to add a table(from TableRenderDemo) to a JFrame again

    Hello again:
    Thanks for stephen andrews's adivice, I follow your adivice to add code (it is in
    EventHandeler of DrawCalendar class, and they indicated by ???????????), but it still not work, please check for me why, Thanks.
    My problem
    Please run my coding first, and get some view from my coding.
    At the movement, I got a problem, I have not idea how to add a table(it is from TableRenderDemo) to JFrame when I click on the button(from DrawCalendar) of the numer 20, and I want the table disply under the buttons(from DrawCalendar).
    Please help me to solve this problem, thanks.
    *This program for add some buttons and a table on JFrame
    import java.awt.*;
    import javax.swing.*;public class TestMain extends JFrame{
    private static TableRenderDemo tRD;
    private static TestMain tM;
    protected static Container c;
    private static DrawCalendar dC;
    public static void main(String[] args){
    tM = new TestMain();
    tM.setVisible(true);
         public TestMain(){
         super(" Test");
         setSize(800,600);
    //set up layoutManager
    c=getContentPane();
    c.setLayout ( new GridLayout(3,1));
    tRD=new TableRenderDemo();
    dC=new DrawCalendar();
    addItems();//add Buttons to JFrame
    private void addItems(){
         c.add(dC); //add Buttons to JFrame
         //c.add(tRD); //add Table to JFrame     
    *This program for add some buttons to JPanel
    *and add listeners to each button
    *I want to display myTable under the buttons,
    *when I click on number 20, but why it doesn't
    *work, The coding for these part are indicated by ??????????????
    [import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.GridLayout;
    public class DrawCalendar extends JPanel {
         private static DrawCalendar dC;
         private static TestMain tM;
         private static TableRenderDemo myTable;
         private static GridLayout gL;
         private static final int nlen = 35;
        private static String names[] = new String[nlen];
    private static JButton buttons[] = new JButton[nlen];
         public DrawCalendar(){
              gL=new GridLayout(5,7,0,0);
              setLayout(gL);
              assignValues();
              addJButton();
              registerListener();
    //assign values to each button
         private void assignValues(){
              names = new String[35];
         for(int i = 0; i < names.length; i++)
         names[i] = Integer.toString(i + 1);
    //create buttons and add them to Jpanel
    private void addJButton(){
         buttons=new JButton[names.length];
         for (int i=0; i<names.length; i++){
         buttons=new JButton(names[i]);
         buttons[i].setBorder(null);
         buttons[i].setBackground(Color.white);
         buttons[i].setFont(new Font ("Palatino", 0,8));
    add(buttons[i]);
    //add listeners to each button
    private void registerListener(){
         for(int i=0; i<35; i++)
              buttons[i].addActionListener(new EventHandler());          
    //I want to display myTable under the buttons,
    //when I click on number 20, but why it doesn't
    //work
    private class EventHandler implements ActionListener{
         public void actionPerformed(ActionEvent e){
         for(int i=0; i<35; i++){
         if(i==20){                  //????????????????????
              tM=new TestMain(); //I want to display myTable under the buttons,
              tM.c.removeAll(); //when I click on number 20, but why it doesn't
              tM.c.add(dC); //work
              tM.c.add(myTable); //???????????????????????????????????????
              tM.validate();
         if(e.getSource()==buttons[i]){
         System.out.println("testing " + names[i]);
         break;
    *This program create a table with some data
    [import javax.swing.table.AbstractTableModel;
    import javax.swing.table.TableColumn;
    import javax.swing.DefaultCellEditor;
    import javax.swing.table.TableCellRenderer;
    import javax.swing.table.DefaultTableCellRenderer;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class TableRenderDemo extends JScrollPane {
        private boolean DEBUG = true;
        public TableRenderDemo() {
          //  super("TableRenderDemo");
            MyTableModel myModel = new MyTableModel();
            JTable table = new JTable(myModel);
            table.setPreferredScrollableViewportSize(new Dimension(700, 70));//500,70
             //Create the scroll pane and add the table to it.
             setViewportView(table);
            //Set up column sizes.
            initColumnSizes(table, myModel);
            //Fiddle with the Sport column's cell editors/renderers.
            setUpSportColumn(table.getColumnModel().getColumn(2));
    * This method picks good column sizes.
    * If all column heads are wider than the column's cells'
    * contents, then you can just use column.sizeWidthToFit().
    private void initColumnSizes(JTable table, MyTableModel model) {
    TableColumn column = null;
    Component comp = null;
    int headerWidth = 0;
    int cellWidth = 0;
    Object[] longValues = model.longValues;
    for (int i = 0; i < 5; i++) {
    column = table.getColumnModel().getColumn(i);
    try {
    comp = column.getHeaderRenderer().
    getTableCellRendererComponent(
    null, column.getHeaderValue(),
    false, false, 0, 0);
    headerWidth = comp.getPreferredSize().width;
    } catch (NullPointerException e) {
    System.err.println("Null pointer exception!");
    System.err.println(" getHeaderRenderer returns null in 1.3.");
    System.err.println(" The replacement is getDefaultRenderer.");
    comp = table.getDefaultRenderer(model.getColumnClass(i)).
    getTableCellRendererComponent(
    table, longValues[i],
    false, false, 0, i);
    cellWidth = comp.getPreferredSize().width;
    if (DEBUG) {
    System.out.println("Initializing width of column "
    + i + ". "
    + "headerWidth = " + headerWidth
    + "; cellWidth = " + cellWidth);
    //XXX: Before Swing 1.1 Beta 2, use setMinWidth instead.
    column.setPreferredWidth(Math.max(headerWidth, cellWidth));
    public void setUpSportColumn(TableColumn sportColumn) {
    //Set up the editor for the sport cells.
    JComboBox comboBox = new JComboBox();
    comboBox.addItem("Snowboarding");
    comboBox.addItem("Rowing");
    comboBox.addItem("Chasing toddlers");
    comboBox.addItem("Speed reading");
    comboBox.addItem("Teaching high school");
    comboBox.addItem("None");
    sportColumn.setCellEditor(new DefaultCellEditor(comboBox));
    //Set up tool tips for the sport cells.
    DefaultTableCellRenderer renderer =
    new DefaultTableCellRenderer();
    renderer.setToolTipText("Click for combo box");
    sportColumn.setCellRenderer(renderer);
    //Set up tool tip for the sport column header.
    TableCellRenderer headerRenderer = sportColumn.getHeaderRenderer();
    if (headerRenderer instanceof DefaultTableCellRenderer) {
    ((DefaultTableCellRenderer)headerRenderer).setToolTipText(
    "Click the sport to see a list of choices");
    class MyTableModel extends AbstractTableModel {
    final String[] columnNames = {"First Name",
    "Last Name",
    "Sport",
    "# of Years",
    "Vegetarian"};
    final Object[][] data = {
    {"Mary ", "Campione",
    "Snowboarding", new Integer(5), new Boolean(false)},
    {"Alison", "Huml",
    "Rowing", new Integer(3), new Boolean(true)},
    {"Kathy", "Walrath",
    "Chasing toddlers", new Integer(2), new Boolean(false)},
    {"Sharon", "Zakhour",
    "Speed reading", new Integer(20), new Boolean(true)},
    {"Angela", "Lih",
    "Teaching high school", new Integer(4), new Boolean(false)}
    public final Object[] longValues = {"Angela", "Andrews",
    "Teaching high school",
    new Integer(20), Boolean.TRUE};
    public int getColumnCount() {
    return columnNames.length;
    public int getRowCount() {
    return data.length;
    public String getColumnName(int col) {
    return columnNames[col];
    public Object getValueAt(int row, int col) {
    return data[row][col];
    * JTable uses this method to determine the default renderer/
    * editor for each cell. If we didn't implement this method,
    * then the last column would contain text ("true"/"false"),
    * rather than a check box.
    public Class getColumnClass(int c) {
    return getValueAt(0, c).getClass();
    * Don't need to implement this method unless your table's
    * editable.
    public boolean isCellEditable(int row, int col) {
    //Note that the data/cell address is constant,
    //no matter where the cell appears onscreen.
    if (col < 2) {
    return false;
    } else {
    return true;
    * Don't need to implement this method unless your table's
    * data can change.
    public void setValueAt(Object value, int row, int col) {
    if (DEBUG) {
    System.out.println("Setting value at " + row + "," + col
    + " to " + value
    + " (an instance of "
    + value.getClass() + ")");
    if (data[0][col] instanceof Integer
    && !(value instanceof Integer)) {
    //With JFC/Swing 1.1 and JDK 1.2, we need to create
    //an Integer from the value; otherwise, the column
    //switches to contain Strings. Starting with v 1.3,
    //the table automatically converts value to an Integer,
    //so you only need the code in the 'else' part of this
    //'if' block.
    try {
    data[row][col] = new Integer(value.toString());
    fireTableCellUpdated(row, col);
    } catch (NumberFormatException e) {
    JOptionPane.showMessageDialog(TableRenderDemo.this,
    "The \"" + getColumnName(col)
    + "\" column accepts only integer values.");
    } else {
    data[row][col] = value;
    fireTableCellUpdated(row, col);
    if (DEBUG) {
    System.out.println("New value of data:");
    printDebugData();
    private void printDebugData() {
    int numRows = getRowCount();
    int numCols = getColumnCount();
    for (int i=0; i < numRows; i++) {
    System.out.print(" row " + i + ":");
    for (int j=0; j < numCols; j++) {
    System.out.print(" " + data[i][j]);
    System.out.println();
    System.out.println("--------------------------");

    http://forum.java.sun.com/faq.jsp#format

  • How to add a table(from TableRenderDemo) to a JFrame?

    Hello:
    Please run my coding first, and get some idea what's going on for my coding.
    At the movement, I got a problem, I have not idea how to add a table(it is from TableRenderDemo) to JFrame when I click on the button(from DrawCalendar) of the numer 20, and I want the table disply under the buttons(from DrawCalendar).
    Please help me to solve this problem, thanks.
    /* this program for adding some Button to JPanel, and also adding some listeners to each button
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.GridLayout;
    public class DrawCalendar extends JPanel {
    private static DrawCalendar dC;
    private static GridLayout gL;
    private static Container c;
    private static String names[]={"1","2","3","4","5","6","7","8","9","10","11","12","13","14",
    "15","16","17","18","19","20","21","22","23","24","25","26",
    "27","28","29","30","31","32","33","34","35"};
    private static String num;
    private static JButton buttons[];
    public DrawCalendar(){
    gL=new GridLayout(5,7,0,0);
    setLayout(gL);
    addJButton(); //add buttons to Panel
    registerListener();//add Listener to buttons
    //add Buttons to JButtons and put the label for each button
    private void addJButton(){
    buttons=new JButton[names.length];
    for (int i=0; i<names.length; i++){
    buttons=new JButton(names);
    buttons.setBorder(null);
    buttons.setBackground(Color.white);
    buttons.setFont(new Font ("Palatino", 0,8));
    add(buttons);
    private void registerListener(){
    for(int i=0; i<35; i++)
    buttons.addActionListener(new EventHandler());//add EventHandler to each button
    private class EventHandler implements ActionListener{
    public void actionPerformed(ActionEvent e){
    for(int i=0; i<35; i++){
    if(e.getSource()==buttons){
    System.out.println("testing " + names);
    break;
    /*The program for adding a table to JPanel
    import javax.swing.JTable;
    import javax.swing.table.AbstractTableModel;
    import javax.swing.table.TableColumn;
    import javax.swing.DefaultCellEditor;
    import javax.swing.table.TableCellRenderer;
    import javax.swing.table.DefaultTableCellRenderer;
    import javax.swing.JScrollPane;
    import javax.swing.JComboBox;
    import javax.swing.JFrame;
    import javax.swing.SwingUtilities;
    import javax.swing.JOptionPane;
    import java.awt.*;
    import java.awt.event.*;
    public class TableRenderDemo extends JScrollPane {
    private boolean DEBUG = true;
    public TableRenderDemo() {
    // super("TableRenderDemo");
    MyTableModel myModel = new MyTableModel();
    JTable table = new JTable(myModel);
    table.setPreferredScrollableViewportSize(new Dimension(700, 70));//500,70
    //Create the scroll pane and add the table to it.
    //JScrollPane scrollPane = new JScrollPane(table);
    setViewportView(table);
    //Set up column sizes.
    initColumnSizes(table, myModel);
    //Fiddle with the Sport column's cell editors/renderers.
    setUpSportColumn(table.getColumnModel().getColumn(2));
    //Add the scroll pane to this window.
    //getContentPane().add(scrollPane, BorderLayout.CENTER);
    // addWindowListener(new WindowAdapter() {
    // public void windowClosing(WindowEvent e) {
    // System.exit(0);
    * This method picks good column sizes.
    * If all column heads are wider than the column's cells'
    * contents, then you can just use column.sizeWidthToFit().
    private void initColumnSizes(JTable table, MyTableModel model) {
    TableColumn column = null;
    Component comp = null;
    int headerWidth = 0;
    int cellWidth = 0;
    Object[] longValues = model.longValues;
    for (int i = 0; i < 5; i++) {
    column = table.getColumnModel().getColumn(i);
    try {
    comp = column.getHeaderRenderer().
    getTableCellRendererComponent(
    null, column.getHeaderValue(),
    false, false, 0, 0);
    headerWidth = comp.getPreferredSize().width;
    } catch (NullPointerException e) {
    System.err.println("Null pointer exception!");
    System.err.println(" getHeaderRenderer returns null in 1.3.");
    System.err.println(" The replacement is getDefaultRenderer.");
    comp = table.getDefaultRenderer(model.getColumnClass(i)).
    getTableCellRendererComponent(
    table, longValues,
    false, false, 0, i);
    cellWidth = comp.getPreferredSize().width;
    if (DEBUG) {
    System.out.println("Initializing width of column "
    + i + ". "
    + "headerWidth = " + headerWidth
    + "; cellWidth = " + cellWidth);
    //XXX: Before Swing 1.1 Beta 2, use setMinWidth instead.
    column.setPreferredWidth(Math.max(headerWidth, cellWidth));
    public void setUpSportColumn(TableColumn sportColumn) {
    //Set up the editor for the sport cells.
    JComboBox comboBox = new JComboBox();
    comboBox.addItem("Snowboarding");
    comboBox.addItem("Rowing");
    comboBox.addItem("Chasing toddlers");
    comboBox.addItem("Speed reading");
    comboBox.addItem("Teaching high school");
    comboBox.addItem("None");
    sportColumn.setCellEditor(new DefaultCellEditor(comboBox));
    //Set up tool tips for the sport cells.
    DefaultTableCellRenderer renderer =
    new DefaultTableCellRenderer();
    renderer.setToolTipText("Click for combo box");
    sportColumn.setCellRenderer(renderer);
    //Set up tool tip for the sport column header.
    TableCellRenderer headerRenderer = sportColumn.getHeaderRenderer();
    if (headerRenderer instanceof DefaultTableCellRenderer) {
    ((DefaultTableCellRenderer)headerRenderer).setToolTipText(
    "Click the sport to see a list of choices");
    class MyTableModel extends AbstractTableModel {
    final String[] columnNames = {"First Name",
    "Last Name",
    "Sport",
    "# of Years",
    "Vegetarian"};
    final Object[][] data = {
    {"Mary ", "Campione",
    "Snowboarding", new Integer(5), new Boolean(false)},
    {"Alison", "Huml",
    "Rowing", new Integer(3), new Boolean(true)},
    {"Kathy", "Walrath",
    "Chasing toddlers", new Integer(2), new Boolean(false)},
    {"Sharon", "Zakhour",
    "Speed reading", new Integer(20), new Boolean(true)},
    {"Angela", "Lih",
    "Teaching high school", new Integer(4), new Boolean(false)}
    public final Object[] longValues = {"Angela", "Andrews",
    "Teaching high school",
    new Integer(20), Boolean.TRUE};
    public int getColumnCount() {
    return columnNames.length;
    public int getRowCount() {
    return data.length;
    public String getColumnName(int col) {
    return columnNames[col];
    public Object getValueAt(int row, int col) {
    return data[row][col];
    * JTable uses this method to determine the default renderer/
    * editor for each cell. If we didn't implement this method,
    * then the last column would contain text ("true"/"false"),
    * rather than a check box.
    public Class getColumnClass(int c) {
    return getValueAt(0, c).getClass();
    * Don't need to implement this method unless your table's
    * editable.
    public boolean isCellEditable(int row, int col) {
    //Note that the data/cell address is constant,
    //no matter where the cell appears onscreen.
    if (col < 2) {
    return false;
    } else {
    return true;
    * Don't need to implement this method unless your table's
    * data can change.
    public void setValueAt(Object value, int row, int col) {
    if (DEBUG) {
    System.out.println("Setting value at " + row + "," + col
    + " to " + value
    + " (an instance of "
    + value.getClass() + ")");
    if (data[0][col] instanceof Integer
    && !(value instanceof Integer)) {
    //With JFC/Swing 1.1 and JDK 1.2, we need to create
    //an Integer from the value; otherwise, the column
    //switches to contain Strings. Starting with v 1.3,
    //the table automatically converts value to an Integer,
    //so you only need the code in the 'else' part of this
    //'if' block.
    try {
    data[row][col] = new Integer(value.toString());
    fireTableCellUpdated(row, col);
    } catch (NumberFormatException e) {
    JOptionPane.showMessageDialog(TableRenderDemo.this,
    "The \"" + getColumnName(col)
    + "\" column accepts only integer values.");
    } else {
    data[row][col] = value;
    fireTableCellUpdated(row, col);
    if (DEBUG) {
    System.out.println("New value of data:");
    printDebugData();
    private void printDebugData() {
    int numRows = getRowCount();
    int numCols = getColumnCount();
    for (int i=0; i < numRows; i++) {
    System.out.print(" row " + i + ":");
    for (int j=0; j < numCols; j++) {
    System.out.print(" " + data[j]);
    System.out.println();
    System.out.println("--------------------------");
    *This is a main progarm, it is for adding some buttons to Frame
    import java.awt.*;
    import javax.swing.*;
    public class TestMain extends JFrame{
    private static TableRenderDemo tRD;
    private static TestMain tM;
    private static Container c;
    private static DrawCalendar dC;
    public static void main(String[] args){
    tM = new TestMain();
    tM.setVisible(true);
    public TestMain(){
    super(" Test");
    setSize(800,600);
    //set up layoutManager
    c=getContentPane();
    c.setLayout ( new GridLayout(3,1));
    tRD=new TableRenderDemo();
    dC=new DrawCalendar();
    addItems();//add Buttons to JFrame
    private void addItems(){
    //c.add(dC); //add Buttons to JFrame
    c.add(tRD); //add Table to JFrame

    http://forum.java.sun.com/faq.jsp#format

  • How I can get a JFrame to open in the middle of the screen?

    Okay, I have been looking for an answer on how I can make a JFrame open in the center of the screen like the JOptionpane's "null" argument does. Maybe, I am putting the wrong words in the search but I can't find any help on this.
    Thanks
    ***Sample***
    import java.awt.FlowLayout;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    public class JFrameProb extends JFrame
         private JLabel someText;
         private JLabel someText2;
         private JLabel someText3;
         public JFrameProb()
              super("Why is this always going to the Corner?");
              setLayout( new FlowLayout() );
              someText = new JLabel("This Window Popped open in the top-left Corner...");
              add(someText);
              someText2 = new JLabel("Is there a way to open in the Center of the Screen?");
              add(someText2);
              someText3 = new JLabel("I know JOptionPane does.");
              add(someText3);
    }

    JosAH,
    I tried using your code but it errored out:
    C:\Program Files\Java\jdk1.5.0\PimpThatHo\PimpNameGetter.java:78: cannot find symbol
    symbol : variable Centralizer
    location: class PimpNameGetter.TextFieldHandler
    Centralizer.centralize(comboBox);
    ^
    1 error
    Process completed.
    So I made a java file for the Cebtralizer Class but it gave me this:
    --------------------Configuration: <Default>--------------------
    C:\Program Files\Java\jdk1.5.0\PimpThatHo\Centralizer.java:3: cannot find symbol
    symbol : class Component
    location: class Centralizer
    public static void centralize(Component c) {
    ^
    C:\Program Files\Java\jdk1.5.0\PimpThatHo\Centralizer.java:5: cannot find symbol
    symbol : class Dimension
    location: class Centralizer
    Dimension screenSize= Toolkit.getDefaultToolkit().getScreenSize();
    ^
    C:\Program Files\Java\jdk1.5.0\PimpThatHo\Centralizer.java:5: cannot find symbol
    symbol : variable Toolkit
    location: class Centralizer
    Dimension screenSize= Toolkit.getDefaultToolkit().getScreenSize();
    ^
    C:\Program Files\Java\jdk1.5.0\PimpThatHo\Centralizer.java:6: cannot find symbol
    symbol : class Dimension
    location: class Centralizer
    Dimension compSize= c.getPreferredSize();
    ^
    4 errors
    Process completed.
    I know I am missing packages but I don't know which ones.
    Roman03_

  • How can I change the Jframe Java help Icon

    How can I change then Jframe Java help Icon?.
    I am using then HelpSet class and HelpBroker.
    I want to change the java help icon
    Any Idea? thanks. ...

    It can be done, but it's ugly...
    Add in a listener to your topmost JFrame to sense when the focus is lost, since this happens when a help window comes up. When the focus leaves the main window, check all the windows that are up to see if one is a help window. If so, this will give you a reference to the help window and you can drill down to change what you want.
    Here's an example that changes the icon and removes the borders from the javahelp buttons.
    WindowListener wndCloser = new WindowAdapter() {
              //A necessarily roundabout method to affect
              //look and feel aspects of the javahelp viewer.
              //(there is no way to get at these components directly.)
              //When the main frame loses focus, it may be because
              //the help viewer was brought up. Look through all
              //the current frames to see if one is a help viewer.
              //If it is, change the look of the help viewer
              //to what we want.
              Frame m_helpFrame = null;
              public void windowDeactivated(WindowEvent e) {
              if (m_helpFrame != null)
                   return;
              Frame[] frames = getFrames();
              for (int k = 0; k < frames.length; k++) {
                   if (!(frames[k] instanceof JFrame))
                   continue;
                   JFrame jf = (JFrame)frames[k];
                   if (jf.getContentPane().getComponentCount()==0)
                   continue;
                   Component c = jf.getContentPane().
                   getComponent(0);
                   if (c == null || !(c instanceof JHelp))
                   continue;
                   m_helpFrame = jf;
                   //now that we know the Frame, we can change the title icon
                   final Image image2 = <your icon here>
                   m_helpFrame.setIconImage(image2);
                   JHelp jh = (JHelp)c;
                   for (int s=0; s<jh.getComponentCount(); s++) {
                   c = jh.getComponent(s);
                   if (c == null || !(c instanceof JToolBar))
                        continue;
                   JToolBar jtb = (JToolBar)c;
                   //now that we've accessed the toolbar, we can
                   //modify the look of the buttons.
                   for(int i=0; i<jtb.getComponentCount(); i++) {
                        Component comp = jtb.getComponentAtIndex(i);
                        if(comp instanceof JButton) {
                        JButton button = (JButton)comp;
                        button.setBorder(null);

  • How can i combine several JFrame into one

    I has several JFrames running with different tasks eg. using
    various eventlistener and runnable. but when i try to combine all
    these JFrames into one, compiling is ok but running always has
    missing information. pls kindly advise the easiest method to use in
    combining.
    In addition, how can i display the JFrame in other
    location instead of top left corner (starting point)?

    yup, i used these layout FlowLayout, GridLayout and BorderLayout for
    each of my JFrame and JPanel.

  • How can i hide a JFrame and then Show it again in runtime

    How can i hide a JFrame and then Show it again in runtime??
    Please, please help me
    Its URGENT

    Here's even an example:
    import javax.swing.*;
    public class HideAndShow extends JFrame
         public HideAndShow()
              super("Hello");
              setSize(200, 200);
              setVisible(true);
              try
                   Thread.sleep(2000);
              } catch(InterruptedException e) {}
              setVisible(false);
              try
                   Thread.sleep(2000);
              } catch(InterruptedException e) {}
              setVisible(true);
         public static void main(String[] args)
              new HideAndShow();
    The JFrame will show, then hide, then show again. This is at runtime.

  • How to add a scroll bar within a view window ?I want to display x and y axis outside the scoll window and keep those axis static and move the graph within scroll area

    how to add a scroll bar within a view window ?I want to display x and y axis outside the scoll window and keep those axis static and move the graph within scroll area
    ananya

    Hey Ananya,
    I believe what you want to do is possible, but it will not be
    easy.  If you want to add a scroll bar that will scroll the graph
    back and forth but keep the axis set, you would want to add a
    horizontal or vertical scrollbar.  Then you would create an event
    handler for the scroll event.  You would have to manually plot
    different data within this scroll event.  Unfortunately, there is
    not really a built in way to do this with the Measurement Studio plot
    control.
    Thanks,
    Pat P.
    Software Engineer
    National Instruments

  • How to add friendly URLs to pages within the ALUI portal?

    I want to know how to add friendly URLs (human-readable URLs that users can bookmark or type into the browser address bar) to pages within the ALUI portal.
    The portal application is developed using plumtree portlets.
    regards,
    Veeshoo

    In 6.5
    Community links look like this:
    http://your_Server/portal/server.pt/community/lockdown_console/
    Documents look like this:
    http://your_Server/portal/server.pt/document/50541/your_document_name.doc
    If your goal is for users to "type into the browser address bar" then your best bet would be dns mapping.
    At that point you could have communities with urls like:
    http://your_Community.your_Server.com
    or
    http://your_Server/your_Community
    Which is significantly easier for users

  • How sholud we call one jframe class from another jframe class

    Hi
    In my application i am calling one jframe class from another jframe clas.
    how sholud we make previous jframe inactve when another jframe is invoked?(user sholud not able to make any changes on on parent jframe window when another jframe is invoked)
    Pls reply.

    Sorry for me it is not possible to change existing code,
    pls suggest me any other solution so that i can inactive parent jframe when child jframe execution is going on.

  • How can I resize a JFrame ,to fit into the screen size

    I have a Jframe which has JPanel and JPanel contains lot of other components.JPanel size is 980,1400. when i use JFrame.show method jpanel goes beyond the screen size in length and I am not able to see the portion below the screen.How can I resize the JFrame so that JFrame and JPanel shrinks to fit into the screen size.I need this because I have a PRINT button at bottom of the JPanel.Thanks.

    Thank you for your reply.I tried with the following code as you have told.But the frame is still going beyond the screen.Can you please look into it and tell me whats wrong ?
    //public class PlayerRegForm extends javax.swing.JFrame implements Printable
    public static void main(String args[]) {
    PlayerRegForm prf = new PlayerRegForm();
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension frameSize = prf.getSize();
    if (frameSize.height > screenSize.height)
    frameSize.height = screenSize.height;
    if (frameSize.width > screenSize.width)
    frameSize.width = screenSize.width;
    System.out.println("Screen Size ----------------- " + screenSize);
    System.out.println(" Frame Size ----------------- " + frameSize);
    prf.setSize(frameSize.width, frameSize.height);
    prf.pack();
    prf.show();
    =============================================================================
    Screen Size ----------------- java.awt.Dimension[width=1024,height=768]
    Frame Size ----------------- java.awt.Dimension[width=112,height=28]

  • How to get keyevents in Jframe

    Hi,
    If i make usual keylistener class for keyevents and
    add it to jframe itself, the frame doesen't get any
    of keyevents. Alltough all buttons and such components
    which has same listener added gets events (when focused).
    The frame itself is allso focused when trying this.
    I tried allso add keylistener to container and all panels
    in that frame, but it had no better effect.
    There must be a way that frame can as get keyevents as default.
    I will be very pleased of any help.

    Are you sure you added a KeyListener to the right component? If you want your frame or panel to receive KeyEvents no matter what child component has the focus (ie. generated the event) then you will need to add a keylistener to every component in the frame (you can use a loop)and just use your frame as the sole KeyListener.
    I am pretty sure that will work but I'm not sure exactly what you have already tried. If that doesn't work then it could be related to the component consuming events. They do consume some events but I thought they would call all of their listeners first.
    Jeff

Maybe you are looking for

  • Compatible camera list

    I am looking to buy a camera to use on some personal projects and build a demo reel. I've tried to locate a list of cameras compatible with FCP 5.0.4 but have so far been unable to do so. Can someone give me the url for this? Or let me know if these

  • How to identify the original source folder of files in the trash?

    I am trying to help a friend who trashed a massive amount of files. Dragging files out of the trash to where they originated from works when one knows where files in the trash came from. What I need to know is how to find out which folder the files o

  • Factory Reset my Stream 11???

    At some point in my owning this product (in the last 4-5 months), I had received a low disk space warning, so I started to uninstall programs that I thought I didn't need. I may have removed something that was necessary for another program to use, bu

  • Upgraded PB g4 to os x but missing omni outliner and iphoto

    Hi Forum I was wondering why the upgrade to os x does not have these features. In fact my previous version of mac before the upgrade has the iphoto (or a version of it) now nothing. Very very disappointed and now with the new os coming up I am upset

  • SQL Server 2008 Express -- Process exited with code -2068643839

    When installing SQL Server 2008 Express, I continue to get the following info in the install log.  I notice that I only get this issue with 64-bit PC's (win 7 & win 8.1).  Ideas? Thanks. The following components failed to install: - SQL Server 2008 E