Search Results

Search found 1571 results on 63 pages for 'swing'.

Page 33/63 | < Previous Page | 29 30 31 32 33 34 35 36 37 38 39 40  | Next Page >

  • JTable - Getting a cell into Edit mode on pressing Tab

    - by Luhar
    This is possibly has a trivial solution, but I am at the end of my tether so I hope somebody can help out. I use a JTable which has a custom renderer and a custom editor for a set of columns. The renderer uses a JLabel component and the editor uses a JSpinner component. Our users want to be able to enter values in a column, and then press TAB or ENTER to move to the next editable cell in the table. If I understand correctly, this is the default behaviour for a JTable. However, this doesn't seem to work correctly for me. Until the user clicks on the cell, only the JLabel is displayed. The JSpinner (i.e. CellEditor) is only displayed when a user double clicks on the cell. So, it looks like the cell is going into "edit" mode only on MouseEvents, but not when it has focus. How do I get the cell to go into edit mode as soon as it has focus?

    Read the article

  • My Jtable is blank

    - by mazin
    Hello my q is about a jtable that i have ,i fill it with components from a .txt ,I have a main (menu ) JFrame and by pressing a jbutton i want the jtable to pop out ! My problem is that my jtable is blank and it supposed to show some date !I would appreciated any help , Thanks. this is my ''reading'' class` public static void main(String[] args) { company Company=new company(); payFrame jframe=new payFrame(Company); jframe.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE); jframe.setSize(600,300); jframe.setVisible(true); readClass(); } //diavasma public static void readClass(){ ArrayList<Employee> emp =new ArrayList<Employee>() ; //Employee[] emp=new Employee[7]; //read from file try { int i=0; // int rowCounter; // int payments=0; String inputDocument = ("src/Employees.txt"); FileInputStream is = new FileInputStream(inputDocument); Reader iD = new InputStreamReader(is); BufferedReader buf = new BufferedReader(iD); String inputLine; while ((inputLine = buf.readLine()) != null) { String[] lineParts = inputLine.split(","); String email = (lineParts[7]); int EmpNo = Integer.parseInt(lineParts[0]); String type = lineParts[10]; int PostalCode = Integer.parseInt(lineParts[5]); int phone = Integer.parseInt(lineParts[6]); int DeptNo = (short) Integer.parseInt(lineParts[8]); double Salary; int card = (short) Integer.parseInt(lineParts[10]); int emptype = 0; int hours=Integer.parseInt(lineParts[11]); if (type.equals("FULL TIME")) { emptype = 1; } else if (type.equals("SELLER")) { emptype = 2; } else { emptype = 3; } /** * Creates employee instances depending on their type of employment * (fulltime=1, salesman=2, parttime=3) */ switch (emptype) { case 1: Salary = Double.parseDouble(lineParts[10]); emp.add(new FullTime(lineParts[1], lineParts[2], EmpNo, lineParts[3], lineParts[4], PostalCode, phone, email, DeptNo, card, Salary,hours, type)); i++; break; and this is my class where i make my Jtable and fill him public class company extends JFrame { private ArrayList<Employee> emp = new ArrayList<Employee>(); public void addEmployee(Employee emplo) { emp.add(emplo); } public ArrayList<Employee> getArray() { return emp; } public void getOption1() { ArrayList<Employee> employee = getArray(); JTable table = new JTable(); DefaultTableModel model = new DefaultTableModel(); table.setModel(model); model.setColumnIdentifiers(new String[]{"Code", "First Name", "Last Name", "Address", "City", "Postal Code", "Phone", "Email", "Dept Code", "Salary", "Time Card", "Hours"}); for (Employee current : employee) { model.addRow(new Object[]{current.getempCode(), current.getfirst(), current.getlast(), current.getaddress(), current.getcity(), current.getpostalCode(), current.gettelephone(), current.getemail(), current.getdep(), current.getsalary(), current.getcardcode(), current.getHours() }); } table.setPreferredScrollableViewportSize(new Dimension(500, 50)); table.setFillsViewportHeight(true); JScrollPane scrollPane = new JScrollPane(table); add(scrollPane); setVisible(true); table.revalidate();

    Read the article

  • Does Java Mac OSX native look and feel respect UIManager font changes?

    - by Erik Lickerman
    I have a java applet and the only look and feel that works properly is the native mac one. I wanted to make the fonts a bit larger and tried using the standard UIManager methods UIManager.put("Label.font", new Font("Georgia", Font.PLAIN, 18)); This produces no change. It does not throw an exception, of course. Does anyone know if the native mac look and feel ignores these? I know there are specific ways to make controls different sizes on mac but these only seem to make them smaller. You cannot make the controls larger than regular.

    Read the article

  • Change size of ImageIcon in a JRadioButton

    - by Frederik Wordenskjold
    I simply want to change the size (diameter) of the actual (default) ImageIcon of my JRadioButton. I've changed the size of the font displayed in the widget, so it really looks silly with such a large radiobutton. JRadioButton button = new JRadioButton("Button"); button.setFont(new Font("Lucida Grande",Font.PLAIN, 11)); gives me this giant button: Do I really have to create my own ImageIcon? Or can I somehow scale the default one, without too much of a hassle?

    Read the article

  • About GridLayout.

    - by Knowing me knowing you
    Hi, if I have code like so: class X extends JFrame { X() { setLayout(new GridLayout(3,3)); JButton b = new JButton("A-ha"); /*I would like to add this button in the center of this grid (2,2)*/ //How can I do it? } }; Thanks.

    Read the article

  • How to check whether the tab is active or not in JTabbedPane?

    - by Supereme
    Hi, How to check whether a tab in JTabbedPane instance is active or not, in the class of the tab(nested class) itself and not in the enclosing class? I know that there is a method 'booloean isEnabledAt(int index)'; but this method can only be called in the enclosing class whereas I want to check whether the tab is currently selected or not in the tab class (nested class) itself. Can anybody please suggest me something? Thank you!

    Read the article

  • JButton Image Ignoring GridBagConstraints

    - by daemor
    I am working on an application and have a screen that needs to have elements (namely some custom JButtons) appear and disappear based on a user selection. However for some reason, when I add these buttons to their pane, the buttton image goes to the top corner, and leaves the text in the center, completely ignoring GridBagConstraints. I am completely stumped on this one as I have done this same exact thing dozens of times earlier in the program without any issues. Here is an image of the problem: The problem is in this method here, and occurs down towards the bottom. public void init(){ contentPane.removeAll(); // Setup jlabels JLabel countyLabel = new JLabel("County"); countyLabel.setFont(new Font("Times New Roman", Font.PLAIN, 18)); JLabel measureByLabel = new JLabel("Measure By: "); measureByLabel.setFont(new Font("Times New Roman", Font.PLAIN, 18)); String[] countyChoices = {"Washtenaw", "Oakland", "Livingston"}; // setup components JComboBox<String> countyCombo = new JComboBox<String>(countyChoices); // place baseComponents c.weightx = 0.5; c.weighty = 0.5; c.gridx = 0; c.gridy = 0; c.anchor = GridBagConstraints.NORTH; contentPane.add(countyLabel, c); c.gridx = 2; contentPane.add(countyCombo, c); c.gridy = 1; c.gridx = 0; contentPane.add(trenchButton, c); c.gridx = 2; contentPane.add(bedButton, c); c.gridy = 2; c.gridx = 1; contentPane.add(systemSelection, c); c.gridy = 3; c.gridx = 0; contentPane.add(lengthButton, c); c.fill = GridBagConstraints.BOTH; c.gridwidth = 4; c.gridy = 4; c.gridx = 0; contentPane.add(choicePane, c); GridBagConstraints con = new GridBagConstraints(); con.weightx = 0.5; con.weighty = 0.5; con.gridx = 0; con.gridy = 0; choicePane.add(lengthButton, c); // revalidate and repaint choicePane.revalidate(); choicePane.repaint(); contentPane.revalidate(); contentPane.repaint(); } I have tried doing this in separate methods, the button looks fine when added to the contentPane, the pane is for sure set to gridbagconstraints as I used the expression JPanel choicePane = new JPanel(new GridBagLayout()) to initialize it.

    Read the article

  • paintComponent on JPanel, image flashes and then disappears

    - by mark
    I have a JApplet (MainClass extends JApplet), a JPanel (ChartWindow extends JPanel) and a Grafico class. The problem is that the Grafico class instance has 2 JPanel that should show 2 images (1 for each panel) but the images are shown and after a little while they disappears: instead of them i get a gray background (like an empty JPanel). This happens for every repaint() call (that are made in the ChartWindow class) the MainClass init() contains chartwindow=new ChartWindow(); add(chartwindow) chartwindow has a Grafico instance. it's the ChartWindow's paintComponent (override) paintComponent(Graphics g) { super.paintComponent(g); Image immagineGrafico=createImage(grafico.pannelloGrafico.getWidth() ,grafico.pannelloGrafico.getHeight()); Image immagineVolumi=createImage(grafico.pannelloVolumi.getWidth() ,grafico.pannelloVolumi.getHeight()); Graphics2D imgGrafico=(Graphics2D)immagineGrafico.getGraphics(); Graphics2D imgVolumi=(Graphics2D)immagineVolumi.getGraphics(); grafico.draw(imgGrafico,imgVolumi,mouseX,mouseY); ((Graphics2D)grafico.pannelloGrafico.getGraphics()).drawImage(immagineGrafico,0,0,this); ((Graphics2D)grafico.pannelloVolumi.getGraphics()).drawImage(immagineVolumi,0,0,this); } grafico's JPanels are added this way in the ChartWindow's constructor grafico=new Grafico() ................ add(grafico.pannelloGrafico); add(grafico.pannelloVolumi); Tell me if you need more information, thank you very much :-)

    Read the article

  • How to use this Color's constructor? Java

    - by MaxMackie
    According to Oracle's site, the class Color has a constructor that accepts a single int value which represents an RGB value. http://download.oracle.com/javase/1.4.2/docs/api/java/awt/Color.html#Color(int) An RGB color is actually three different numbers ranging from 0-255. So combining them together to make one int would look like this: White 255,255,255 White 255255255 Right? So I pass this to the constructor and get a vibrant teal color. What am I doing wrong? What haven't I understood?

    Read the article

  • Cast Object to JTable?

    - by Chris
    I am trying to implement a ListSelectionListener for some of my JTables. Simply (at the moment) the ListSelectionListener is supposed to simply return the text of the cell that was selected. My program design has several JTables and I would like to have one ListSelectionListener work for them all. In the valueChanged event of the ListSelectionListener I thought it was possible to do something like: private class SelectionHandler implements ListSelectionListener { public void valueChanged(ListSelectionEvent e) { JTable table = (JTable)e.getSource(); String data = (String) table.getValueAt(table.getSelectedRow(), 0); // Print data } } But when I do this I a ClassCastException error. Is there a way to do something like this? One solution I thought of was to compare the source of the event (e.getSource()) to all my JTables to see if they were equivalent (big if block) and then just calling .getValueAt inside that block but that would making the code in the future difficult if tables were to be added or removed.

    Read the article

  • What if a large number of objects are passed to my SwingWorker.process() method?

    - by Trejkaz
    I just found an interesting situation. Suppose you have some SwingWorker (I've made this one vaguely reminiscent of my own): public class AddressTreeBuildingWorker extends SwingWorker<Void, NodePair> { private DefaultTreeModel model; public AddressTreeBuildingWorker(DefaultTreeModel model) { } @Override protected Void doInBackground() { // Omitted; performs variable processing to build a tree of address nodes. } @Override protected void process(List<NodePair> chunks) { for (NodePair pair : chunks) { // Actually the real thing inserts in order. model.insertNodeInto(parent, child, parent.getChildCount()); } } private static class NodePair { private final DefaultMutableTreeNode parent; private final DefaultMutableTreeNode child; private NodePair(DefaultMutableTreeNode parent, DefaultMutableTreeNode child) { this.parent = parent; this.child = child; } } } If the work done in the background is significant then things work well - process() is called with relatively small lists of objects and everything is happy. Problem is, if the work done in the background is suddenly insignificant for whatever reason, process() receives a huge list of objects (I have seen 1,000,000, for instance) and by the time you process each object, you have spent 20 seconds on the Event Dispatch Thread, exactly what SwingWorker was designed to avoid. In case it isn't clear, both of these occur on the same SwingWorker class for me - it depends on the input data, and the type of processing the caller wanted. Is there a proper way to handle this? Obviously I can intentionally delay or yield the background processing thread so that a smaller number might arrive each time, but this doesn't feel like the right solution to me.

    Read the article

  • Getting a JFrame's actual current location

    - by Ian Fellows
    Hello community, I am trying to create a (child) JFrame which slides out from underneath one side of a second (parent) JFrame. The goal is to then have the child follow the parent around when it is moved, and respond to resizing events. This is somewhat related to this question. I have tried using a ComponentListener, but with this method the child only moves once the parent has come to a stop, whereas I would like the child to move as the parent is dragged around the screen. Another option I attempted was to start a new refresher thread that continually updated the child's location using getLocation() or getLocationOnScreen(), but the lag was the same as with ComponentListener. Is there a way to get the true actual location of a JFrame even in the midst of a drag? or if not, is there a way to get the effect of a sheet sliding out from underneath and following the Frame around?

    Read the article

  • How to set specific column settings in JTable?

    - by HansDampf
    How can I make my JTable show specific stuff for each column? Can I use an Object for more than one column? I want to have a column showing the date (dd.mm.yyyy) and another to show the time (hh:mm) but as I have it now it only shows the String representation of the Date object as a whole. public class AppointmentTableModel extends AbstractTableModel { ... @Override public Object getValueAt(int rowIndex, int columnIndex) { return appointments.get(rowIndex).getByColumn(columnIndex); } } public class Appointment { ... public Object getByColumn(int columnIndex) { switch (columnIndex) { case 0: return date; case 1: return date; case 2: return sample; case 3: return sample; case 4: return history; case 5: return comment; } return null; } }

    Read the article

  • Why does GC not clear the Dialog references?

    - by Pavel
    I have a dialog. Every time I create it and then dispose, it stays in memory. It seems to be a memory leak somewhere, but I can't figure it out. Do you have any ideas? See the screenshot of heap dump for more information. Thanks in advance. http://img441.imageshack.us/img441/5764/leak.png

    Read the article

  • Panel is not displaying in JFrame

    - by mallikarjun
    I created a chat panel and added to Jframe but the panel is not displaying. But my sop in the chat panel are displaying in the console. Any one please let me know what could be the problem My Frame public class MyFrame extends JFrame { MyPanel chatClient; String input; public MyFrame() { input = (String)JOptionPane.showInputDialog(null, "Name:", "Connect to chat server", JOptionPane.QUESTION_MESSAGE, null,null, "Test"); input=input.trim(); chatClient = new MyPanel("localhost",input); setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); add(chatClient); } public static void main(String...args){ new MyFrame(); } } MyPanel: public class MyPanel extends JPanel{ ChatClient chatClient; public MyPanel(String host, String uid) { chatClient= new ChatClient(host,uid); add(chatClient.getChatPanel()); this.setVisible(true); } } chat panel: public class ChatClient { Client client; String name; ChatPanel chatPanel; String hostid; public ChatClient(String host,String uid){ client = new Client(); client.start(); System.out.println("in constructor"); Network.register(client); client.addListener(new Listener(){ public void connected(Connection connection){ System.out.println("in client connected method"); Network.RegisterName registerName = new Network.RegisterName(); registerName.name=name; client.sendTCP(registerName); } public void received(Connection connection,Object object){ System.out.println("in client received method"); if (object instanceof Network.UpdateNames) { Network.UpdateNames updateNames = (Network.UpdateNames)object; //chatFrame.setNames(updateNames.names); System.out.println("got it message"); return; } if (object instanceof Network.ChatMessage) { Network.ChatMessage chatMessage = (Network.ChatMessage)object; //chatFrame.addMessage(chatMessage.text); System.out.println("send it message"); return; } } }); // end of listner name=uid.trim(); hostid=host.trim(); chatPanel = new ChatPanel(hostid,name); chatPanel.setSendListener(new Runnable(){ public void run(){ Network.ChatMessage chatMessage = new Network.ChatMessage(); chatMessage.chatMessage=chatPanel.getSendText(); client.sendTCP(chatMessage); } }); new Thread("connect"){ public void run(){ try{ client.connect(5000, hostid,Network.port); }catch(IOException e){ e.printStackTrace(); } } }.start(); }//end of constructor static public class ChatPanel extends JPanel{ CardLayout cardLayout; JList messageList,nameList; JTextField sendText; JButton sendButton; JPanel topPanel,bottomPanel,panel; public ChatPanel(String host,String user){ setSize(600, 200); this.setVisible(true); System.out.println("Chat panel "+host+"user: "+user); { panel = new JPanel(new BorderLayout()); { topPanel = new JPanel(new GridLayout(1,2)); panel.add(topPanel); { topPanel.add(new JScrollPane(messageList=new JList())); messageList.setModel(new DefaultListModel()); } { topPanel.add(new JScrollPane(nameList=new JList())); nameList.setModel(new DefaultListModel()); } DefaultListSelectionModel disableSelections = new DefaultListSelectionModel() { public void setSelectionInterval (int index0, int index1) { } }; messageList.setSelectionModel(disableSelections); nameList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); } { bottomPanel = new JPanel(new GridBagLayout()); panel.add(bottomPanel,BorderLayout.SOUTH); bottomPanel.add(sendText=new JTextField(),new GridBagConstraints(0,0,1,1,1,0,GridBagConstraints.CENTER,GridBagConstraints.BOTH,new Insets(0,0,0,0),0,0)); bottomPanel.add(sendButton=new JButton(),new GridBagConstraints(1,0,1,1,0,0,GridBagConstraints.CENTER,0,new Insets(0,0,0,0),0,0)); } } sendText.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ sendButton.doClick(); } }); } public void setSendListener (final Runnable listener) { sendButton.addActionListener(new ActionListener() { public void actionPerformed (ActionEvent evt) { if (getSendText().length() == 0) return; listener.run(); sendText.setText(""); sendText.requestFocus(); } }); } public String getSendText () { return sendText.getText().trim(); } public void setNames (final String[] names) { EventQueue.invokeLater(new Runnable(){ public void run(){ DefaultListModel model = (DefaultListModel)nameList.getModel(); model.removeAllElements(); for(String name:names) model.addElement(name); } }); } public void addMessage (final String message) { EventQueue.invokeLater(new Runnable() { public void run () { DefaultListModel model = (DefaultListModel)messageList.getModel(); model.addElement(message); messageList.ensureIndexIsVisible(model.size() - 1); } }); } } public JPanel getChatPanel(){ return chatPanel; } }

    Read the article

  • How to get components from a JFrame with a GridLayout?

    - by NlightNfotis
    I have a question about Java and JFrame in particular. Let's say I have a JFrame that I am using with a GridLayout. Supposing that I have added JButtons in the JFrame, how can I gain access to the one I want using it's position (by position, I mean a x and a y, used to define the exact place on the Grid). I have tried several methods, for instance getComponentAt(int x, int y), and have seen that those methods do not work as intended when combined with GridLayout, or at least don't work as intended in my case. So I tried using getComponent(), which seems fine. The latest method, that seems to be on a right track for me is (assuming I have a JFrame with a GridLayout with 7 rows and 7 columns, x as columns, y as rows): public JButton getButtonByXAndY(int x, int y) { return (JButton) this.getContentPane().getComponent((y-1) * 7 + x); } Using the above, say I want to get the JButton at (4, 4), meaning the 25th JButton in the JFrame, I would index through the first 21 buttons at first, and then add 4 more, finally accessing the JButton I want. Problem is this works like that in theory only. Any ideas? P.S sorry for linking to an external website, but stack overflow won't allow me to upload the image, because I do not have the required reputation.

    Read the article

  • Adding label and text box control to GUI

    - by Mike
    I would like to know what code to insert and where to add a simple label that can just say the word "Label" and a input text box that I can enter a number. public CalculateDimensions() { JTabbedPane Tab = new JTabbedPane(); JPanel jplInnerPanel1 = createInnerPanel("First Tab"); Tab.addTab("One", jplInnerPanel1); Tab.setSelectedIndex(0); JPanel jplInnerPanel2 = createInnerPanel("Second Tab"); Tab.addTab("Two", jplInnerPanel2); JPanel jplInnerPanel3 = createInnerPanel("Third Tab"); Tab.addTab("Three", jplInnerPanel3); JPanel jplInnerPanel4 = createInnerPanel("Fourth Tab"); Tab.addTab("Four", jplInnerPanel4); JPanel jplInnerPanel5 = createInnerPanel("Fifth Tab"); Tab.addTab("Five", jplInnerPanel5); setLayout(new GridLayout(1, 1)); add(Tab); } protected JPanel createInnerPanel(String text) { JPanel jplPanel = new JPanel(); JLabel jlbDisplay = new JLabel(text); jlbDisplay.setHorizontalAlignment(JLabel.CENTER); jplPanel.setLayout(new GridLayout(1, 1)); jplPanel.add(jlbDisplay); return jplPanel; } public static void main(String[] args) { JFrame frame = new JFrame("Calculations"); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); frame.getContentPane().add(new CalculateDimensions(), BorderLayout.CENTER); frame.setSize(400, 400); frame.setVisible(true); } }

    Read the article

  • GroupLayout: JScrollPane in TextArea is not working

    - by Dozent
    i'm new in java and recently started to develop an simple application. For the moment i have a problem with JScrollPanne, it's not able to scroll down (or up) when the text in textarea more than size of area. I have looked to some solutions, but all of them were for FlowLayot (GridLayout and BoxLayout), but not for GroupLayout. Here is the code: JPanel conent_p = new JPanel(); conent_p.setBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null)); JLabel lblItemName = new JLabel("Item name:"); itemField = new JTextField(); itemField.setColumns(10); JLabel lblMxPrice = new JLabel("Max price:"); mpriceField = new JTextField(); mpriceField.setColumns(10); JLabel lblQuantity = new JLabel("Quantity:"); quanField = new JTextField(); quanField.setColumns(10); JLabel lblDelivery = new JLabel("Delivery:"); delivField = new JTextField(); delivField.setColumns(10); JLabel lblLogcat = new JLabel("LogCat:"); final JTextArea txtConsole = new JTextArea(); txtConsole.setEditable(false); txtConsole.setLineWrap(true); txtConsole.setWrapStyleWord(true); sbrText = new JScrollPane(txtConsole); sbrText.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); // Now create a new TextAreaOutputStream to write to our JTextArea control and wrap a // PrintStream around it to support the println/printf methods. PrintStream out = new PrintStream(new TextAreaOutputStream(txtConsole)); // redirect standard output stream to the TextAreaOutputStream System.setOut(out); // redirect standard error stream to the TextAreaOutputStream System.setErr(out); GroupLayout gl_conent_p = new GroupLayout(conent_p); gl_conent_p.setHorizontalGroup( gl_conent_p.createParallelGroup(Alignment.LEADING) .addGroup(gl_conent_p.createSequentialGroup() .addContainerGap() .addGroup(gl_conent_p.createParallelGroup(Alignment.LEADING) .addComponent(lblMxPrice, Alignment.TRAILING) .addComponent(lblItemName, Alignment.TRAILING) .addComponent(lblLogcat, Alignment.TRAILING)) .addGap(18) .addGroup(gl_conent_p.createParallelGroup(Alignment.LEADING) .addGroup(gl_conent_p.createSequentialGroup() .addGroup(gl_conent_p.createParallelGroup(Alignment.LEADING, false) .addComponent(itemField, GroupLayout.PREFERRED_SIZE, 365, GroupLayout.PREFERRED_SIZE) .addGroup(gl_conent_p.createSequentialGroup() .addComponent(mpriceField, GroupLayout.PREFERRED_SIZE, 80, GroupLayout.PREFERRED_SIZE) .addGap(18) .addComponent(lblQuantity) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(quanField, 0, 0, Short.MAX_VALUE) .addGap(18) .addComponent(lblDelivery) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(delivField, GroupLayout.PREFERRED_SIZE, 80, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED))) .addGap(100)) .addGroup(gl_conent_p.createSequentialGroup() .addComponent(txtConsole, GroupLayout.PREFERRED_SIZE, 345, GroupLayout.PREFERRED_SIZE) .addComponent(sbrText) .addContainerGap()))) ); gl_conent_p.setVerticalGroup( gl_conent_p.createParallelGroup(Alignment.LEADING) .addGroup(gl_conent_p.createSequentialGroup() .addContainerGap() .addGroup(gl_conent_p.createParallelGroup(Alignment.BASELINE) .addComponent(lblItemName) .addComponent(itemField, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)) .addGap(20) .addGroup(gl_conent_p.createParallelGroup(Alignment.LEADING) .addGroup(gl_conent_p.createParallelGroup(Alignment.BASELINE) .addComponent(lblDelivery) .addComponent(delivField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGroup(gl_conent_p.createParallelGroup(Alignment.BASELINE) .addComponent(lblMxPrice) .addComponent(mpriceField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(lblQuantity) .addComponent(quanField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))) .addGap(55) .addGroup(gl_conent_p.createParallelGroup(Alignment.BASELINE) .addComponent(lblLogcat) .addComponent(txtConsole, GroupLayout.PREFERRED_SIZE, 200, GroupLayout.PREFERRED_SIZE) .addComponent(sbrText)) .addContainerGap()) ); conent_p.setLayout(gl_conent_p); getContentPane().add(conent_p, BorderLayout.NORTH); JButton btnBuy = new JButton("Buy"); btnBuy.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ev) { try { String title = itemField.getText().trim(); String mprice = mpriceField.getText().trim(); String quantity = quanField.getText().trim(); String deliver = delivField.getText().trim(); Item_CONCEPT item = new Item_CONCEPT(); item.setName(title); item.setDelivery(Integer.parseInt(deliver)); item.setStartPrice(0); item.setMaxPrice(Integer.parseInt(mprice)); myAgent.existsSeller(item); Date date = new Date(); DateFormat df = new SimpleDateFormat("dd.MM.yy HH:mm"); System.out.println(df.format(date)+": Buyer orders an item: "+item.getName()); //Clearing all fields itemField.setText(""); quanField.setText(""); delivField.setText(""); //txtConsole.setText(""); mpriceField.setText(""); } catch (Exception e) { JOptionPane.showMessageDialog(BuyerGUI.this, "A field is filled incorrectly. "+e.getMessage()+" is invalid.", "Error", JOptionPane.ERROR_MESSAGE); } } } );![enter image description here][1]

    Read the article

  • redirect inputStream to JTextField

    - by gt_ebuddy
    I want to redirect the Standard System input to JTextField, So that a user must type his/her input in JTextField (instead of console.) I found System.setIn(InputStream istream) for redirecting System.in. Here is my scratch code where i confused on reading from JTextField - inputJTextField. System.setIn(new InputStream() { @Override public int read() throws IOException { //how to read content? return Integer.parseInt(inputJTextField.getText()); } }); My Question is how to read content from GUI Component ( like JTextField and Cast it to String and other types after redirecting the input stream?

    Read the article

  • a problem with JTabedPanel

    - by sirvan
    hi, I have an application that includes an JtabedPanel and two Tabes with some componetnts,my problem is when i click on another Tab,it's components not appeared immediately but when mouse courser move over each component(Jcheckbox,Jbutton and so on) of the tab,the components will appear but not correctly (see below image) This is my CODE . . .

    Read the article

  • How to center elements in the BoxLayout using center of the element?

    - by Roman
    I use outputPanel.setLayout(new BoxLayout(outputPanel, BoxLayout.Y_AXIS)); and then I add elements (for example JLabels, JButtons) to the outputPanel. For example: outputPanel.add(submitButton);. I see that all added elements are "centered". It is good, because I do want my elements to be in the center. When I write "center" I mean "equal distance from left and right". But the problem is that the left part of the element is put into the center. And I want to have center of elements to be put into the center. How can I get this behavior?

    Read the article

< Previous Page | 29 30 31 32 33 34 35 36 37 38 39 40  | Next Page >