Search Results

Search found 37239 results on 1490 pages for 'javax swing text'.

Page 66/1490 | < Previous Page | 62 63 64 65 66 67 68 69 70 71 72 73  | Next Page >

  • Writing long line support for text editor

    - by Mathematician82
    I know that some some text editors have problems to show long lines https://bugzilla.gnome.org/show_bug.cgi?id=172099 . What is the best way to fix the bug or are they equally well? Modify the GTK+ source code and add a support for long lines. Modify the text editor source code such that it does not use GTK+ if it meets a long line. Split the long lines into part (maybe by cut on the Bash ) I'm just a junior programmer so I don't know what people does when they meet a bug that is on the library they use.

    Read the article

  • Really slow obtaining font metrics.

    - by Artur
    So the problem I have is that I start my application by displaying a simple menu. To size and align the text correctly I need to obtain font metrics and I cannot find a way to do it quickly. I tested my program and it looks like whatever method I use to obtain font metrics the first call takes over 500 milliseconds!? Because of it the time it takes to start-up my application is much longer than necessary. I don't know if it is platform specific or not, but just in case, I'm using Mac OS 10.6.2 on MacBook Pro (hardware isn't an issue here). If you know a way of obtaining font metrics quicker please help. I tried these 3 methods for obtaining the font metrics and the first call is always very slow, no matter which method I choose. import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.font.FontRenderContext; import java.awt.font.LineMetrics; import javax.swing.JFrame; public class FontMetricsTest extends JFrame { public FontMetricsTest() { setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } @Override public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Font font = new Font("Dialog", Font.BOLD, 10); long start = System.currentTimeMillis(); FontMetrics fontMetrics = g2.getFontMetrics(font); // LineMetrics fontMetrics1 = // font.getLineMetrics("X", new FontRenderContext(null, false, false)); // FontMetrics fontMetrics2 = g.getFontMetrics(); long end = System.currentTimeMillis(); System.out.println(end - start); g2.setFont(font); } public static void main(String[] args) { new FontMetricsTest(); } }

    Read the article

  • Is there a difference between plain text emails, and multipart emails with only plain text?

    - by Brian Armstrong
    I'm using Rails to send emails and I just want to send a plain text email (there is no corresponding HTML part). I've noticed that if I just have one file named email.text.plain.erb it actually generates a multipart email with one part (the plain text part) like this: Content-Type: multipart/alternative; boundary=mimepart_4c04a2d34c4bb_690a4e56b0362 --mimepart_4c04a2d34c4bb_690a4e56b0362 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: Quoted-printable Content-Disposition: inline text of the email here... --mimepart_4c04a2d34c4bb_690a4e56b0362-- But if I take out the text.plain part and name it email.erb ActionMailer generates a regular plain text email without multipart like this: Content-Type: text/plain; charset=utf-8 text of the email here... Both work fine most of the time (so this is kind of nitpicky), but I guess my question is whether the second one is more correct. My goal here is just to make sure deliverability is as high as possible across a wide variety of devices and email clients. I've read that plain text emails can have slightly better deliverability rates than html and was just curious if throwing in this multipart (even if it only contained a plain text part) might throw off some of the dumber email clients. Thanks for your help!

    Read the article

  • Error when creating JFrame from JFrame

    - by Aly
    Hi, I have an application that is works fine and the JFrame for it is launched in the constructor of a GameInitializer class which takes in some config parameters. I have tried to create a GUI in which allows the user to specify these config parameters and then click submit. When the user clicks submit a new GameInitializer object is created. The error I am getting is: Exception in thread "AWT-EventQueue-0" java.lang.Error: Cannot call invokeAndWait from the event dispatcher thread at java.awt.EventQueue.invokeAndWait(Unknown Source) at javax.swing.SwingUtilities.invokeAndWait(Unknown Source) at game.player.humanplayer.view.HumanView.update(HumanView.java:43) once submit is called this code is executed: values assigned to parames... new GameInitializer(userName, player, Constants.BLIND_STRUCTURE_FILES.get(blindStructure), handState); Then code in the GameInitializer constructor is: public GameInitializer(String playerName, AbstractPlayer opponent, String blindStructureConfig, AbstractHandState handState){ beginGame(playerName, opponent, blindStructureConfig, handState); } public static void beginGame(String playerName, AbstractPlayer opponent, String blindStructureConfig, AbstractHandState handState){ AbstractDealer dealer; BlindStructure.initialize(blindStructureConfig); AbstractPlayer humanPlayer = new HumanPlayer(playerName, handState); AbstractPlayer[] players = new AbstractPlayer[2]; players[0] = humanPlayer; players[1] = opponent; handState.setTableLayout(players); for(AbstractPlayer player : players){ player.initialize(); } dealer = new Dealer(players, handState); dealer.beginGame(); } It basically cascades down and eventually calls this piece of code in the HumanView class: public void update(final Event event, final ReadableHandState handState, final AbstractPlayer player) { try { SwingUtilities.invokeAndWait(new Runnable() { public void run() { gamePanel.update(event, handState, player); validate(); } }); } catch (InterruptedException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } if(event.equals(Event.HAND_ENDING)){ try { if(handState.wonByShowdown() || handState.isSplitPot()){ Thread.sleep(3500); } else{ Thread.sleep(1000); } } catch (InterruptedException e) { e.printStackTrace(); } } } Do you have any idea why?

    Read the article

  • error insert text in papervision typography class

    - by safeDomain
    hi evryone , i am encounter with a small problem i want to make a 3d rtl text animation with papervision this code generet a problem to this : [Fault] exception, information=TypeError: Error #1009: Cannot access a property or method of a null object reference. but when using a english text this error dont genereta my code : package { import flash.display.Sprite; import flash.events.Event; import org.papervision3d.scenes.Scene3D import org.papervision3d.view.Viewport3D import org.papervision3d.cameras.Camera3D import org.papervision3d.render.BasicRenderEngine import org.papervision3d.typography.Font3D import org.papervision3d.typography.fonts.HelveticaBold import org.papervision3d.typography.Text3D import org.papervision3d.materials.special.Letter3DMaterial import flash.text.engine.FontDescription import flash.text.engine.ElementFormat import flash.text.engine.TextElement import flash.text.engine.TextBlock import flash.text.engine.TextLine /** * ... * @author vahid */ public class Main extends Sprite { private var fd:FontDescription private var ef:ElementFormat private var te:TextElement protected var st:String; private var scene:Scene3D private var view:Viewport3D private var camera:Camera3D private var render:BasicRenderEngine private var vpWidth:Number = stage.stageWidth; private var vpHeight:Number = stage.stageHeight; private var text3d:Text3D private var font3d:Font3D //private var font:HelveticaBold private var textMaterial:Letter3DMaterial private var text:String public function Main():void { if (stage) init(); else addEventListener(Event.ADDED_TO_STAGE, init); } private function init(e:Event = null):void { removeEventListener(Event.ADDED_TO_STAGE, init); // rtl block fd = new FontDescription () ef = new ElementFormat (fd) te = new TextElement ("?????? ?????? ???? ?????? ?? papervision", ef) text = te.text //3d block scene = new Scene3D () view = new Viewport3D (vpWidth,vpHeight,true,true,false,false) camera = new Camera3D () render = new BasicRenderEngine() addChild (view) this.addEventListener (Event.ENTER_FRAME , renderThis) textMaterial = new Letter3DMaterial(0xFF0000,1) font3d = new HelveticaBold() text3d = new Text3D (text, font3d, textMaterial) scene.addChild (text3d) } protected function renderThis(e:Event):void { text3d.rotationY +=5 render.renderScene(scene,camera,view) } } } i am using flashdevelop. please help me thank's

    Read the article

  • What is best practice (and implications) for packaging projects into JAR's?

    - by user245510
    What is considered best practice deciding how to define the set of JAR's for a project (for example a Swing GUI)? There are many possible groupings: JAR per layer (presentation, business, data) JAR per (significant?) GUI panel. For significant system, this results in a large number of JAR's, but the JAR's are (should be) more re-usable - fine-grained granularity JAR per "project" (in the sense of an IDE project); "common.jar", "resources.jar", "gui.jar", etc I am an experienced developer; I know the mechanics of creating JAR's, I'm just looking for wisdom on best-practice. Personally, I like the idea of a JAR per component (e.g. a panel), as I am mad-keen on encapsulation, and the holy-grail of re-use accross projects. I am concerned, however, that on a practical, performance level, the JVM would struggle class loading over dozens, maybe hundreds of small JAR's. Each JAR would contain; the GUI panel code, necessary resources (i.e. not centralised) so each panel can stand alone. Does anyone have wisdom to share?

    Read the article

  • JScrollPanel without scrollbars

    - by Erik Itland
    I'm trying to use a JScrollPanel to display a JPanel that might be too big for the containing Jpanel. I don't want to show the scrollbars (yes, this is questionable UI design, but it is my best guess of what the customer wants. We use the same idea other places in the application, and I feel this case have given me enough time to ponder if I can do it in a better way, but if you have a better idea I might accept it an answer.) First attempt: set verticalScrollBarPolicy to NEVER. Result: Scrolling using mouse wheel doesn't work. Second attempt: set the scrollbars to null. Result: Scrolling using mouse wheel doesn't work. Third attempt: set scrollbars visible property to false. Result: It is immidiately set visible by Swing. Fourth attempt: inject a scrollbar where setVisible is overridden to do nothing when called with true. Result: Can't remember exactly, but I think it just didn't work. Fifth attempt: inject a scrollbar where setBounds are overridden. Result: Just didn't look nice. (I might have missed something here, though.) Sixth attempt: ask stackoverflow. Result: Pending. Scrolling works once scrollbars are back.

    Read the article

  • After Adding "readonly" attribute on text box not able to remove it in one event

    - by Sreedhar K
    Steps to repro USE Internet Explorer Check unlimited check box Click on text box (It will remove tick/check from check box) Try to enter text in text box We cannot enter in the text box 4. Click again on the text box. Now we will be able to enter text in the text box We tried by 1. Making attribute readOnly to flase i.e. $('#myinput').attr('readOnly', false); 2. Calling $('#myinput').click(); Below is the HTML code <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Make input read only</title> <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.4.min.js"></script> </head> <body> <input id="myinput" type="text" /> <input id="mycheck" type="checkbox" /> <script type="text/javascript"> /*oncheck box click*/ $('#mycheck').click(function () { if ($(this).attr('checked')) { $('#myinput').attr('readOnly', 'readOnly'); } else { $('#myinput').removeAttr('readOnly'); /* also tried * $('#myinput').attr('readOnly', false); * $('#myinput').attr('readOnly', ''); */ } }); /*on text box click*/ $('#myinput').click(function () { $('#mycheck').removeAttr('checked'); $('#myinput').removeAttr('readOnly'); /* also tried * $('#myinput').attr('readOnly', false); * $('#myinput').attr('readOnly', ''); */ }); </script> </body> </html> Live copy

    Read the article

  • Why setPreferredSize does not change the size of the button?

    - by Roman
    Here is the code: import javax.swing.*; import java.awt.event.*; import java.awt.*; public class TestGrid { public static void main(String[] args) { JFrame frame = new JFrame("Colored Trails"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); JPanel panel = new JPanel(); panel.setLayout(new GridLayout(4, 9)); panel.setMaximumSize(new Dimension(9*30-20,4*30)); JButton btn; for (int i=1; i<=4; i++) { for (int j=1; j<=4; j++) { btn = new JButton(); btn.setPreferredSize(new Dimension(30, 30)); panel.add(btn); } btn = new JButton(); btn.setPreferredSize(new Dimension(30, 10)); panel.add(btn); for (int j=1; j<=4; j++) { btn = new JButton(); btn.setPreferredSize(new Dimension(30, 30)); panel.add(btn); } } mainPanel.add(panel); frame.add(mainPanel); frame.setSize(450,950); frame.setVisible(true); } } I suppose to have a table of buttons with 4 rows and 9 columns. And the middle column should be narrower that other columns. I tried Dimension(30, 10) and Dimension(30, 10) both have no effect on the width of the middle column. Why?

    Read the article

  • Best Practice With JFrame Constructors?

    - by David Barry
    In both my Java classes, and the books we used in them laying out a GUI with code heavily involved the constructor of the JFrame. The standard technique in the books seems to be to initialize all components and add them to the JFrame in the constructor, and add anonymous event handlers to handle events where needed, and this is what has been advocated in my class. This seems to be pretty easy to understand, and easy to work with when creating a very simple GUI, but seems to quickly get ugly and cumbersome when making anything other than a very simple gui. Here is a small code sample of what I'm describing: public class FooFrame extends JFrame { JLabel inputLabel; JTextField inputField; JButton fooBtn; JPanel fooPanel; public FooFrame() { super("Foo"); fooPanel = new JPanel(); fooPanel.setLayout(new FlowLayout()); inputLabel = new JLabel("Input stuff"); fooPanel.add(inputLabel); inputField = new JTextField(20); fooPanel.add(inputField); fooBtn = new JButton("Do Foo"); fooBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { //handle event } }); fooPanel.add(fooBtn); add(fooPanel, BorderLayout.CENTER); } } Is this type of use of the constructor the best way to code a Swing application in java? If so, what techniques can I use to make sure this type of constructor is organized and maintainable? If not, what is the recommended way to approach putting together a JFrame in java?

    Read the article

  • Java application design question

    - by ring bearer
    I have a hobby project, which is basically to maintain 'todo' tasks in the way I like. One task can be described as: public class TodoItem { private String subject; private Date dueBy; private Date startBy; private Priority priority; private String category; private Status status; private String notes; } As you can imagine I would have 1000s of todo items at a given time. What is the best strategy to store a todo item? (currently on an XML file) such that all the items are loaded quickly up on app start up(the application shows kind of a dashboard of all the items at start up)? What is the best way to design its back-end so that it can be ported to Android/or a J2ME based phone? Currently this is done using Java Swing. What should I concentrate on so that it works efficiently on a device where memory is limited? The application throws open a form to enter new todo task. For now, I would like to save the newly added task to my-todos.xml once the user presses "save" button. What are the common ways to append such a change to an existing XML file?(note that I don't want to read the whole file again and then persist)

    Read the article

  • Why isn't componentHidden called for my JPopupMenu?

    - by heycam
    I want to be notified when my JPopupMenu is hidden — whether because an item was selected, the menu was dismissed, or setVisible(false) was called on it. Here is my test code: import javax.swing.*; import java.awt.*; import java.awt.event.*; public class A extends ComponentAdapter implements Runnable, ActionListener { private JButton b; public static void main(String[] args) { EventQueue.invokeLater(new A()); } public void run() { JFrame f = new JFrame("Test"); b = new JButton("Click me"); b.addActionListener(this); f.add(b); f.pack(); f.setVisible(true); } public void actionPerformed(ActionEvent e) { JPopupMenu pm = new JPopupMenu(); pm.addComponentListener(this); pm.add("Popup..."); pm.add("...menu!"); pm.show(b, 10, 10); } public void componentShown(ComponentEvent e) { System.out.println("componentShown"); } public void componentHidden(ComponentEvent e) { System.out.println("componentHidden"); } } Regardless of how I interact with the menu, neither of the two ComponentListener methods are being called. Why is that? Is there different/better/correct way of finding out when my JPopupMenu is hidden? Thanks, Cameron

    Read the article

  • Why SetMinimumSize sets the minimal heights but not width?

    - by Roman
    Here is my code: import javax.swing.*; import java.awt.*; public class PanelModel { public static void main(String[] args) { JFrame frame = new JFrame("Colored Trails"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); JPanel firstPanel = new JPanel(); firstPanel.setLayout(new GridLayout(4, 4)); firstPanel.setMaximumSize(new Dimension(4*100, 4*100)); firstPanel.setMinimumSize(new Dimension(4*100, 4*100)); JButton btn; for (int i=1; i<=4; i++) { for (int j=1; j<=4; j++) { btn = new JButton(); btn.setPreferredSize(new Dimension(100, 100)); firstPanel.add(btn); } } mainPanel.add(firstPanel); frame.add(mainPanel); frame.setSize(520,600); //frame.setMinimumSize(new Dimension(520,600)); frame.setVisible(true); } } When I increase the size of the window (by mouse) I see that my panel does not increase its size. It is the expected behavior (because I set the maximal size of the panel). However, when I decrease the size of the window, I see that width of the panel is decreased too (while the height is constant). So, the setMinimumSize works only partially. Why is that?

    Read the article

  • How do I integrate GUI elements from different classes at runtime?

    - by thefourthdoctor
    I'm trying to "future-proof" an application that I'm writing by splitting out those elements that are likely to change over time. In my application I need to be able to adapt to changes in the output format (e.g. today I output to a CSV file, in the future I may need to output directly to a SQL Server database, or to a web service, etc.). I'm handling this by defining an abstract class ("OutputProvider") that I will subclass for each individual case. The one aspect of this that has me stumped is how to provide a configuration GUI that is specific to each concrete class. I have a settings dialog with a tab for output configuration. On that tab I intend to provide a drop-down to select the provider and a JPanel beneath it to hold the contents of the provider-specific GUI. How do I get the right GUI in that panel at runtime and have it behave correctly with respect to events? Also, a bonus would be if there was a way to do this such that in order to add support for new providers I could simply provide a new jar or class file to be dropped in a specific folder and the application could pick that up at startup. I'm using NetBeans and Swing.

    Read the article

  • Components don't show in custom JPanel/JComponent

    - by Bart van Heukelom
    I've created a custom swing component. I can see it (the grid from the paint method is drawn), but the buttons that are added (verified by println) aren't shown. What am I doing wrong? Background information: I'm trying to build a tree of visible objects like the Flash/AS3 display list. public class MapPanel extends JComponent { // or extends JPanel, same effect private static final long serialVersionUID = 4844990579260312742L; public MapPanel(ShapeMap map) { setBackground(Color.LIGHT_GRAY); setPreferredSize(new Dimension(1000,1000)); setLayout(null); for (Layer l : map.getLayers()) { // LayerView layerView = new LayerView(l); // add(layerView); System.out.println(l); JButton test = new JButton(l.getName()); add(test); validate(); } } @Override protected void paintComponent(Graphics g) { // necessary? super.paintComponent(g); // background g.setColor(getBackground()); g.fillRect(0, 0, getWidth(), getHeight()); // grid g.setColor(Color.GRAY); for (double x = 0; x < getWidth(); x += 10) { g.drawLine((int)x, 0, (int)x, getHeight()); } for (double y = 0; y < getHeight(); y += 10) { g.drawLine(0, (int)y, getWidth(), (int)y); } } }

    Read the article

  • JTable data only shown after scrolling

    - by Christian 'fuzi' Orgler
    I wrote a method, that creates my DefaultTableModel and there I'm going to add my records. When I set the model to my JTable, the data rows are blank. After scrolling the data gets displayed correct. How can I avoid this and display the data from the first moment? EDIT: I imported the javax.swing.table.DefaultTableModel -- is this correct? private DefaultTableModel _dtm; private void loadTable(Vector<Member> members) { loadTableModel(); try { lbl_state.setText("Please wait"); for (Member actMember : members) { String gender = ""; if (actMember.getGender() == MemberView.MEMBER_MALE) { gender = "männlich"; } else { gender = "weiblich"; } _dtm.addRow(new Object[]{ actMember.getNname(), actMember.getVname(), actMember.getCity(), actMember.getStreet(), actMember.getPlz(), actMember.getMail(), actMember.getPhonenumber(), actMember.getBirthdayString(), actMember.getStartDateString(), gender, actMember.getBankname(), actMember.getAccountnumber(), actMember.getBanknumber(), actMember.getGroup().toString(), (actMember.hasAccess() ? "JA" : "NEIN"), actMember.getWriteDateString(), (actMember.hasDrinkAbo() ? "JA" : "NEIN") }); } } catch (Exception ex) { System.err.println(ex.getMessage()); } tbl_results.setModel(_dtm); } private void loadTableModel() { _dtm = new DefaultTableModel(new Object[]{"Nachname", "Vorname", "Ort", "Straße", "PLZ", "E-Mail", "Telefon", "Geburtsdatum", "Beitrittsdatum", "Geschlecht", "Bankname", "Kontonummer", "Bankleitzahl", "Gruppe", "hat Zugriff", "Einschreibdatum", "Getränkeabo"}, 0); tbl_results.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); }

    Read the article

  • Add JTabbedPane with buttons, labels ... in a frame with an absolute layout

    - by alibenmessaoud
    I have a code in java. package interfaces; import javax.swing.JPanel; public class TabbedPaneDemo extends JPanel { public TabbedPaneDemo() { JTabbedPane pane = new JTabbedPane(); JPanel dashboardPanel = new JPanel(); dashboardPanel.add(new JLabel("Dashboard")); // Add Dashboard Tab pane.addTab("Dashboard", dashboardPanel); JPanel transactionPanel = new JPanel(); transactionPanel.add(new JLabel("Transactions")); // Add Transactions Tab pane.addTab("Transactions", transactionPanel); JPanel accountPanel = new JPanel(); accountPanel.add(new JLabel("Account")); // Add Account Tab pane.addTab("Account", accountPanel); this.setLayout(new BorderLayout()); this.setPreferredSize(new Dimension(400, 200)); this.add(pane, BorderLayout.CENTER); } public static void main(String[] args) { JPanel panel = new TabbedPaneDemo(); panel.setOpaque(true); // panel.setBounds(12, 12, 45, 98); JFrame frame = new JFrame("JTabbedPane Demo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setContentPane(panel); frame.pack(); frame.setVisible(true); }} and the output it's ! I want to change in this code to be like this. I want use an absolute layout (null). I want to add menu, buttons and labels with these tabs ... How can I do?? Thanks in advance. Best regards, Ali

    Read the article

  • java gui image problem : doesn't display in the background

    - by thegamer
    Hello, i have a query about why is my image not being displayed in my background of my program. I mean i did all the steps necessary and still it would'nt be displayed. The code runs perfectly but without having the image displayed. The directory is written in the good location of the image. I am using java with gui. If anyone could help me solve my problem, i would appreciate :) here is the code below: import java.awt.*; import java.awt.event.*; import javax.swing.*; public class hehe extends JPanel{ public hehe(){ setOpaque(false); setLayout(new FlowLayout()); } public static void main (String args[]){ JFrame win = new JFrame("yooooo"); // it is automaticcally hidden JPanel mainPanel = new JPanel(new BorderLayout()); win.add(mainPanel); JLabel titleLabel = new JLabel("title boss"); titleLabel.setFont(new Font("Arial",Font.BOLD,18)); titleLabel.setForeground(Color.blue); mainPanel.add(titleLabel,BorderLayout.NORTH); win.setSize(382,269); // the dimensions of the image win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); win.setVisible(true); } public void paint(Graphics g) { Image a = Toolkit.getDefaultToolkit().getImage("C:\\Users\\andrea\\Desktop\\Gui\\car"); // car is the name of the image file and is in JPEG g.drawImage(a,0,0,getSize().width,getSize().height,this); super.paint(g); } }

    Read the article

  • correct way of initializing variables

    - by OVERTONE
    ok this is just a shot in the dark but it may be the cause of most of the errors ive gotten. when your initializing something. lets say a smal swing program. would it go liek this variables here { private Jlist contactList; String [] contactArray; ArrayList <String> contactArrayList; ResultSet namesList constructor here public whatever() { GridLayout aGrid = new GridLayout(2,2,10,10); contact1 = new String(); contact2 = new String(); contact3 = new String(); contactArrayList = new ArrayList<String>(); // is something supposed too go in the () of this JList? contactList = new JList(); contactArray = new String[5]; from1 =new JLabel ("From: " + contactArray[1]); gridlayout.add(components)// theres too many components to write onto SO. } // methods here public void fillContactsGui() { createConnection(); ArrayList<String> contactsArrayList = new ArrayList<String>(); while (namesList.next()) { contactArrayList.add(namesList.getString(1)); ContactArray[1] = namesList[1]; } } i know this is probably a huge beginner question but this is the code ive gotten used too. im initializing thigns three and fours times without meaning too because im not sure where they gp. can anyone shed some light on this? p.s. sorry for the messy sample code. i done my best.

    Read the article

  • How to start matching and saving matched from exact point in a text

    - by yuliya
    I have a text and I write a parser for it using regular expressions and perl. I can match what I need with two empty lines (I use regexp), because there is a pattern that allows recognize blocks of text after two empty lines. But the problem is that the whole text has Introduction part and some text in the end I do not need. Here is a code which matches text when it finds two empty lines #!/usr/bin/perl use strict; use warnings; my $file = 'first'; open(my $fh, '<', $file); my $empty = 0; my $block_num = 1; open(OUT, '>', $block_num . '.txt'); while (my $line = <$fh>) { chomp ($line); if ($line =~ /^\s*$/) { $empty++; } elsif ($empty == 2) { close(OUT); open(OUT, '>', ++$block_num . '.txt'); $empty = 0; } else { $empty = 0;} print OUT "$line\n"; } close(OUT); This is example of the text I need (it's really small :)) this is file example I think that I need to iterate over the text till the moment it will find the word LOREM IPSUM with regexps this kind "/^LOREM IPSUM/", because it is the point from which needed text starts(and save the text in one file when i reach the word). And I need to finish iterating over the text when INDEX word is fount or save the text in separate file. How could I implement it. Should I use next function to proceed with lines or what? BR, Yuliya

    Read the article

  • Evaluating creation of GUI via file vs coding

    - by nevets1219
    I'm working on a utility that will be used to test the project I'm currently working on. What the utility will do is allow user to provide various inputs and it will sends out requests and provide the response as output. However, at this point the exact format (which input is required and what is optional) has yet to be fleshed out. In addition, coding in Swing is somewhat repetitive since the overall work is simple though this should be the safest route to go as I have more or less full control and every component can be tweaked as I want. I'm considering using a configuration file that's in XML to describe the GUI (at least one part of it) and then coding the event handling part (in addition to validation, etc). The GUI itself shouldn't be too complicated. For each type of request to make there's a tab for the request and within each tab are various inputs. There seems to be quite a few questions about this already but I'm not asking for a 3rd party library to do this. I'm looking to do this myself, since I don't think it'll be too overly complicated (hopefully). My main consideration for using this is re-usability (later on, for other projects) and for simplifying the GUI work. My question is: are there other pros/cons that I'm overlooking? Is it worth the (unknown) time to do this? I've built GUI in VB.NET and with Flex3 before.

    Read the article

  • java label setText and setBounds clashing?

    - by java
    I would like to have a JLabel changint color to a random one, while jumping to a random position, and while changing its text. but the setText and setBounds seem to clash and i don't know why. if you comment out the setText then the setBounds will work, but they won't work together. import java.awt.*; import java.util.*; import javax.swing.*; public class test2 extends JFrame { private static JLabel label = new JLabel("0"); private static Random gen = new Random(); public test2() { JPanel panel = new JPanel(); panel.add(label); this.add(panel); } public static void move() { for (int i = 0; i < 10; i++) { int n = gen.nextInt(254)+1; int nn = gen.nextInt(254)+1; int nnn = gen.nextInt(254)+1; label.setText(""+i); //the setBounds command will not work with the setText command. why? label.setBounds(n*2, nn*2, 20, 20); label.setForeground(new Color(n, nn, nnn)); try { Thread.sleep(200); } catch (Exception e) {} } } public static void main(String[] args) { test2 frame = new test2(); frame.setVisible(true); frame.setSize(600, 600); frame.setResizable(true); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); move(); } }

    Read the article

  • Set JTabbedPane width to constant

    - by msp
    I'm implementing an UI in Java Swing. Therefore I use a JTabbedPane. The tabbedPane has no components at startup. When i add a tab to the tabbedpane, the width of the tabbedpane increases, when i remove the tab, the width resizes to the width at the startup. This should not happen. The tabbedpane is placed on a JPanel which has a gridbag layout. Layout code: Container contentPane = mainFrame.getContentPane(); contentPane.setLayout( new GridBagLayout() ); GridBagConstraints c = new GridBagConstraints(); // add the component tree initComponentTree(); c.gridx = 0; c.gridy = 0; c.gridheight = 1; c.gridwidth = 1; c.fill = GridBagConstraints.BOTH; c.anchor = GridBagConstraints.LINE_START; c.weightx = 1; c.weighty = 1; contentPane.add( componentTree, c ); // add the tabbed pane initTabbedPane(); c.gridx = 1; c.weightx = 10; contentPane.add( tabbedPane, c ); // add the status panel initStatusPanel(); c.gridx = 0; c.gridy = 1; c.gridwidth = 2; c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.LINE_START; c.weightx = 0; c.weighty = 0; contentPane.add( statusPanel, c ); Hope someone can help!

    Read the article

< Previous Page | 62 63 64 65 66 67 68 69 70 71 72 73  | Next Page >