This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.{ Color, Dimension, Font } | |
import javax.swing._ | |
import javax.swing.border.LineBorder | |
import javax.swing.plaf.FontUIResource | |
object JavaSwingTest2 { | |
def main(args: Array[String]) = { | |
SwingUtilities.invokeLater { | |
new Runnable { | |
override def run() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ラベルにアイコンとテキストを表示 | |
// テキストはアイコンの下中央 | |
import java.awt.Font | |
import javax.swing._ | |
import javax.swing.plaf.FontUIResource | |
object JavaSwingTest1 { | |
def init() = { | |
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TableのセルにJEditorPaneを表示する | |
class EditorPane extends TextComponent { | |
override lazy val peer = new JEditorPane | |
} | |
class EditorPaneRenderer(comp: EditorPane) extends Table.AbstractRenderer[String, EditorPane](comp) { | |
override def configure(table: Table, isSelected: Boolean, hasFocus: Boolean, a: String, row: Int, column: Int): Unit = { | |
component.text = a | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// List#sort, Sorting.stableSort | |
import scala.collection.mutable | |
import scala.util.Sorting | |
List(1, 3, 2).sort(_ < _) // List(1, 2, 3) | |
val ar = Array(1, 3, 2) | |
Sorting.stableSort(ar) | |
ar // Array(1, 2, 3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TwitterのPublic Timelineを取得し、ユーザ名とツイートを表示する | |
// 元 http://gist.github.com/240444 | |
import scala.io.Source | |
import scala.xml.XML | |
val source = Source.fromURL("http://twitter.com/statuses/public_timeline.xml", "UTF-8") | |
val contents = source.getLines.mkString | |
val doc = XML.loadString(contents) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Twitter4jで検索 | |
import scala.collection.jcl.Conversions.convertList | |
import twitter4j.{Tweet, QueryResult, Query, Twitter} | |
object Twitter4jSearch { | |
def main(args: Array[String]) { | |
val queryString = "#scala" | |
val lang = "ja" | |
val rpp = 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// java.util.Properties load/store, get/set | |
import java.io._ | |
import java.util.{Date, Properties} | |
import org.apache.commons.io.IOUtils | |
object PropertiesLoadStore { | |
def main(args: Array[String]) { | |
val configFile = new File("PropertiesLoadStore.properties") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Twitter4jで公開タイムラインの取得 | |
import java.text.SimpleDateFormat | |
import scala.collection.jcl.Conversions.convertList | |
import twitter4j.{Status, Twitter} | |
object Twitter4jGetPublicTimeline { | |
def main(args: Array[String]) { | |
val twitter = new Twitter | |
val statuses = twitter.getPublicTimeline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Apache HttpComponents HttpClient Get ResponseHandler | |
import java.io.File | |
import java.io.IOException | |
import java.net.URI | |
import java.net.URISyntaxException | |
import java.net.URLDecoder | |
import java.net.UnknownHostException | |
import org.apache.commons.io.FileUtils | |
import org.apache.commons.io.FilenameUtils |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Apache HttpComponents HttpClient Get | |
import java.io.{ File, IOException } | |
import java.net.{ URI, UnknownHostException, URLDecoder } | |
import org.apache.http.impl.client.DefaultHttpClient | |
import org.apache.http.client.methods.HttpGet | |
import org.apache.http.{ HttpResponse, HttpEntity, HttpStatus } | |
import org.apache.http.util.EntityUtils | |
import org.apache.commons.io.{ FileUtils, FilenameUtils } |
NewerOlder