JTable's suitable Layout manager

i have a JTable in a JPanel and another JPanel with JLabels and JTextFiled in it.
* VersionControl.java
* @author JPQuilala
* Created on December 22, 2006, 1:18 PM
package qis_dreamteam;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyVetoException;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableModel;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class VersionControl extends JInternalFrame {
JPanel pnlMain;
JPanel pnlApp,pnlAppTblInput,pnlAppTbl,pnlAppInput,pnlAppLbl,pnlAppTxt;
JPanel pnlHst,pnlHstTblInput,pnlHstTbl,pnlHstInput,pnlHstLbl,pnlHstTxt;
JTable tblApp;
JTable tblHst;
JTextField[] txtApp=new JTextField[7];
JTextField[] txtHst=new JTextField[7];
JLabel[] lblApp=new JLabel[7];
JLabel[] lblHst=new JLabel[7];
JButton btnAppAdd,bntAppUpdate,btnAppDelete;
JButton btnHstAdd,bntHstUpdate,btnHstDelete;
PaoTableModel modelApp=new PaoTableModel("SELECT * FROM QIS_APPLICATION_MT");
PaoTableModel modelHst=new PaoTableModel("SELECT * FROM QIS_APP_VERSION_HISTORY");
public VersionControl(Dimension dSize) throws PropertyVetoException {     
super("Version Control ",
false, //resizable
true, //closable
false, //maximizable
true); //iconifiable
pnlMain=new JPanel();
pnlApp=new JPanel();
pnlAppTblInput=new JPanel();
pnlAppTbl=new JPanel();
pnlAppInput=new JPanel();
pnlAppLbl=new JPanel();
pnlAppTxt=new JPanel();
pnlHst=new JPanel();
pnlHstTblInput=new JPanel();
pnlHstTbl=new JPanel();
pnlHstInput=new JPanel();
pnlHstLbl=new JPanel();
pnlHstTxt=new JPanel();
JPanel pnlHeader=new JPanel();
tblApp=new JTable(modelApp);
tblHst=new JTable(modelHst);
JScrollPane scrollApp=new JScrollPane(tblApp);
tblApp.setPreferredScrollableViewportSize(new Dimension(1000,100));
JScrollPane scrollHst=new JScrollPane(tblHst);
tblHst.setPreferredScrollableViewportSize(new Dimension(dSize.width,100));
setContentPane(pnlMain);
setSelected(true);
tblApp.setAutoResizeMode(tblApp.AUTO_RESIZE_LAST_COLUMN);
JLabel lblTitle=
new JLabel("Hitachi Global Storage Technology Philippines Corp.");
pnlHeader.setLayout(new FlowLayout());
lblTitle.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
lblTitle.setPreferredSize(new java.awt.Dimension (1100,25));
lblTitle.setForeground(new java.awt.Color(255, 255, 255));
lblTitle.setBackground(new java.awt.Color(215, 0, 0));
lblTitle.setOpaque(true);
pnlHeader.add(lblTitle);
//pnlAppLbl
pnlAppLbl.setLayout(new GridLayout(7,1,0,9));
for(int i=0;i<7;i++) {
pnlAppLbl.add(lblApp=new JLabel("Label "+i));
//pnlAppTxt
pnlAppTxt.setLayout(new GridLayout(7,1,0,5));
for(int i=0;i<7;i++) {
pnlAppTxt.add(txtApp[i]=new JTextField("",16));
//pnlAppInput
pnlAppInput.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createTitledBorder("Input :"),
BorderFactory.createEmptyBorder(5,5,5,5)));
pnlAppInput.setLayout(new FlowLayout(FlowLayout.LEFT));
pnlAppInput.add(pnlAppLbl);
pnlAppInput.add(pnlAppTxt);
//pnlAppInput.setVisible(false);
//pnlAppTbl
pnlAppTbl.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createTitledBorder("Tbl :"),
BorderFactory.createEmptyBorder(5,5,5,5)));
//pnlAppTbl.setLayout(new BoxLayout(pnlAppTbl,BoxLayout.LINE_AXIS));
//pnlAppTbl.setLayout(new GridLayout(1,0));
pnlAppTbl.setLayout(new BorderLayout());
pnlAppTbl.add(scrollApp);
//pnlAppTblInput
pnlAppTblInput.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createTitledBorder("TblInput :"),
BorderFactory.createEmptyBorder(5,5,5,5)));
pnlAppTblInput.setLayout(new FlowLayout(FlowLayout.LEFT));
pnlAppTblInput.add(pnlAppTbl);
pnlAppTblInput.add(pnlAppInput);
//pnlApp
pnlApp.setLayout(new FlowLayout(FlowLayout.LEFT));
pnlApp.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createTitledBorder("Application :"),
BorderFactory.createEmptyBorder(5,5,5,5)));
//pnlApp.add(pnlAppTbl);
pnlApp.add(pnlAppTblInput);
//pnlHst
pnlHst.setLayout(new FlowLayout(FlowLayout.LEFT));
pnlHst.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createTitledBorder("History :"),
BorderFactory.createEmptyBorder(5,5,5,5)));
pnlHst.add(scrollHst);
//pnlMain
pnlMain.setLayout(new BoxLayout(pnlMain,BoxLayout.PAGE_AXIS));
pnlMain.setBorder(BorderFactory.createCompoundBorder(
null,
BorderFactory.createEmptyBorder(5,5,5,5)));
pnlMain.add(pnlHeader);
pnlMain.add(pnlApp);
pnlMain.add(pnlHst);
setSize(1015,712);
* PaoTableModel.java
* Created on December 15, 2006, 7:53 AM
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
package qis_dreamteam;
import java.text.Format;
import javax.swing.*;
import java.net.URL;
import java.util.Date;
import java.util.Vector;
import java.util.Timer;
import java.util.TimerTask;
import java.io.*;
import java.sql.*;
import java.lang.*;
import java.text.*;
import java.util.*;
import javax.swing.table.AbstractTableModel;
* @author JPQuilala
public class PaoTableModel extends AbstractTableModel {
Vector vData;
int colCount;
String[] headers;
String sSQL;
public PaoTableModel(String sSQL) {
DbManager oDB=new DbManager();
oDB.conQAPROD();
ResultSet oRS=oDB.execQuery(sSQL);
vData = new Vector();
try {
ResultSetMetaData metaData=oRS.getMetaData();
colCount = metaData.getColumnCount();
headers = new String[colCount];
for (int i = 1; i <= colCount; i++) {
headers[i - 1] = metaData.getColumnName(i);
while (oRS.next()) {
String[] sRecord = new String[colCount];
for (int i = 0; i < colCount; i++) {
sRecord[i] = oRS.getString(i + 1);
vData.addElement(sRecord);
} catch (SQLException ex) {
vData = new Vector();
ex.printStackTrace();
} finally {
oDB.disconnect();
public String getColumnName(int i) {
return headers[i];
public int getColumnCount() {
return colCount;
public int getRowCount() {
return vData.size();
public Object getValueAt(int row, int col) {
return ((String[]) vData.elementAt(row))[col];
this is the exact code... my problem is how can i set the JTable's size to be dependent on the JFrame and it should automaticaly adjust size when i inserted another JPanel.

Sorry, but I didn't read all the code... but if I could understand, the layout managers that you used adjust automatically with the window size. Another thing, it's not the table that you have to adjust. As the tables are in a jscrollpane, it's the size of the scrollpane that you have to adjust.
If you wan't a tip, try to use background color to visualize the size of your components. Sometimes, the table or another component is already adjusted, but the text or other components in it, it's not.

Similar Messages

  • Cant find suitable Layout  Manager

    Hello!
    I am doing a project where i allow user to drag an area on frame and then I should put a new JtextArea on that area. I have used the setBounds method of JTextArea to specify the location points but becoz of the layout manager (Flow Layout) it automatically shifts to other place in the frame.
    I have tried using other layouts but none helps to keep the textarea at specified place. Plz help!!

    Hi,
    You need to set the layout manager to null. This will allow you to specify size/location using setBounds.
    Regards,
    Ahmed Saad

  • Suitable layout manager for adding JToolbar?

    Hi there,
    I'm new to Java Swing. I'm looking to add a toolbar to the top of a JFrame. I've created a Grid layout with 3 rows and no columns. I've placed the JToolbar in the first row. Unfortunately, each row in the grid is of equal size so the toolbar is stretched to 1/3rd the size of the JFrame. I want to the toolbar to be standard size but I don't know how to resize the grid rows. I don't want to have to add more rows to reduce the size.
    Can anyone help me here? Or if you have a better layout manager suggestion.
    Thanks,
    Sean

    You can use the default BorderLayout of JFrame and add your JToolBar to the North.

  • Urgent: Layout Manager mess

    Hi everybody!
    I am trying to do a simple application that should draw a diagram on the screen. The diagram should look like this:
    a column of rectangles (I used JLabels) alternate with a column of vertical lines (again JLabels).
    To do so I've used a GridLayout for displaying the columns and inside the columns I've used a BoxLayout for arranging items.
    Here is the problem: now I have to connect the rectangles with the vertical lines using horizontal lines, but I don't know how to do this, unless I use absolute positioning.
    Any idea about that?
    Thanks

    Connecting the recangles to the verticals with horizontal lines?
    That's a bit unclear :)
    Connecting the vericals with horizontal lines would make crosses?
    Anyway it doesn't sound like a layout management problem, more like a painting problem.
    Maybe you wanna extend JComponent and overwrite paintComponent(Graphics g) and just draw
    with g.drawLine etc
    Seems like you are trying to make a table?
    Check out the JTable tutorial.
    It's not that straightforward, but just copying and pasting the tutorials code should get you an easy table.

  • Does anyone know how to win a fight with layout manager?

    I am using the form designer in netBeans to design my page, which has a jPanel on the left and a number of controls on the right.
    My problem is that when I eventually get it to look half right at design time, it looks different at run time. The fonts are different, the combo boxes are a different height and some of my text boxes are 4 times as wide. http://RPSeaman.googlepages.com/layout.GIF shows both the design-time view and the run-time view. How can I win my fight with layout manager?

    I'd like to do an experiment where you take say 20 pairs of students of java, with each pair matched in terms of prior programming and java experience, general knowledge, etc... and set one of each pair to learn Swing using netbeans and its layout generator with the other pair learning to code Swing by hand. Then 6 months later compare their abilities. I'll bet that the code by hand group will blow the other group out of the water in terms of understanding and ability.
    Just my 2 Sheckel's worth.

  • Delete Crystal Report Design in Report and Layout Manager

    Hi All
    How to permanently delete a customised Crystal Report Design imported in Report and Layout Manager?
    There is no Delete button at all unlike Form Design?
    Kedalene Chong

    Hi Nagarajan
    Please see image attached, already login as superuser but there is no Delete button for imported Crystal Report Design in Report and Layout Manager.

  • Placing components without layout manager not working

    Hey there, I am working on a java game version of pong which I have begun to try and do using Java Swing. The problem I am currently having is reposition the components in the main window part of the game which is were the user can start a new game or close the program. I having tried using the absolute positioning by setting the layout manager to null but then everything goes blank. I can't figure out why this is not working. Here is the code so far...
    import javax.swing.*;
    import java.awt.*;
    public class SwingPractice extends JFrame
        private Container contents;
        private JLabel titleLabel;
        private JButton startGameButton;
        public SwingPractice()
            super("SwingPractice");       
            contents = getContentPane();
            contents.setLayout(null);
            this.getContentPane().setBackground(Color.BLUE);
            startGameButton = new JButton("Start Game");
            startGameButton.setFont(new Font("Visitor TT1 BRK", Font.PLAIN, 24));
            startGameButton.setForeground(Color.cyan);
            startGameButton.setBackground(Color.blue);       
            startGameButton.setBounds(350,350, 75, 75);
            titleLabel = new JLabel("The Amazing Ping Pong Game!!");
            titleLabel.setForeground(Color.cyan);
            titleLabel.setBackground(Color.blue);
            titleLabel.setOpaque(true);
            titleLabel.setFont(new Font("Visitor TT1 BRK", Font.PLAIN, 24));
            titleLabel.setBounds(0,350, 75, 75);
            contents.add(startGameButton);
            contents.add(titleLabel);
            setSize(700,350);
            setResizable(false);
            setVisible(true);
        /*private class SwingPracticeEvents implements ActionListener
        public static void main(String [] args)
            SwingPractice window = new SwingPractice();
            window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       Any other critiquing would be greatly appreciated. Thank you.
    Edited by: 804210 on Oct 21, 2010 1:30 PM

    804210 wrote:
    Hey there, I am working on a java game version of pong which I have begun to try and do using Java Swing. The problem I am currently having is reposition the components in the main window part of the game which is were the user can start a new game or close the program. I having tried using the absolute positioning by setting the layout manager to nullDon't. Ever. Never. Well, mostly.
    Read the tutorial chapter about [url http://java.sun.com/docs/books/tutorial/uiswing/layout/index.html]Laying out components. It even features a section on absolute positioning - which you should skip reading, of course! :o)
    And read this old Sun topic: http://forums.sun.com/thread.jspa?threadID=5411066
    Edited by: jduprez on Oct 21, 2010 10:48 PM

  • Report & Layout Manager

    Hi,
    I have created User defined form. Now i have to display report when click on Preview button (Same as Standard document).
    Can we use report & layout manager to display report.
    Regards,
    Pravin

    Hello
    possible with development, and it is pending from the B1 version.
    Easy solutions are:
    - 8.81 you can use Crystal Reports and PLD
    - 2007 you can use PLD only or CR integration addon
    in Crystal:
    - You can create your layout and you can import into the system as report (not layout) into a specific folder
    - When you press the print or print preview button (eg menu action is indicated, menu id "520", "519"), then you can find the crystal report in the OCMN table with the following query
    select MenuUID from OCMN where Name = N'YOUR_REPORT_NAME'
    - next step is call the report with ActivateMenuItem and fill the parameters.
    Complete code for crystal
                Dim oRs As SAPbobsCOM.Recordset = oCompany.GetBusinessObject(BoObjectTypes.BoRecordset)
                Dim sQuery As String
                Dim sMenuID As String
                sQuery = "select MenuUID from OCMN where Name = N'YOUR_REPORT_NAME"
                oRs.DoQuery(sQuery)
                If oRs.Fields.Count > 0 Then
                    sMenuID = oRs.Fields.Item("MenuUID").Value.ToString
                    m_SBO_Application.ActivateMenuItem(sMenuID)
                    Dim oForm As SAPbouiCOM.Form = SBO_Application.Forms.ActiveForm
                    oForm.Items.Item("1000003").Specific.String = docentry
                    m_CrystalCriteriaFormID = oForm.UniqueID
                    oForm.Items.Item("1").Click(BoCellClickType.ct_Regular)
                Else : m_SBO_Application.MessageBox("NO PRINTING LAYOUT EXISTS!")
                End If
    In PLD, the logic is the same, but you must activate the User Queries print layout, and locate the report in the matrix.
    Regards
    János

  • Need suggestion regarding Layout Manager using Swing in Java

    I have developed a swing application where i am having problem with selecting the right layout manager.
    I am attaching the file where it contains the method for addingComponents to the Content Pane. But, the code that i have written
    contains lot of spaces between first panel and second panel and so forth.
    Please suggest.
    <<Code>>
    public void addComponentsToPane(Container contentPane) {
              this.contentPane = contentPane;
    //          File Panel
              JPanel jfile1panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
              JPanel jfile2panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
              JPanel jfile3panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
              JLabel jfile1 = new JLabel("Select File:");
              jtfile1 = new JTextField(50);
              jbfile1 = new JButton("Button1");
              jfile1panel.add(jfile1);
              jfile1panel.add(jtfile1);
              jfile1panel.add(jbfile1);
              jbfile1.addActionListener(this);
              JLabel jfile2 = new JLabel("Select File:");
              jtfile2 = new JTextField(50);
              jbfile2 = new JButton("Button2");
              jfile2panel.add(jfile2);
              jfile2panel.add(jtfile2);
              jfile2panel.add(jbfile2);
              jbfile2.addActionListener(this);
              JLabel jfile3 = new JLabel("Select File:");
              jtfile3 = new JTextField(50);
              jbfile3 = new JButton("Button3");
              jfile3panel.add(jfile3);
              jfile3panel.add(jtfile3);
              jfile3panel.add(jbfile3);
              jbfile3.addActionListener(this);
              //Button Panel
              JPanel jbuttonpanel = new JPanel();
              jbuttonpanel.setLayout(new FlowLayout(FlowLayout.CENTER));
              JButton jbcmd1 = new JButton("Submit");
              JButton jbcmd2 = new JButton("Cancel");
              jbuttonpanel.add(jbcmd1);
              jbuttonpanel.add(jbcmd2);
              jbcmd1.addActionListener(this);
              jbcmd2.addActionListener(this);
              //Content Pane               
              contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
              contentPane.add(jfile1panel);
              contentPane.add(jfile2panel);
              contentPane.add(jfile3panel);
              contentPane.add(jbuttonpanel);
    }

    But, the code that i have written contains lot of spaces between first panel and second panel and so forth.use pack(), see if it makes a difference
    as you're using FlowLayout, make the frame not resizable

  • Layout manager issue.

    I was hoping that someone could shed some light on why one layout manage will allow an applet to be inserted in a class that extends JFrame but not another.
    Here is the guts of the problem I have an class that extends applet to display a pie chart. I then have a seperate class that extends JFrame that display two input boxes and a button. When the user enters two fields and clicks draw the pie chart displays working with the two numbers. The JFrame class that works uses the border layout. I change the class to use gridbag, and now only the textboxes display. Can anyone help. Here is the code for the three classes.
    This is the applet class....
    * File: PieChart.java
    * PieChart class is an Swing applet that use a pie chart
    * to show the percentage. It is used by PieChartExample
    * to show what percetange of a payment actually goes to
    * pay interest. There is no error handling in the program.
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import javax.swing.*;
    public class PieChart extends JApplet {
    final static Color bg = Color.white;
    final static Color fg = Color.black;
    private double percent;
    public void init() {
    //Initialize drawing colors
    setBackground(bg);
    setForeground(fg);
    percent = 1.0;
         public void setPercentage(double pct) {
              this.percent = pct;
    public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setPaint(fg);
    drawAnnotation(g2);
    drawArc(g2, percent);
    public void drawAnnotation(Graphics2D g2) {
              // draw a small green circle
              g2.setPaint(Color.green);
    g2.fill(new Ellipse2D.Double(200, 200, 10,10));
    // draw a small red circle
    g2.setPaint(Color.red);
    g2.fill(new Ellipse2D.Double(270, 200, 10, 10));
    g2.setPaint(Color.black);
    g2.drawString("Interest", 210, 210); // write "Interest" by green circle
    g2.drawString("Principal", 280, 210); // write "Principal" by red circle
         public void drawArc(Graphics2D g2, double percent) {
    // draw the interest portion
              g2.setPaint(Color.green);
              g2.fill(new Arc2D.Double(10,10,200,200, 0, percent * 360, Arc2D.PIE));
              // draw the rest (principal portion)
              g2.setPaint(Color.red);
              g2.fill(new Arc2D.Double(10,10,200,200, percent * 360, (1-percent)*360, Arc2D.PIE));
    This is the JFrame class using Boarderlayout that works.
    * File: PieChartExample.java
    * The program demonstrate a simple use of pie chart. It takes total
    * payment and interest paid from user input and draws a pie chart
    * to show the percentage of interert to total payment. There is no
    * error handling whatsoever in the example program, so you can see
    * that it can be broken easily.
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import javax.swing.*;
    public class PieChartExample extends JFrame {
         final static int CHART_WIDTH = 800;
         final static int CHART_HEIGHT = 300;
         JPanel panel ;
         JLabel paymentLabel;
         JTextField paymentField;
         JLabel interestLabel;
         JTextField interestField;
         JButton show;
    PieChart applet;
    public PieChartExample() {
    super("Pie Chart Example");
    panel = new JPanel();
    paymentLabel = new JLabel("Payment: $");
    panel.add(paymentLabel);
    paymentField = new JTextField(10);
    panel.add(paymentField);
    interestLabel = new JLabel("Interest: $");
    panel.add(interestLabel);
    interestField = new JTextField(10);
    panel.add(interestField);
    show = new JButton("Draw");
    panel.add(show);
    this.getContentPane().add("North", panel);
    applet = new PieChart();
    this.getContentPane().add("Center", applet);
    show.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent evt) {
                        double interest = Double.parseDouble(interestField.getText());
                        double payment = Double.parseDouble(paymentField.getText());
                        double percent = interest / payment;
                        //System.out.println("In event handler, percent is " + percent);
                        applet.setPercentage(percent);
                        applet.repaint();
    private static void createAndShowGUI() {
    PieChartExample f = new PieChartExample();
    f.pack();
    f.setSize(new Dimension(CHART_WIDTH ,CHART_HEIGHT));
    f.show();
    public static void main(String[] args) {
    //Schedule a job for the event-dispatching thread:
    //creating and showing this application's GUI.
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    createAndShowGUI();
    This is the modified class to use GridBag that fails.
    * File: PieChartExample2.java
    * The program demonstrate a simple use of pie chart. It takes total
    * payment and interest paid from user input and draws a pie chart
    * to show the percentage of interert to total payment. There is no
    * error handling whatsoever in the example program, so you can see
    * that it can be broken easily.
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import javax.swing.*;
    public class PieChartExample2 extends JFrame {
         final static int CHART_WIDTH = 800;
         final static int CHART_HEIGHT = 300;
         JPanel panel ;
         JLabel paymentLabel;
         JTextField paymentField;
         JLabel interestLabel;
         JTextField interestField;
         JButton show;
    PieChart applet;
    public PieChartExample2() {
    super("Pie Chart Example");
    // Get container and set layout manager
    Container contentPane = getContentPane();
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    contentPane.setLayout(gridbag);
    c.fill = GridBagConstraints.HORIZONTAL;
    panel = new JPanel();
    paymentLabel = new JLabel("Payment: $");
    panel.add(paymentLabel);
    paymentField = new JTextField(10);
    panel.add(paymentField);
    interestLabel = new JLabel("Interest: $");
    panel.add(interestLabel);
    interestField = new JTextField(10);
    panel.add(interestField);
    show = new JButton("Draw");
    panel.add(show);
    c.gridx = 0;
    c.gridy = 0;
    gridbag.setConstraints(panel, c);
    contentPane.add(panel);
    applet = new PieChart();
    c.gridx = 0;
    c.gridy = 1;
    gridbag.setConstraints(applet, c);
    contentPane.add(applet);
    show.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent evt) {
                        double interest = Double.parseDouble(interestField.getText());
                        double payment = Double.parseDouble(paymentField.getText());
                        double percent = interest / payment;
                        //System.out.println("In event handler, percent is " + percent);
                        applet.setPercentage(percent);
                        applet.repaint();
    private static void createAndShowGUI() {
    PieChartExample2 f = new PieChartExample2();
    f.pack();
    f.setSize(new Dimension(CHART_WIDTH ,CHART_HEIGHT));
    f.show();
    public static void main(String[] args) {
    //Schedule a job for the event-dispatching thread:
    //creating and showing this application's GUI.
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    createAndShowGUI();
    }

    Ok. It seems I may be wrong and that this may not be a concurrent call issue. I overode the components setBounds and setLocation methods and it appears that an external class is updating the position of these components while layoutContainer is attempting to position them. I can see that the correct positions are being set in the setBounds method, but this is happening after layoutContainer has called getLocation on the components. To be a little more specific, I am using a JLayeredPane to display some overlapping JLabels with images. I have implemented drag and drop on these labels so that dropping one on another swaps the images. The label positions and sizes are not being changed during the drop (I don't want them to move or resize just change images). However, for some reason I have yet to discover, two calls to set bounds are being made on the labels. The first call is relocating the label to the second labels position, the second call is relocating the label back to it's original position. If anyone has any insight on why the label position are changing when I am not explicitly repositioning them please reply. I will post another reply when I have corrected the problem or found a work around for it. I am awarding the dukes to tjacobs1 since he was the only responses I've had so far.

  • Layout Management in Table Control

    Hi Dialog Programming Experts,
    I have a new requirement - adding Layout Management options in Table Control. This is dialog/module programming, not ALV Report. Is there a function module for this?
    Thanks so much in advance for your help.
    Regards,
    Joyreen

    Hi
    For filter use the following function modules,
    l_rightx-id = l_index.
      l_rightx-fieldname = 'DESCR'.
      l_rightx-text = text-054.
      APPEND l_rightx TO i_rightx.
      l_index = l_index + 1.
      CLEAR l_rightx.
      l_rightx-id = l_index.
      l_rightx-fieldname = 'DEL_CM'.
      l_rightx-text = text-055.
      APPEND l_rightx TO i_rightx.
    CALL FUNCTION 'CEP_DOUBLE_ALV'
           EXPORTING
                i_title_left  = text-034
                i_title_right = text-035
                i_popup_title = text-036
           IMPORTING
                e_cancelled   = l_cancelled
           TABLES
                t_leftx       = i_leftx[]
                t_rightx      = i_rightx[].
    Firstly populate the right table with all fields which you want in the filtering condition. The left table will be populated once the use selects some fields and transfer it to the left portion of the dialog.
    Then use the following FM like this.
    DATA: i_group TYPE lvc_t_sgrp.
          CALL FUNCTION 'LVC_FILTER_DIALOG'
               EXPORTING
                    it_fieldcat   = i_fldcat1
                    it_groups     = i_group
               TABLES
                    it_data       = i_ziteminvoice[]
               CHANGING
                    ct_filter_lvc = i_filter
               EXCEPTIONS
                    no_change     = 1
                    OTHERS        = 2.
    here filter table should have fields from left table above.
    Once you get the filter data, populate range table for each fields and then delete your internal table using these range.
    CASE l_filter-fieldname.
                  WHEN 'ITMNO'.
                    l_itmno-sign = l_filter-sign.
                    l_itmno-option = l_filter-option.
                    l_itmno-low = l_filter-low.
                    l_itmno-high = l_filter-high.
                    APPEND l_itmno TO li_itmno.
                    CLEAR l_itmno.
    DELETE i_ziteminvoice WHERE NOT  itmno IN li_itmno OR
                                          NOT  aedat IN li_aedat OR...
    First check this if it works, else let me know.
    Thanks
    Sourav.

  • Missing reports in Report and Layout manager

    Hi Experts,
    i need to convert with Crystal Converter some PLD Tax reports.
    The problem is that under Tax Reports tree, in report and layout manager, reports of typecode 'RB01' are missing!
    Why are they missing??
    Is there any other way to convert them even if missing?
    i can see them in the tax report form, selecting tax register block and press ok.
    From the print layout designer they are listed.
    Please help.
    Thanks
    Paolo

    Hi Paolo,
    What is your B1 PL? Have you solved your problem? Try to upgrade to the latest PL if you are not in it.
    Thanks,
    Gordon

  • The most precise layout manager

    It's time to decide on a layout. My java game screen is a fairly complex jumble of info in little boxes here and there. Everywhere.
    I'm not a java pro yet, but am I correct in thinking that there is -no- pixel grid layout manager? Meaning, I could define the coords for each element? I don't think there is one like that.
    All that being said, what java layout manager gives you the most precise control over element placement? It looks like the Box or GridBag, but I'm not certain.
    Thank you in advance for your expert oppinion :-)
    Mark Deibert

    From my experience I've found that using a combination
    of layout managers works best for fine tuning things.
    For example you can create a panel for your buttons
    implementing a flow layout then a panel for your
    checkboxes using a gridbag layout etc.
    The code might not be as neat as using a single
    manager but it does give you more control on where
    things go by breaking the GUI up into more manageable
    pieces.I agree with that - I really never use absolute postioning. Think in an object oriented way when you choose LayoutManagers - arrange all components, that are displayable by the same LayoutManager in a separate JPanel with this LayoutManager - add only those components, which are in the same context to that, what this JPanel should do.
    For example - when you want some buttons to show up in the center of JPanel, use two JPanels, one with FlowLayout, where you add the buttons, and add this JPanel to a second one with BorderLayout to its center. If you now want to place these buttons to the bottom of another panel, you easily add it to a JPanel with BorderLayout to its bottom - the hole JPanel, not the buttons. That is also quite fine if you want to repostion those functional units later on - components, that are in a relation to each other will stay together this way and must not be repositioned component by component.
    greetings Marsian

  • JAVAFX have FANTASTIC LAYOUT MANAGER!

    NEW version 2.2!!! is new from 2.1
    I find a fantastic layout for javafx, it is static and dynamc with Scene. You can create special indipendent rows and set all cols and rows size. Is better than java layout. You can create span cols. You can set grow in vertical and horizontal. You can set alignment and other. It is user friendly and simple to use for all. Is easy create form and panel with this layout.
    He's name is DigLayout. For tutorial and samples:
    See articles in jfxstudio web site: http://jfxstudio.wordpress.com/2009/03/05/new-advanced-javafx-layout-manager-diglayout-from-jdlayout-library/
    See official project webpage: http://code.google.com/p/diglayout/
    simple to use:
    import Window.JDLayout.;
    import javafx.stage.Stage;
    import javafx.scene.Scene;
    import javafx.scene.text.Text;
    import javafx.scene.text.Font;
    import javafx.scene.effect.;
    /   @author Diego Benna [email protected]
    var panel = DigLayout?{
            // All setting
           // Rows and Items
            digrows:[
                    Row{
                            items:[
                                    Item{
                                            valign:"middle"
                                            halign:"center"
                                            item:
                                                    javafx.ext.swing.SwingLabel? {
                                                            text: "Item 1"
                                    Item{
                                            valign:"middle"
                                            halign:"center"
                                            item:
                                                    javafx.ext.swing.SwingLabel? {
                                                            text: "Item 2"
                    Row{
                            items:[
                                    Item{
                                            valign:"middle"
                                            halign:"center"
                                            item:
                                                    javafx.ext.swing.SwingLabel? {
                                                            text: "Item 3"
                                    Item{
                                            valign:"middle"
                                            halign:"center"
                                            item:
                                                    javafx.ext.swing.SwingLabel? {
                                                            text: "Item 4"
    Stage{
            title : "UnitTest? Simple Panel"                                       
            scene : Scene{
                width: 540
                 height: 370
                content: [
                    panel
    What do you think??

    DiegoBenna wrote:
    NEW version 2.2!!! is new from 2.1
    I find a fantastic layout for javafx
    What do you think??I think you are doing a bit too much advertisements for your product, and pretending to "find" it when you made it is on the limit of honesty.
    I think I dislike CRYING OUT loud with capitals in forums and mailing lists.
    I think you are right to present your product, and you probably made a good product, but such marketing ploys don't make me feeling like trying it.
    Just my opinion, perhaps too arrogant, and certainly more looking upset than I am actually, but I felt I had to let you know, in case you wonder why you have so little reactions to your messages... :-) I don't mean to be offensive, somehow I try to help (otherwise I would just shut up and go my way).
    Have a good day and I sincerely wish your product will become as popular as it deserves.

  • Layout manager for a Windows type toolbar

    I have made a layout manager that when there is not enough room to put all the buttons it stores them inside a "subMenu" that appears at the end of the tool bar. Unfortunally the perfered size is not being calculated correctly so when the user makes the toolbar floatable it doesn't make the toolbar long enough.
    Here is my code:
    * ExpandLayout.java
    * Created on May 29, 2003, 3:17 PM
    package edu.cwu.virtualExpert.caseRecorder;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    * @author  subanark
    public class ExpandLayout implements java.awt.LayoutManager
        private JPopupMenu extenderPopup = new JPopupMenu();
        private JButton extenderButton = new JButton(new PopupAction());
        /** Creates a new instance of ExpandLayout */
        public ExpandLayout()
        protected class PopupAction extends AbstractAction
            public PopupAction()
                super(">");
            public void actionPerformed(ActionEvent e)
                JComponent component = (JComponent)e.getSource();
                extenderPopup.show(component,0,component.getHeight());
        /** If the layout manager uses a per-component string,
         * adds the component <code>comp</code> to the layout,
         * associating it
         * with the string specified by <code>name</code>.
         * @param name the string to be associated with the component
         * @param comp the component to be added
        public void addLayoutComponent(String name, Component comp)
         * Lays out the specified container.
         * @param parent the container to be laid out
        public void layoutContainer(Container parent)
            Dimension parentSize = parent.getSize();
            Dimension prefSize = preferredLayoutSize(parent);
            Insets insets = parent.getInsets();
            int x = insets.left;
            int y = insets.top;
            parentSize.width -= insets.right;
            int i;
            for(int j = 0; j < extenderPopup.getComponentCount();)
                Component aComponent = extenderPopup.getComponent(j);
                parent.add(aComponent);
            parent.remove(extenderButton);
            //System.out.println("Component count:"+parent.getComponentCount());
            for(i = 0; i < parent.getComponentCount() &&
                       parent.getComponent(i).getPreferredSize().width +(i==parent.getComponentCount()-1?0:extenderButton.getPreferredSize().width) + x < parentSize.width;i++)
                //System.out.println("exSize"+(parent.getComponent(i).getPreferredSize().width +extenderButton.getPreferredSize().width + x));
                Component aComponent = parent.getComponent(i);
                if(aComponent != extenderButton)
                    aComponent.setSize(aComponent.getPreferredSize());
                    aComponent.setLocation(x,y);
                    x += aComponent.getPreferredSize().width;
                    //System.out.println(aComponent.getX());
            if(i < parent.getComponentCount())
                while(i < parent.getComponentCount())
                    //System.out.println("Need Room");
                    extenderPopup.add(parent.getComponent(i));
                //System.out.println("extenderButton added");
                parent.add(extenderButton);
                extenderButton.setSize(extenderButton.getPreferredSize());
                extenderButton.setLocation(x,y);
                x += extenderButton.getPreferredSize().width;
                //System.out.println(extenderButton);
            else
                //System.out.println("extenderButton removed");
                parent.remove(extenderButton);
                //System.out.println("Component count:"+extenderButton.getComponentCount());
         * Calculates the minimum size dimensions for the specified
         * container, given the components it contains.
         * @param parent the component to be laid out
         * @see #preferredLayoutSize
        public Dimension minimumLayoutSize(Container parent)
            return extenderButton.getMinimumSize();
        /** Calculates the preferred size dimensions for the specified
         * container, given the components it contains.
         * @param parent the container to be laid out
         * @see #minimumLayoutSize
        public Dimension preferredLayoutSize(Container parent)
            Dimension d = new Dimension();
            d.width += parent.getInsets().right+parent.getInsets().left;
            for(int i = 0; i < parent.getComponents().length;i++)
                if(parent.getComponent(i) != extenderButton)
                    d.width+=parent.getComponent(i).getPreferredSize().width;
                    d.height = Math.max(d.height,parent.getComponent(i).getPreferredSize().height);
            for(int i = 0; i < extenderPopup.getComponentCount();i++)
                d.width+=extenderPopup.getComponent(i).getPreferredSize().width;
                d.height = Math.max(d.height,extenderPopup.getComponent(i).getPreferredSize().height);
            d.height += parent.getInsets().top+parent.getInsets().bottom+5;
            return d;
        /** Removes the specified component from the layout.
         * @param comp the component to be removed
        public void removeLayoutComponent(Component comp)
        public static void main(String[] argv)
            JFrame f = new JFrame();
            JToolBar toolBar = new JToolBar();
            toolBar.setLayout(new ExpandLayout());
            toolBar.add(new JButton("hello"));
            toolBar.add(new JButton("Hello2"));
            toolBar.add(new JButton("Hello3"));
            toolBar.add(new JButton("Hi"));
            f.getContentPane().setLayout(new BorderLayout());
            f.getContentPane().add(toolBar,BorderLayout.NORTH);
            f.setBounds(0,0,300,300);
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setVisible(true);
    }

    This is a wierd one. I noticed that the width of a button is 22 pixels larger in the popup menu that it is in the toolbar.I traced this down to the insets being changed when the button is added to the toolbar. The strange part is that the size of the component keeps changing as you move it from the toolbar to the popup menu and back.
    Anyway, I ended up changing most of you code. Here is my version:
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    * @author subanark
    public class ExpandLayout implements java.awt.LayoutManager
         private JPopupMenu extenderPopup = new JPopupMenu();
         private JButton extenderButton = new JButton(new PopupAction());
         /** Creates a new instance of ExpandLayout */
         public ExpandLayout()
         /** If the layout manager uses a per-component string,
         * adds the component <code>comp</code> to the layout,
         * associating it
         * with the string specified by <code>name</code>.
         * @param name the string to be associated with the component
         * @param comp the component to be added
         public void addLayoutComponent(String name, Component comp)
         * Lays out the specified container.
         * @param parent the container to be laid out
         public void layoutContainer(Container parent)
              //  Position all buttons in the container
              Insets insets = parent.getInsets();
              int x = insets.left;
              int y = insets.top;
              int spaceUsed = insets.right + insets.left;
              for (int i = 0; i < parent.getComponentCount(); i++ )
                   Component aComponent = parent.getComponent(i);
                   aComponent.setSize(aComponent.getPreferredSize());
                   aComponent.setLocation(x,y);
                   int componentWidth = aComponent.getPreferredSize().width;
                   x += componentWidth;
                   spaceUsed += componentWidth;
              //  All the buttons won't fit, add extender button
              //  Note: the size of the extender button changes once it is added
              //  to the container. Add it here so correct width is used.
              int parentWidth = parent.getSize().width;
              if (spaceUsed > parentWidth)
                   parent.add(extenderButton);
                   extenderButton.setSize( extenderButton.getPreferredSize() );
                   spaceUsed += extenderButton.getSize().width;
              //  Remove buttons that don't fit and add to the popup menu
              while (spaceUsed > parentWidth)
                   int last = parent.getComponentCount() - 2;
                   Component aComponent = parent.getComponent( last );
                   parent.remove( last );
                   extenderPopup.insert(aComponent, 0);
                   extenderButton.setLocation( aComponent.getLocation() );
                   spaceUsed -= aComponent.getSize().width;
         * Calculates the minimum size dimensions for the specified
         * container, given the components it contains.
         * @param parent the component to be laid out
         * @see #preferredLayoutSize
         public Dimension minimumLayoutSize(Container parent)
              return extenderButton.getMinimumSize();
         /** Calculates the preferred size dimensions for the specified
         * container, given the components it contains.
         * @param parent the container to be laid out
         * @see #minimumLayoutSize
         public Dimension preferredLayoutSize(Container parent)
              //  Move all components to the container and remove the extender button
              parent.remove(extenderButton);
              while ( extenderPopup.getComponentCount() > 0 )
                   Component aComponent = extenderPopup.getComponent(0);
                   extenderPopup.remove(aComponent);
                   parent.add(aComponent);
              //  Calculate the width of all components in the container
              Dimension d = new Dimension();
              d.width += parent.getInsets().right + parent.getInsets().left;
              for (int i = 0; i < parent.getComponents().length; i++)
                   d.width += parent.getComponent(i).getPreferredSize().width;
                   d.height = Math.max(d.height,parent.getComponent(i).getPreferredSize().height);
              d.height += parent.getInsets().top + parent.getInsets().bottom + 5;
              return d;
         /** Removes the specified component from the layout.
         * @param comp the component to be removed
         public void removeLayoutComponent(Component comp)
         protected class PopupAction extends AbstractAction
              public PopupAction()
                   super(">");
              public void actionPerformed(ActionEvent e)
                   JComponent component = (JComponent)e.getSource();
                   extenderPopup.show(component,0,component.getHeight());
         public static void main(String[] argv)
              JFrame f = new JFrame();
              JToolBar toolBar = new JToolBar();
              toolBar.setLayout(new ExpandLayout());
              toolBar.add(new JButton("hello"));
              JButton button = new JButton("Hello2");
              System.out.println( button.getInsets() );
              toolBar.add(button);
              System.out.println( button.getInsets() );
              toolBar.add(new JButton("Hello3"));
              toolBar.add(new JButton("Hi"));
              f.getContentPane().setLayout(new BorderLayout());
              f.getContentPane().add(toolBar,BorderLayout.NORTH);
              f.setBounds(0,0,300,300);
              f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              f.setVisible(true);
    }

Maybe you are looking for

  • Tolerance limits at Schedule line level in PO

    Hi How to make tolerance limits at schedule line level in PO, (not at item level) Thanks Raju

  • Lr 4.1RC GPS metadata not read in CR2 files on Synch

    After importing CR2 files from a Canon 5dMkii I later updated those files with GPS coordinates using the program GeoSetter (www.geosetter.de).  The program is a GUI front end to ExifTool that adds the coordinates to the CR2 or JPG files. After the fi

  • Fonts display wrong in Final Cut Pro

    One of the other editors in the office put together this piece and now I am making some changes to it on my machine. We're using the font "Baskerville" a common font that comes on the computer, and it is showing up correctly in the Font Book, but it

  • Forms6i and Beans

    Hi, We had some problems implementing JavaBeans in our Forms 6i would appreciate it if anybody can send us more information for the topics mentioned below. -- Can JavaBeans be implemented in a client/server environment or does it only work in a three

  • Display datas on data block based on a criteria

    hi.. how can i manipulate my data block such as it could only display the output based on a certain criteria enter by a user ex. select * from IT where account_no = :txtacctno null